diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-08-08 16:52:55 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-08-08 16:52:55 (GMT) |
commit | d8397a6f426227d09d20e647ce8b12b8c6295b2d (patch) | |
tree | 2943fbfd2bfb66cf167eb642835fdb4deb3afd3c /src/H5Omtime.c | |
parent | 573307786a1f5f7ce597e5191ea08c3bbd95b66c (diff) | |
download | hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.zip hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.tar.gz hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.tar.bz2 |
[svn-r5842] Purpose:
Code cleanup
Description:
Change most (all?) HRETURN_ERROR macros to HGOTO_ERROR macros, along with
HRETURN macros to HGOTO_DONE macros. This unifies the error return path
from functions and reduces the size of the library by up to 10% on some
platforms.
Additionally, I improved a lot of the error cleanup code in many routines.
Platforms tested:
FreeBSD 4.6 (sleipnir) serial & parallel and IRIX64 6.5 (modi4) serial &
parallel.
Diffstat (limited to 'src/H5Omtime.c')
-rw-r--r-- | src/H5Omtime.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/src/H5Omtime.c b/src/H5Omtime.c index a424f27..ff5020c 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -78,6 +78,7 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p, int i; struct tm tm; static int ncalls=0; + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_mtime_decode, NULL); @@ -91,10 +92,8 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p, /* decode */ for (i=0; i<14; i++) { - if (!HDisdigit(p[i])) { - HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, - "badly formatted modification time message"); - } + if (!HDisdigit(p[i])) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message"); } /* @@ -112,10 +111,8 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p, 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=HDmktime(&tm))) { - HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, - "badly formatted modification time message"); - } + if ((time_t)-1==(the_time=HDmktime(&tm))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message"); #if defined(H5_HAVE_TM_GMTOFF) /* FreeBSD, OSF 4.0 */ @@ -130,20 +127,16 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p, /* Irix5.3 */ { struct timezone tz; - if (HDBSDgettimeofday(NULL, &tz)<0) { - HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, - "unable to obtain local timezone information"); - } + if (HDBSDgettimeofday(NULL, &tz)<0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information"); the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0); } #elif defined(H5_HAVE_GETTIMEOFDAY) && defined(H5_HAVE_STRUCT_TIMEZONE) { struct timezone tz; - if (HDgettimeofday(NULL, &tz) < 0) { - HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, - "unable to obtain local timezone information"); - } + if (HDgettimeofday(NULL, &tz) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information"); the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0); } @@ -169,18 +162,19 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p, */ /* Irix64 */ - HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, - "unable to obtain local timezone information"); + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information"); #endif /* The return value */ - if (NULL==(mesg = H5FL_ALLOC(time_t,1))) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } + if (NULL==(mesg = H5FL_ALLOC(time_t,1))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); *mesg = the_time; - FUNC_LEAVE((void*)mesg); + /* Set return value */ + ret_value=mesg; + +done: + FUNC_LEAVE(ret_value); } @@ -245,21 +239,25 @@ 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; /* Return value */ FUNC_ENTER_NOAPI(H5O_mtime_copy, NULL); /* check args */ assert(mesg); - if (!dest && NULL==(dest = H5FL_ALLOC(time_t,0))) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } + if (!dest && NULL==(dest = H5FL_ALLOC(time_t,0))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *mesg; - FUNC_LEAVE((void *) dest); + /* Set return value */ + ret_value=dest; + +done: + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5O_mtime_size @@ -355,7 +353,6 @@ H5O_mtime_debug(H5F_t UNUSED *f, const void *_mesg, FILE *stream, /* debug */ tm = HDlocaltime(mesg); - HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, |