Skip to content

Commit

Permalink
Commit format changes from running clang-format with clang version 10…
Browse files Browse the repository at this point in the history
….0.1.
  • Loading branch information
lrknox committed Feb 26, 2021
1 parent 29dc84a commit 794d76f
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 136 deletions.
2 changes: 1 addition & 1 deletion src/H5Epublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g;
do { \
H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \
return (ret); \
} while(0)
} while (0)

/* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in
* And goto a label after pushing error onto stack.
Expand Down
178 changes: 95 additions & 83 deletions src/H5FDmulti.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,12 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_f

/* 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; mt = (H5FD_mem_t)(mt + 1))
_memb_map[mt] = H5FD_MEM_DEFAULT;
memb_map = _memb_map;
}
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; mt = (H5FD_mem_t)(mt + 1))
_memb_map[mt] = H5FD_MEM_DEFAULT;
memb_map = _memb_map;
}
if (!memb_fapl) {
for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1))
_memb_fapl[mt] = H5Pcreate(H5P_FILE_ACCESS);
Expand All @@ -465,8 +465,9 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_f
/* 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;
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
Expand All @@ -475,9 +476,9 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_f
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);
}

/*
Expand Down Expand Up @@ -529,13 +530,14 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl
H5Eclear2(H5E_DEFAULT);

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_BADTYPE, "not an access list",
-1); if (H5FD_MULTI != H5Pget_driver(fapl_id))
H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver",
-1); if (NULL == (fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id)))
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));
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_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", -1);
if (NULL == (fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id)))
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));
if (memb_fapl) {
for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) {
if (fa->memb_fapl[mt] >= 0)
Expand Down Expand Up @@ -674,8 +676,8 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out
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;
/* 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;
Expand Down Expand Up @@ -732,13 +734,13 @@ 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;
}
/* Set default values */
ALL_MEMBERS(mt)
{
memb_addr[mt] = HADDR_UNDEF;
memb_eoa[mt] = HADDR_UNDEF;
memb_name[mt] = NULL;
}
END_MEMBERS;

/*
Expand All @@ -762,8 +764,8 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
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 */
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++;
Expand Down Expand Up @@ -820,21 +822,21 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
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];
}
/* 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;
Expand Down Expand Up @@ -957,8 +959,9 @@ H5FD_multi_fapl_free(void *_fa)
{
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]);
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);
Expand Down Expand Up @@ -996,24 +999,23 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr

/* 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);
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)
}
/*
* 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)
Expand Down Expand Up @@ -1112,14 +1114,14 @@ H5FD_multi_close(H5FD_t *_file)
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]);
}
/* 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);
Expand Down Expand Up @@ -1277,7 +1279,9 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type)

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];
HADDR_UNDEF);
if (memb_eoa > 0)
memb_eoa += file->fa.memb_addr[mt];
}
else if (file->fa.relax) {
/*
Expand Down Expand Up @@ -1308,7 +1312,9 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type)

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];
HADDR_UNDEF);
if (eoa > 0)
eoa += file->fa.memb_addr[mmt];
}
else if (file->fa.relax) {
/*
Expand Down Expand Up @@ -1384,7 +1390,7 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa)
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() */

/*-------------------------------------------------------------------------
Expand Down Expand Up @@ -1426,7 +1432,9 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type)

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];
HADDR_UNDEF);
if (tmp_eof > 0)
tmp_eof += file->fa.memb_addr[mt];
}
else if (file->fa.relax) {
/*
Expand Down Expand Up @@ -1457,7 +1465,9 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type)

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];
HADDR_UNDEF);
if (eof > 0)
eof += file->fa.memb_addr[mmt];
}
else if (file->fa.relax) {
/*
Expand Down Expand Up @@ -1496,9 +1506,10 @@ 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_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];
-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;

Expand Down Expand Up @@ -1543,7 +1554,7 @@ H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t 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 ) {
Expand Down Expand Up @@ -1758,7 +1769,7 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing)
if (nerrors)
H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1);

return 0;
return 0;
}

/*-------------------------------------------------------------------------
Expand Down Expand Up @@ -1799,7 +1810,7 @@ H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing)
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() */

/*-------------------------------------------------------------------------
Expand Down Expand Up @@ -1860,7 +1871,8 @@ H5FD_multi_lock(H5FD_t *_file, hbool_t rw)
} /* end if */

if (nerrors)
H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTLOCKFILE, "error locking member files", -1); return 0;
H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTLOCKFILE, "error locking member files", -1);
return 0;

} /* H5FD_multi_lock() */

Expand Down Expand Up @@ -1899,7 +1911,7 @@ H5FD_multi_unlock(H5FD_t *_file)
if (nerrors)
H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTUNLOCKFILE, "error unlocking member files", -1);

return 0;
return 0;
} /* H5FD_multi_unlock() */

/*-------------------------------------------------------------------------
Expand Down Expand Up @@ -1998,7 +2010,7 @@ open_members(H5FD_multi_t *file)
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")

Expand Down
Loading

0 comments on commit 794d76f

Please sign in to comment.