diff options
Diffstat (limited to 'src/H5FD.c')
-rw-r--r-- | src/H5FD.c | 37 |
1 files changed, 19 insertions, 18 deletions
@@ -50,7 +50,7 @@ #include "H5FDstream.h" /* In-memory files streamed via sockets */ #include "H5FLprivate.h" /* Free lists */ #ifdef H5_HAVE_FPHDF5 -#include "H5FPprivate.h" /*Flexible Parallel HDF5 */ +#include "H5FPprivate.h" /* Flexible Parallel HDF5 */ #endif /* H5_HAVE_FPHDF5 */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ @@ -121,7 +121,7 @@ H5FD_init_interface(void) FUNC_ENTER_NOAPI_NOINIT(H5FD_init_interface) - if (H5I_register_type(H5I_VFL, H5I_VFL_HASHSIZE, 0, (H5I_free_t)H5FD_free_cls)<0) + if (H5I_register_type(H5I_VFL, H5I_VFL_HASHSIZE, 0, (H5I_free_t)H5FD_free_cls)<H5I_FILE) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Reset the file serial numbers */ @@ -160,7 +160,7 @@ H5FD_term_interface(void) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_term_interface) if (H5_interface_initialize_g) { - if ((n=H5I_nmembers(H5I_VFL))) { + if ((n=H5I_nmembers(H5I_VFL))!=0) { H5I_clear_type(H5I_VFL, FALSE); /* Reset the VFL drivers, if they've been closed */ @@ -634,7 +634,8 @@ H5FD_pl_close(hid_t driver_id, herr_t (*free_func)(void *), void *pl) H5MM_xfree(pl); /* Decrement reference count for driver */ - H5I_dec_ref(driver_id); + if(H5I_dec_ref(driver_id)<0) + HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement reference count for driver") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1472,7 +1473,7 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) /* Check args */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer") - if (type<0 || 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) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "zero-size request") @@ -1533,7 +1534,7 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) /* check args */ assert(file); assert(file->cls); - assert(type >= 0 && type < H5FD_MEM_NTYPES); + assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); #ifdef H5_HAVE_FPHDF5 @@ -1614,7 +1615,7 @@ H5FD_alloc_from_free_list(H5FD_t *file, H5FD_mem_t type, FUNC_ENTER_NOAPI(H5FD_alloc_from_free_list, HADDR_UNDEF) assert(file); - assert(type >= 0 && type < H5FD_MEM_NTYPES); + assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); /* @@ -1636,7 +1637,7 @@ H5FD_alloc_from_free_list(H5FD_t *file, H5FD_mem_t type, * 2. block address is aligned with smallest size > requested size; * 3. block address is not aligned with smallest size >= requested size. */ - if (mapped_type >= 0 && (file->maxsize == 0 || size <= file->maxsize)) { + if (mapped_type >= H5FD_MEM_DEFAULT && (file->maxsize == 0 || size <= file->maxsize)) { H5FD_free_t *prev = NULL, *best = NULL; H5FD_free_t *cur = file->fl[mapped_type]; int found_aligned = 0; @@ -1792,7 +1793,7 @@ H5FD_alloc_from_free_list(H5FD_t *file, H5FD_mem_t type, if((tmp = H5FL_MALLOC(H5FD_free_t))==NULL) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "free block allocation failed") - if ((tmp->size = (best->size - (head + size)))) { + if ((tmp->size = (best->size - (head + size)))!=0) { tmp->addr = best->addr + (head + size); tmp->next = best->next; best->next = tmp; @@ -1836,7 +1837,7 @@ H5FD_alloc_metadata(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) /* check args */ assert(file); - assert(type >= 0 && type < H5FD_MEM_NTYPES); + assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); /* @@ -1951,7 +1952,7 @@ H5FD_alloc_raw(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) /* check args */ assert(file); - assert(type >= 0 && type < H5FD_MEM_NTYPES); + assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); /* @@ -2068,7 +2069,7 @@ H5FD_real_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) /* check args */ assert(file); assert(file->cls); - assert(type >= 0 && type < H5FD_MEM_NTYPES); + assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); /* @@ -2114,7 +2115,7 @@ H5FD_update_eoa(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) /* check args */ assert(file); assert(file->cls); - assert(type >= 0 && type < H5FD_MEM_NTYPES); + assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); assert(size > 0); eoa = file->cls->get_eoa(file); @@ -2206,7 +2207,7 @@ H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t siz /* Check args */ if (!file || !file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") - if (type<0 || 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) dxpl_id= H5P_DATASET_XFER_DEFAULT; @@ -2254,7 +2255,7 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t si /* Check args */ assert(file); assert(file->cls); - assert(type >= 0 && type < H5FD_MEM_NTYPES); + assert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); #ifdef H5_HAVE_FPHDF5 /* @@ -2296,7 +2297,7 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t si * without ever telling the driver that it was freed. Otherwise let the * driver deallocate the memory. */ - if (mapped_type>=0) { + if (mapped_type>=H5FD_MEM_DEFAULT) { H5FD_free_t *last; /* Last merged node */ H5FD_free_t *last_prev=NULL;/* Pointer to node before merged node */ H5FD_free_t *curr; /* Current free block being inspected */ @@ -3751,7 +3752,7 @@ done: *------------------------------------------------------------------------- */ hssize_t -H5FD_get_freespace(H5FD_t *file) +H5FD_get_freespace(const H5FD_t *file) { H5FD_free_t *free_node; /* Pointer to node on free list */ H5FD_mem_t type; /* Type of memory */ @@ -3771,7 +3772,7 @@ H5FD_get_freespace(H5FD_t *file) /* Iterate through the free list, accumulating the amount of free space for this type */ free_node = file->fl[type]; while(free_node) { - ret_value+=free_node->size; + ret_value+=(hssize_t)free_node->size; free_node=free_node->next; } /* end while */ } /* end for */ |