1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-22 20:35:44 +01:00

cppcheck fixes

This commit is contained in:
Anthony Scemama 2022-01-07 11:21:12 +01:00
parent dbb6f78397
commit 3f4b8e2c7e

View File

@ -1,4 +1,5 @@
#+TITLE: Front end API
break;
#+PROPERTY: comments org
#+SETUPFILE: ../../docs/theme.setup
# -*- mode: org -*-
@ -1723,9 +1724,12 @@ trexio_write_$group_dset$_64 (trexio_t* const file, const $group_dset_dtype_doub
{
if (file == NULL) return TREXIO_INVALID_ARG_1;
assert(file->back_end < TREXIO_INVALID_BACK_END);
if ($group_dset$ == NULL) return TREXIO_INVALID_ARG_2;
if (trexio_has_$group_dset$(file) == TREXIO_SUCCESS) return TREXIO_DSET_ALREADY_EXISTS;
trexio_exit_code rc;
int64_t $group_dset_dim$ = 0;
@ -1737,8 +1741,6 @@ trexio_write_$group_dset$_64 (trexio_t* const file, const $group_dset_dtype_doub
uint32_t rank = $group_dset_rank$;
uint64_t dims[$group_dset_rank$] = {$group_dset_dim_list$};
$group_dset_dtype_double$* $group_dset$_p = ($group_dset_dtype_double$*) $group_dset$;
if ($is_index$) {
/* Handle index type : is_index = $is_index$ */
uint64_t dim_size = 1;
@ -1746,41 +1748,66 @@ trexio_write_$group_dset$_64 (trexio_t* const file, const $group_dset_dtype_doub
dim_size *= dims[i];
}
$group_dset$_p = CALLOC(dim_size, $group_dset_dtype_double$);
$group_dset_dtype_double$* $group_dset$_p =
CALLOC(dim_size, $group_dset_dtype_double$);
if ($group_dset$_p == NULL) return TREXIO_ALLOCATION_FAILED;
for (uint64_t i=0; i<dim_size; ++i){
$group_dset$_p[i] -= ($group_dset_dtype_double$) 1;
}
}
assert(file->back_end < TREXIO_INVALID_BACK_END);
rc = TREXIO_FAILURE;
switch (file->back_end) {
rc = TREXIO_FAILURE;
switch (file->back_end) {
case TREXIO_TEXT:
rc = trexio_text_write_$group_dset$(file, $group_dset$_p, rank, dims);
break;
case TREXIO_HDF5:
#ifdef HAVE_HDF5
rc = trexio_hdf5_write_$group_dset$(file, $group_dset$_p, rank, dims);
break;
#else
rc = TREXIO_BACK_END_MISSING;
break;
#endif
/*
case TREXIO_JSON:
rc = trexio_json_write_$group_dset$(file, $group_dset$_p, rank, dims);
case TREXIO_TEXT:
rc = trexio_text_write_$group_dset$(file,
(const $group_dset_dtype_double$*) $group_dset$_p,
rank, dims);
break;
,*/
}
/* Handle index type */
if ($is_index$) {
FREE($group_dset$_p);
case TREXIO_HDF5:
#ifdef HAVE_HDF5
rc = trexio_hdf5_write_$group_dset$(file,
(const $group_dset_dtype_double$*) $group_dset$_p,
rank, dims);
break;
#else
rc = TREXIO_BACK_END_MISSING;
break;
#endif
/*
case TREXIO_JSON:
rc = trexio_json_write_$group_dset$(file, $group_dset$_p, rank, dims);
break;
,*/
FREE($group_dset$_p);
}
} else {
rc = TREXIO_FAILURE;
switch (file->back_end) {
case TREXIO_TEXT:
rc = trexio_text_write_$group_dset$(file, $group_dset$, rank, dims);
break;
case TREXIO_HDF5:
#ifdef HAVE_HDF5
rc = trexio_hdf5_write_$group_dset$(file, $group_dset$, rank, dims);
break;
#else
rc = TREXIO_BACK_END_MISSING;
break;
#endif
/*
case TREXIO_JSON:
rc = trexio_json_write_$group_dset$(file, $group_dset$, rank, dims);
break;
,*/
}
}
return rc;