Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many fixes to various compiler warnings #3124

Merged
merged 9 commits into from
Jun 19, 2023
13 changes: 7 additions & 6 deletions c++/examples/h5tutr_extend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ main(void)
// ---------------------------------------

int rdata[10][3];
int i, j, rank, rank_chunk;
int i, j, rank;
hsize_t chunk_dimsr[2], dimsr[2];

// Open the file and dataset.
Expand All @@ -111,12 +111,13 @@ main(void)
prop = dataset->getCreatePlist();

// Get information to obtain memory dataspace.
rank = filespace->getSimpleExtentNdims();
herr_t status_n = filespace->getSimpleExtentDims(dimsr);
rank = filespace->getSimpleExtentNdims();
(void)filespace->getSimpleExtentDims(dimsr);

if (H5D_CHUNKED == prop.getLayout())
rank_chunk = prop.getChunk(rank, chunk_dimsr);
cout << "rank chunk = " << rank_chunk << endl;
if (H5D_CHUNKED == prop.getLayout()) {
int rank_chunk = prop.getChunk(rank, chunk_dimsr);
cout << "rank chunk = " << rank_chunk << endl;
}

memspace = new DataSpace(rank, dimsr, NULL);
dataset->read(rdata, PredType::NATIVE_INT, *memspace, *filespace);
Expand Down
4 changes: 2 additions & 2 deletions c++/examples/readdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ main(void)
* Get order of datatype and print message if it's a little endian.
*/
H5std_string order_string;
H5T_order_t order = intype.getOrder(order_string);
(void)intype.getOrder(order_string);
cout << order_string << endl;

/*
Expand All @@ -109,7 +109,7 @@ main(void)
* display them.
*/
hsize_t dims_out[2];
int ndims = dataspace.getSimpleExtentDims(dims_out, NULL);
(void)dataspace.getSimpleExtentDims(dims_out, NULL);
cout << "rank " << rank << ", dimensions " << (unsigned long)(dims_out[0]) << " x "
<< (unsigned long)(dims_out[1]) << endl;

Expand Down
43 changes: 28 additions & 15 deletions c++/test/ttypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ using namespace H5;
/* #include "H5Tpkg.h"
*/

const char *FILENAME[] = {"dtypes1.h5", "dtypes2.h5", "dtypes3.h5", "dtypes4.h5",
"encode_decode.h5", "h5_type_operators.h5", NULL};
static const char *FILENAME[] = {"dtypes1.h5", "dtypes2.h5", "dtypes3.h5", "dtypes4.h5",
"encode_decode.h5", "h5_type_operators.h5", NULL};

typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t;

Expand Down Expand Up @@ -462,11 +462,16 @@ test_query()
// Create a enumerate datatype
EnumType tid2(sizeof(short));

tid2.insert("RED", (enum_val = 0, &enum_val));
tid2.insert("GREEN", (enum_val = 1, &enum_val));
tid2.insert("BLUE", (enum_val = 2, &enum_val));
tid2.insert("ORANGE", (enum_val = 3, &enum_val));
tid2.insert("YELLOW", (enum_val = 4, &enum_val));
enum_val = 0;
tid2.insert("RED", &enum_val);
enum_val = 1;
tid2.insert("GREEN", &enum_val);
enum_val = 2;
tid2.insert("BLUE", &enum_val);
enum_val = 3;
tid2.insert("ORANGE", &enum_val);
enum_val = 4;
tid2.insert("YELLOW", &enum_val);

// Query member number and member index by name, for compound type
int nmembs = tid1.getNmembers();
Expand Down Expand Up @@ -859,11 +864,16 @@ test_encode_decode()
// Create a enumerate datatype
EnumType enumtyp(sizeof(short));

enumtyp.insert("RED", (enum_val = 0, &enum_val));
enumtyp.insert("GREEN", (enum_val = 1, &enum_val));
enumtyp.insert("BLUE", (enum_val = 2, &enum_val));
enumtyp.insert("ORANGE", (enum_val = 3, &enum_val));
enumtyp.insert("YELLOW", (enum_val = 4, &enum_val));
enum_val = 0;
enumtyp.insert("RED", &enum_val);
enum_val = 1;
enumtyp.insert("GREEN", &enum_val);
enum_val = 2;
enumtyp.insert("BLUE", &enum_val);
enum_val = 3;
enumtyp.insert("ORANGE", &enum_val);
enum_val = 4;
enumtyp.insert("YELLOW", &enum_val);

// Encode compound type in a buffer
enumtyp.encode();
Expand Down Expand Up @@ -1060,9 +1070,12 @@ test_operators()
// Create an enumerate datatype
EnumType enumtyp(sizeof(short));

enumtyp.insert("RED", (enum_val = 0, &enum_val));
enumtyp.insert("GREEN", (enum_val = 1, &enum_val));
enumtyp.insert("BLUE", (enum_val = 2, &enum_val));
enum_val = 0;
enumtyp.insert("RED", &enum_val);
enum_val = 1;
enumtyp.insert("GREEN", &enum_val);
enum_val = 2;
enumtyp.insert("BLUE", &enum_val);

