From 1c1bf5dcd37a9370f555f4ad2e4a001f39e1a1dd Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Aug 2003 13:53:49 -0500 Subject: [svn-r7299] Purpose: Code refactoring Description: Chase new error API usage by adding error class to calls to H5Epush(). Platforms tested: h5committested --- src/H5FDmulti.c | 68 ++++++++++++++++++++++++++++----------------------------- src/H5FDstdio.c | 52 +++++++++++++++++++++---------------------- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 9492d7c..4d8849a 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -421,7 +421,7 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, /* 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_PLIST, H5E_BADVALUE, "not an access list", -1); + 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_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1); if (H5FD_MEM_DEFAULT==mmt) mmt = mt; /* @@ -461,11 +461,11 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, * access property lists. */ if (H5P_DEFAULT!=memb_fapl[mmt] && TRUE!=H5Pisa_class(memb_fapl[mmt], H5P_FILE_ACCESS)) - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1); + 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_INTERNAL, H5E_BADVALUE, "file resource type not set", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1); } /* @@ -524,11 +524,11 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, if(H5I_GENPROP_LST != H5Iget_type(fapl_id) || TRUE != H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) - H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not an access list", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not an access list", -1); if (H5FD_MULTI!=H5Pget_driver(fapl_id)) - H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", -1); if (NULL==(fa=H5Pget_driver_info(fapl_id))) - H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1); if (memb_map) { memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t)); @@ -596,12 +596,12 @@ H5Pset_dxpl_multi(hid_t dxpl_id, const hid_t *memb_dxpl) /* Check arguments */ if (TRUE!=H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) - H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a data transfer property list", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a data transfer property list", -1); if (!memb_dxpl) - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid pointer", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "invalid pointer", -1); for (mt=H5FD_MEM_DEFAULT; mtfa.memb_map, mt) { @@ -1034,7 +1034,7 @@ H5FD_multi_fapl_copy(const void *_old_fa) if (new_fa->memb_name[mt]) free(new_fa->memb_name[mt]); } free(new_fa); - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL); } return new_fa; } @@ -1116,7 +1116,7 @@ H5FD_multi_dxpl_copy(const void *_old_dx) for (mt=H5FD_MEM_DEFAULT; mtmemb_dxpl[mt]); free(new_dx); - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL); } return new_dx; } @@ -1188,16 +1188,16 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, /* Check arguments */ if (!name || !*name) - H5Epush_ret(func, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL); if (0==maxaddr || HADDR_UNDEF==maxaddr) - H5Epush_ret(func, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL); + 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. */ if (NULL==(file=calloc(1, sizeof(H5FD_multi_t)))) - H5Epush_ret(func, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL); + 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); H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE); @@ -1226,9 +1226,9 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, /* Compute derived properties and open member files */ if (compute_next(file)<0) - H5Epush_goto(func, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", error); + H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", error); if (open_members(file)<0) - H5Epush_goto(func, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", error); + H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", error); /* We must have opened at least the superblock file */ if (H5FD_MEM_DEFAULT==(m=file->fa.memb_map[H5FD_MEM_SUPER])) { @@ -1301,7 +1301,7 @@ H5FD_multi_close(H5FD_t *_file) } } END_MEMBERS; if (nerrors) - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1); /* Clean up other stuff */ ALL_MEMBERS(mt) { @@ -1472,7 +1472,7 @@ H5FD_multi_set_eoa(H5FD_t *_file, haddr_t eoa) status = H5FDset_eoa(file->memb[mmt], eoa-file->fa.memb_addr[mmt]); } H5E_END_TRY; if (status<0) - H5Epush_ret(func, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1); } /* Save new eoa for return later */ @@ -1516,7 +1516,7 @@ H5FD_multi_get_eof(H5FD_t *_file) tmp = H5FDget_eof(file->memb[mt]); } H5E_END_TRY; if (HADDR_UNDEF==tmp) - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF); if (tmp>0) tmp += file->fa.memb_addr[mt]; } else if (file->fa.relax) { @@ -1528,7 +1528,7 @@ H5FD_multi_get_eof(H5FD_t *_file) assert(HADDR_UNDEF!=tmp); } else { - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF); } if (tmp>eof) eof = tmp; @@ -1561,9 +1561,9 @@ H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) /* Get data type for multi driver */ if(H5Pget_multi_type(fapl, &type) < 0) - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "can't get data type for multi driver", -1); + 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_INTERNAL, H5E_BADVALUE, "data type is out of range", -1); + 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; @@ -1599,7 +1599,7 @@ H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) if (H5FD_MEM_DEFAULT==mmt) mmt = type; if (HADDR_UNDEF==(addr=H5FDalloc(file->memb[mmt], type, dxpl_id, size))) { - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF); } addr += file->fa.memb_addr[mmt]; if (addr+size>file->eoa) file->eoa = addr+size; @@ -1820,7 +1820,7 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) } } if (nerrors) - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1); return 0; } @@ -1924,7 +1924,7 @@ open_members(H5FD_multi_t *file) } } END_MEMBERS; if (nerrors) - H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1); return 0; } diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index b1062e0..77a8720 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -258,7 +258,7 @@ H5Pset_fapl_stdio(hid_t fapl_id) H5Eclear(H5E_DEFAULT); if(0 == H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) - H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1); + 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); } @@ -317,21 +317,21 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, /* Check arguments */ if (!name || !*name) - H5Epush_ret(func, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL); if (0==maxaddr || HADDR_UNDEF==maxaddr) - H5Epush_ret(func, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL); if (ADDR_OVERFLOW(maxaddr)) - H5Epush_ret(func, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL); if (access(name, F_OK) < 0) { if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR)) { f = fopen(name, "wb+"); write_access=1; /* Note the write access */ } else { - H5Epush_ret(func, H5E_IO, H5E_CANTOPENFILE, "file doesn't exist and CREAT wasn't specified", NULL); + 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_CREAT) && (flags & H5F_ACC_EXCL)) { - H5Epush_ret(func, H5E_IO, H5E_FILEEXISTS, "file exists but CREAT and EXCL were specified", NULL); + 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 = fopen(name, "wb+"); @@ -342,11 +342,11 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, f = fopen(name, "rb"); } if (!f) - H5Epush_ret(func, H5E_IO, H5E_CANTOPENFILE, "fopen failed", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, "fopen failed", NULL); /* Build the return value */ if (NULL==(file = calloc(1,sizeof(H5FD_stdio_t)))) - H5Epush_ret(func, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL); file->fp = f; file->op = H5FD_STDIO_OP_SEEK; file->pos = HADDR_UNDEF; @@ -404,7 +404,7 @@ H5FD_stdio_close(H5FD_t *_file) H5Eclear(H5E_DEFAULT); if (fclose(file->fp) < 0) - H5Epush_ret(func, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1); free(file); @@ -628,7 +628,7 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) *file_handle = &(file->fp); if(*file_handle==NULL) - H5Epush_ret(func, H5E_IO, H5E_WRITEERROR, "get handle failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "get handle failed", -1); return(0); } @@ -674,11 +674,11 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz /* Check for overflow */ if (HADDR_UNDEF==addr) - H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); + H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); if (REGION_OVERFLOW(addr, size)) - H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); + H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); if (addr+size>file->eoa) - H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); + H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); /* Check easy cases */ if (0 == size) @@ -698,14 +698,14 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz if (fsetpos(file->fp,&tempos)!=0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fsetpos failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fsetpos failed", -1); } #else if (fseek(file->fp, (long)addr, SEEK_SET) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); } #endif file->pos = addr; @@ -729,7 +729,7 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz if (n <= 0 && ferror(file->fp)) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_IO, H5E_READERROR, "fread failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_READERROR, "fread failed", -1); } else if (n < size) { memset((unsigned char *)buf + n, 0, (size - n)); } @@ -786,11 +786,11 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, /* Check for overflow conditions */ if (HADDR_UNDEF==addr) - H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); + H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); if (REGION_OVERFLOW(addr, size)) - H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); + H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); if (addr+size>file->eoa) - H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); + H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); /* * Seek to the correct file position. @@ -803,13 +803,13 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, if (fsetpos(file->fp,&tempos) != 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fsetpos failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fsetpos failed", -1); } #else if (fseek(file->fp, (long)addr, SEEK_SET) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); } #endif /* WIN32 */ file->pos = addr; @@ -823,7 +823,7 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, if (size != fwrite(buf, 1, size, file->fp)) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1); } /* @@ -900,10 +900,10 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) li.QuadPart = file->eoa; SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle)==0) - H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "unable to extend file properly", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to extend file properly", -1); #else /* WIN32 */ if (-1==file_truncate(fd, (file_offset_t)file->eoa)) - H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "unable to extend file properly", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to extend file properly", -1); #endif /* WIN32 */ /* Update the eof value */ file->eof = file->eoa; @@ -918,13 +918,13 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) */ if(!closing) { if (fflush(file->fp) < 0) - H5Epush_ret(func, H5E_IO, H5E_WRITEERROR, "fflush failed", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1); } /* end if */ } /* end if */ else { /* Double-check for problems */ if (file->eoa>file->eof) - H5Epush_ret(func, H5E_IO, H5E_TRUNCATED, "eoa>eof!", -1); + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_TRUNCATED, "eoa>eof!", -1); } /* end else */ return(0); -- cgit v0.12