summaryrefslogtreecommitdiffstats
path: root/src/H5FDdirect.c
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2020-01-29 16:47:30 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2020-01-29 16:47:30 (GMT)
commita5f236e83bdd29e660a55c5577a69a3809605cda (patch)
tree0da09d16f60e1454a4a5f31dd36398737a16f68a /src/H5FDdirect.c
parentf554a4fb5465cfd539ad7bd0310adddf88db6708 (diff)
downloadhdf5-a5f236e83bdd29e660a55c5577a69a3809605cda.zip
hdf5-a5f236e83bdd29e660a55c5577a69a3809605cda.tar.gz
hdf5-a5f236e83bdd29e660a55c5577a69a3809605cda.tar.bz2
Reduce casts of HDcalloc()/HDmalloc() that -Wc++-compat required.
Reduce gratuitous casts---e.g., (size_t)1. Use the right format string for a pointer. In the H5C sanity checks, change a "size increase" variable from ssize_t (too narrow) to int64_t (wide enough). Parenthesize every appearance of `storage` in the macro `H5D_CHUNK_STORAGE_INDEX_CHK(storage)` so that you can pass in an expression like &sc and it works properly. Disallow re-assignment of the `dset` parameter to H5D__chunk_init() because it helped assure me that it's safe to replace the repeating expression `&dset->shared->layout.storage.u.chunk` with `sc` throughout. Replace lengthy expressions such as `&dset->shared->layout.storage.u.chunk` with `sc` throughout several functions in H5Dchunk.c ISTR that the compiler warned that `sc` was declared but unused in a couple of functions, and then I found that `sc` could be used in many places. Maybe the disused `sc` appeared because a bunch of code was copied and pasted, I don't know. Anyway, it's a lot tighter code now that I use `sc`. In H5D__chunk_update_old_edge_chunks() and H5D__chunk_delete() I actually expand `sc` and another temporary variable, `pline`, because they're used only in !defined(NDEBUG) code. This squashes unused-variable warnings in the defined(NDEBUG) configuration. Don't drop the `volatile` qualification with a cast in tools/src/h5import/h5import.c.
Diffstat (limited to 'src/H5FDdirect.c')
-rw-r--r--src/H5FDdirect.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index 33a0ef4..ce5e081 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -459,8 +459,8 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
#endif
h5_stat_t sb;
H5P_genplist_t *plist; /* Property list */
- int *buf1, *buf2;
- H5FD_t *ret_value;
+ void *buf1, *buf2;
+ H5FD_t *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
@@ -525,13 +525,13 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
/* NOTE: Use HDmalloc and HDfree here to ensure compatibility with
* HDposix_memalign.
*/
- buf1 = (int *)HDmalloc(sizeof(int));
+ buf1 = HDmalloc(sizeof(int));
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, (void*)buf1, sizeof(int))<0) {
- if(HDwrite(file->fd, (void*)buf2, file->fa.fbsize)<0)
+ 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;
@@ -540,8 +540,8 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
HDftruncate(file->fd, (HDoff_t)0);
}
} else {
- if(HDread(file->fd, (void*)buf1, sizeof(int))<0) {
- if(HDread(file->fd, (void*)buf2, file->fa.fbsize)<0)
+ 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;
@@ -549,7 +549,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
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, (void *)buf1, sizeof(int))<0)
+ if(HDwrite(file->fd, buf1, sizeof(int))<0)
file->fa.must_align = TRUE;
else
file->fa.must_align = FALSE;