// Verify that operator== and operator!= work properly
verify_val(cmptyp == enumtyp, false, "DataType::operator==", __LINE__, __FILE__);
Expand Down
2 changes: 1 addition & 1 deletion config/cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ if (HDF5_BUILD_FORTRAN)
#define C_LDBL_DIG DECIMAL_DIG\n\
#else\n\
#define C_LDBL_DIG LDBL_DIG\n\
#endif\n\nint main() {\nprintf(\"\\%d\\\;\\%d\\\;\", C_LDBL_DIG, C_FLT128_DIG)\\\;\n\nreturn 0\\\;\n}\n
#endif\n\nint main(void) {\nprintf(\"\\%d\\\;\\%d\\\;\", C_LDBL_DIG, C_FLT128_DIG)\\\;\n\nreturn 0\\\;\n}\n
"
)

Expand Down
4 changes: 2 additions & 2 deletions config/cmake/HDFTests.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


/* A simple test program to see if a function "works" */
#define SIMPLE_TEST(x) int main(){ x; return 0; }
#define SIMPLE_TEST(x) int main(void){ x; return 0; }


#ifdef HAVE_ATTRIBUTE
Expand Down Expand Up @@ -93,7 +93,7 @@ int main ()

#include <sys/types.h>

int main()
int main(void)
{
off64_t n = 0;
return (int)n;
Expand Down
2 changes: 1 addition & 1 deletion doxygen/examples/H5Fclose.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "hdf5.h"

int
main()
main(void)
{
hid_t file;
if ((file = H5Fcreate("foo.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
Expand Down
2 changes: 1 addition & 1 deletion doxygen/examples/H5Fcreate.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "hdf5.h"

int
main()
main(void)
{
hid_t file;
if ((file = H5Fcreate("foo.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
Expand Down
2 changes: 1 addition & 1 deletion doxygen/examples/hello_hdf5.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "hdf5.h"

int
main()
main(void)
{
herr_t retval;
unsigned majnum, minnum, relnum;
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_cmprss.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define DIM1 20

int
main()
main(void)
{

hid_t file_id, dataset_id, dataspace_id; /* identifiers */
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_crtatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define FILE "dset.h5"

int
main()
main(void)
{

hid_t file_id, dataset_id, attribute_id, dataspace_id; /* identifiers */
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_crtdat.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define FILE "dset.h5"

int
main()
main(void)
{

hid_t file_id, dataset_id, dataspace_id; /* identifiers */
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_crtgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define FILE "group.h5"

int
main()
main(void)
{

hid_t file_id, group_id; /* identifiers */
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_crtgrpar.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define FILE "groups.h5"

int
main()
main(void)
{

hid_t file_id, group1_id, group2_id, group3_id; /* identifiers */
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_crtgrpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define FILE "groups.h5"

int
main()
main(void)
{

hid_t file_id, group_id, dataset_id, dataspace_id; /* identifiers */
Expand Down
6 changes: 3 additions & 3 deletions examples/h5_extlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ UD_hard_create(const char *link_name, hid_t loc_group, const void *udata, size_t
goto done;
}

token = *((H5O_token_t *)udata);
token = *((const H5O_token_t *)udata);

//! [H5Oopen_by_token_snip]

Expand Down Expand Up @@ -459,7 +459,7 @@ UD_hard_delete(const char *link_name, hid_t loc_group, const void *udata, size_t
goto done;
}

token = *((H5O_token_t *)udata);
token = *((const H5O_token_t *)udata);

/* Open the object this link points to */
target_obj = H5Oopen_by_token(loc_group, token);
Expand Down Expand Up @@ -498,7 +498,7 @@ UD_hard_traverse(const char *link_name, hid_t cur_group, const void *udata, size
if (udata_size != sizeof(H5O_token_t))
return H5I_INVALID_HID;

token = *((H5O_token_t *)udata);
token = *((const H5O_token_t *)udata);

/* Open the object by token. If H5Oopen_by_token fails, ret_value will
* be negative to indicate that the traversal function failed.
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_rdwt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define FILE "dset.h5"

int
main()
main(void)
{

hid_t file_id, dataset_id; /* identifiers */
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_vds-exc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ main(void)
kdims[3] = {KDIM0, KDIM1, KDIM2}, kdims_max[3] = {H5S_UNLIMITED, KDIM1, KDIM2},
ndims[3] = {NDIM0, NDIM1, NDIM2}, ndims_max[3] = {H5S_UNLIMITED, NDIM1, NDIM2},
start[3], /* Hyperslab parameters */
stride[3], count[3], block[3];
count[3], block[3];
hsize_t start_out[3], stride_out[3], count_out[3], block_out[3];
int k = 2;
int n = 3;
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_vds-exclim.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ main(void)
herr_t status;
hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, kdims[3] = {KDIM0, KDIM1, KDIM2},
ndims[3] = {NDIM0, NDIM1, NDIM2}, start[3], /* Hyperslab parameters */
stride[3], count[3], block[3];
count[3], block[3];
hsize_t start_out[3], stride_out[3], count_out[3], block_out[3];
int k = 2;
int n = 3;
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_vds.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ main(void)
hsize_t vdsdims[2] = {VDSDIM0, VDSDIM1}, /* Virtual datasets dimension */
dims[1] = {DIM0}, /* Source datasets dimensions */
start[2], /* Hyperslab parameters */
stride[2], count[2], block[2];
count[2], block[2];
hsize_t start_out[2], stride_out[2], count_out[2], block_out[2];
int wdata[DIM0], /* Write buffer for source dataset */
rdata[VDSDIM0][VDSDIM1], /* Read buffer for virtual dataset */
Expand Down
2 changes: 1 addition & 1 deletion hl/examples/ex_image1.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define WIDTH 400
#define HEIGHT 200
#define PAL_ENTRIES 9
unsigned char buf[WIDTH * HEIGHT];
static unsigned char buf[WIDTH * HEIGHT];

int
main(void)
Expand Down
4 changes: 2 additions & 2 deletions hl/examples/ex_image2.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#define PAL_NAME "palette"
#define PAL_ENTRIES 256

static int read_data(const char *file_name, hsize_t *width, hsize_t *height);
unsigned char *gbuf = NULL; /* global buffer for image data */
static int read_data(const char *file_name, hsize_t *width, hsize_t *height);
static unsigned char *gbuf = NULL; /* global buffer for image data */

int
main(void)
Expand Down
10 changes: 5 additions & 5 deletions hl/src/H5DS.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
ds_list_t *dsbuf_w =
NULL; /* array of "REFERENCE_LIST" attribute data to write when adding new reference to a dataset */
hobj_ref_t ref_to_ds; /* reference to the DS */
hobj_ref_t ref_j; /* iterator reference */
hobj_ref_t ref_to_ds = HADDR_UNDEF; /* reference to the DS */
hobj_ref_t ref_j; /* iterator reference */

/* Variables to be used when new references are used */
nds_list_t ndsl;
nds_list_t *ndsbuf = NULL;
nds_list_t *ndsbuf_w = NULL;
H5R_ref_t nref_to_ds;
nds_list_t *ndsbuf = NULL;
nds_list_t *ndsbuf_w = NULL;
H5R_ref_t nref_to_ds = {0};
H5R_ref_t nref_j;
hbool_t is_new_ref;

Expand Down
17 changes: 9 additions & 8 deletions hl/test/test_ld.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* Varies from 10->13; 10->9, 10->10, 10->1, 10->11
*/
#define ONE_NTESTS 5
int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1};
static int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1};

/*
* Test variations (retained original) for two-dimensional dataset:
Expand All @@ -61,7 +61,8 @@ int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1};
* {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10}
*/
#define TWO_NTESTS 9
int two_tests[TWO_NTESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {-1, -1}, {-1, 0}, {0, 2}, {0, -1}, {0, 0}};
static int two_tests[TWO_NTESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {-1, -1},
{-1, 0}, {0, 2}, {0, -1}, {0, 0}};

/* Verify that the two input values are the same */
#define VERIFY_EQUAL(_x, _y) \
Expand Down Expand Up @@ -210,12 +211,12 @@ typedef struct test_valid_fields2 {

/* Temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */
#define TEST_BUF_SIZE 100
int *iibuf; /* buffer for storing retrieved elements */
int *ibuf; /* buffer for storing retrieved elements (integer) */
set_t *cbuf; /* buffer for storing retrieved elements (compound) */
set_t *ccbuf; /* buffer for storing retrieved elements (compound) */
test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */
test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */
static int *iibuf; /* buffer for storing retrieved elements */
static int *ibuf; /* buffer for storing retrieved elements (integer) */
static set_t *cbuf; /* buffer for storing retrieved elements (compound) */
static set_t *ccbuf; /* buffer for storing retrieved elements (compound) */
static test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */
static test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */

/*
*********************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion hl/test/test_packet_vlen.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ test_H5PTis_varlen(void)
*/
#define ATTR_RANK 1
#define ATTR_DIM 3
int attr_data[ATTR_DIM] = {256, 11945, -22107}; /* values to be written to attr */
static int attr_data[ATTR_DIM] = {256, 11945, -22107}; /* values to be written to attr */

static int
adding_attribute(hid_t fid, const char *table_name, const char *attr_name)
Expand Down
4 changes: 2 additions & 2 deletions hl/tools/gif2h5/decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ GIFBYTE *Raster; /* The raster data stream, unblocked */

/* The hash table used by the decompressor */

int *Prefix;
int *Suffix;
static int *Prefix;
static int *Suffix;

/* An output array used by the decompressor */

Expand Down
2 changes: 1 addition & 1 deletion hl/tools/gif2h5/hdf2gif.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ leave(int ret)
HDexit(ret);
}

FILE *fpGif = NULL;
static FILE *fpGif = NULL;
int
main(int argc, char **argv)
{
Expand Down
Loading