Skip to content

Commit

Permalink
fix some compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
markcmiller86 committed Aug 2, 2024
1 parent 3afb21f commit afad9b5
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 52 deletions.
62 changes: 31 additions & 31 deletions src/hdf5_drv/H5FDsilo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,42 +1647,42 @@ H5FD_silo_close(H5FD_t *_file)
hsize_t tot_raw_count, tot_raw_bytes, tot_md_count, tot_md_bytes;
FILE* logf = fopen(file->log_name, "w");
fprintf(logf, "======== Interactions between the VFD and the filesystem ========\n");
fprintf(logf, "block size = %llu\n", file->block_size);
fprintf(logf, "block size = %llu\n", (long long unsigned) file->block_size);
fprintf(logf, "block count = %d\n", file->max_blocks);
fprintf(logf, "\n");
fprintf(logf, "max block id = %llu\n", file->stats.max_block_id);
fprintf(logf, "max blocks in mem = %llu\n", file->stats.max_blocks_in_mem);
fprintf(logf, "max block id = %llu\n", (long long unsigned) file->stats.max_block_id);
fprintf(logf, "max blocks in mem = %llu\n", (long long unsigned) file->stats.max_blocks_in_mem);
fprintf(logf, "\n");
fprintf(logf, "total seeks = %llu\n", file->stats.total_seeks);
fprintf(logf, "total seeks = %llu\n", (long long unsigned) file->stats.total_seeks);
fprintf(logf, "\n");
fprintf(logf, "number of multi-block writes = %llu\n", file->stats.num_multiblock_writes);
fprintf(logf, "number of multi-block reads = %llu\n", file->stats.num_multiblock_reads);
fprintf(logf, "number of multi-block writes = %llu\n", (long long unsigned) file->stats.num_multiblock_writes);
fprintf(logf, "number of multi-block reads = %llu\n", (long long unsigned) file->stats.num_multiblock_reads);
fprintf(logf, "\n");
fprintf(logf, "number of blocks majority md = %llu\n", file->stats.num_blocks_majority_md);
fprintf(logf, "number of blocks majority raw = %llu\n", file->stats.num_blocks_majority_raw);
fprintf(logf, "number of blocks majority md = %llu\n", (long long unsigned) file->stats.num_blocks_majority_md);
fprintf(logf, "number of blocks majority raw = %llu\n", (long long unsigned) file->stats.num_blocks_majority_raw);
fprintf(logf, "\n");
fprintf(logf, "number of writes = %llu\n", file->stats.total_write_count);
fprintf(logf, "number of bytes written = %llu\n", file->stats.total_write_bytes);
fprintf(logf, "number of writes = %llu\n", (long long unsigned) file->stats.total_write_count);
fprintf(logf, "number of bytes written = %llu\n", (long long unsigned) file->stats.total_write_bytes);
fprintf(logf, "\n");
fprintf(logf, "number of times a raw block was written = %llu\n", file->stats.total_block_raw_writes);
fprintf(logf, "number of times a raw block was written more than once = %llu\n", file->stats.total_block_raw_re_writes);
fprintf(logf, "number of times a raw block was written = %llu\n", (long long unsigned) file->stats.total_block_raw_writes);
fprintf(logf, "number of times a raw block was written more than once = %llu\n", (long long unsigned) file->stats.total_block_raw_re_writes);
fprintf(logf, "\n");
fprintf(logf, "number of times an md block was written = %llu\n", file->stats.total_block_md_writes);
fprintf(logf, "number of times an md block was written more than once = %llu\n", file->stats.total_block_md_re_writes);
fprintf(logf, "number of times an md block was written = %llu\n", (long long unsigned) file->stats.total_block_md_writes);
fprintf(logf, "number of times an md block was written more than once = %llu\n", (long long unsigned) file->stats.total_block_md_re_writes);
fprintf(logf, "\n");
fprintf(logf, "number of reads = %llu\n", file->stats.total_read_count);
fprintf(logf, "number of bytes read = %llu\n", file->stats.total_read_bytes);
fprintf(logf, "number of reads = %llu\n", (long long unsigned) file->stats.total_read_count);
fprintf(logf, "number of bytes read = %llu\n", (long long unsigned) file->stats.total_read_bytes);
fprintf(logf, "\n");
fprintf(logf, "number of times a block was read = %llu\n", file->stats.total_block_reads);
fprintf(logf, "number of times a block was read more than once = %llu\n", file->stats.total_block_re_reads);
fprintf(logf, "number of times a block was read = %llu\n", (long long unsigned) file->stats.total_block_reads);
fprintf(logf, "number of times a block was read more than once = %llu\n", (long long unsigned) file->stats.total_block_re_reads);
fprintf(logf, "\n");
fprintf(logf, "number of hot blocks %d\n", file->stats.num_hot_blocks);
fprintf(logf, "hot blocks...\n");
for (i = 0; i < file->stats.num_hot_blocks; i++)
{
silo_vfd_hot_block_stats_t *hb = &(file->stats.hot_block_list[i]);
fprintf(logf," %8llu: %4s (%f), #writes=%8llu, #reads=%8llu\n",
hb->id, (hb->raw_frac>0.5?"raw":"meta"), hb->raw_frac, hb->num_block_writes+1, hb->num_block_reads+1);
(long long unsigned) hb->id, (hb->raw_frac>0.5?"raw":"meta"), hb->raw_frac, (long long unsigned) hb->num_block_writes+1, (long long unsigned) hb->num_block_reads+1);
}
if (file->stats.hot_block_list) free(file->stats.hot_block_list);
if (file->was_written_map.bitmap) free(file->was_written_map.bitmap);
Expand All @@ -1691,10 +1691,10 @@ H5FD_silo_close(H5FD_t *_file)
fprintf(logf, "\n");
fprintf(logf, "\n");
fprintf(logf, "======== Interactions between HDF5 library and the VFD ========\n");
fprintf(logf, "number raw writes = %llu\n", file->stats.total_vfd_raw_write_count);
fprintf(logf, "number raw bytes written = %llu\n", file->stats.total_vfd_raw_write_bytes);
fprintf(logf, "number md writes = %llu\n", file->stats.total_vfd_md_write_count);
fprintf(logf, "number md bytes written = %llu\n", file->stats.total_vfd_md_write_bytes);
fprintf(logf, "number raw writes = %llu\n", (long long unsigned) file->stats.total_vfd_raw_write_count);
fprintf(logf, "number raw bytes written = %llu\n", (long long unsigned) file->stats.total_vfd_raw_write_bytes);
fprintf(logf, "number md writes = %llu\n", (long long unsigned) file->stats.total_vfd_md_write_count);
fprintf(logf, "number md bytes written = %llu\n", (long long unsigned) file->stats.total_vfd_md_write_bytes);
fprintf(logf, "histogram...\n");
cum_raw_count = 0;
cum_raw_bytes = 0;
Expand Down Expand Up @@ -1730,16 +1730,16 @@ H5FD_silo_close(H5FD_t *_file)

fprintf(logf,"%2d: %8llu (%3d%%, %3d%%) %8llu (%3d%%, %3d%%) | "
"%8llu (%3d%%, %3d%%) %8llu (%3d%%, %3d%%)\n", i,
file->stats.vfd_raw_write_count_hist[i],
(long long unsigned) file->stats.vfd_raw_write_count_hist[i],
(int) (100.0 * file->stats.vfd_raw_write_count_hist[i] / tot_raw_count),
(int) (100.0 * cum_raw_count / tot_raw_count),
file->stats.vfd_raw_write_bytes_hist[i],
(long long unsigned) file->stats.vfd_raw_write_bytes_hist[i],
(int) (100.0 * file->stats.vfd_raw_write_bytes_hist[i] / tot_raw_bytes),
(int) (100.0 * cum_raw_bytes / tot_raw_bytes),
file->stats.vfd_md_write_count_hist[i],
(long long unsigned) file->stats.vfd_md_write_count_hist[i],
(int) (100.0 * file->stats.vfd_md_write_count_hist[i] / tot_md_count),
(int) (100.0 * cum_md_count / tot_md_count),
file->stats.vfd_md_write_bytes_hist[i],
(long long unsigned) file->stats.vfd_md_write_bytes_hist[i],
(int) (100.0 * file->stats.vfd_md_write_bytes_hist[i] / tot_md_bytes),
(int) (100.0 * cum_md_bytes / tot_md_bytes));
}
Expand Down Expand Up @@ -1777,16 +1777,16 @@ H5FD_silo_close(H5FD_t *_file)

fprintf(logf,"%2d: %8llu (%3d%%, %3d%%) %8llu (%3d%%, %3d%%) | "
"%8llu (%3d%%, %3d%%) %8llu (%3d%%, %3d%%)\n", i,
file->stats.vfd_raw_read_count_hist[i],
(long long unsigned) file->stats.vfd_raw_read_count_hist[i],
(int) (100.0 * file->stats.vfd_raw_read_count_hist[i] / tot_raw_count),
(int) (100.0 * cum_raw_count / tot_raw_count),
file->stats.vfd_raw_read_bytes_hist[i],
(long long unsigned) file->stats.vfd_raw_read_bytes_hist[i],
(int) (100.0 * file->stats.vfd_raw_read_bytes_hist[i] / tot_raw_bytes),
(int) (100.0 * cum_raw_bytes / tot_raw_bytes),
file->stats.vfd_md_read_count_hist[i],
(long long unsigned) file->stats.vfd_md_read_count_hist[i],
(int) (100.0 * file->stats.vfd_md_read_count_hist[i] / tot_md_count),
(int) (100.0 * cum_md_count / tot_md_count),
file->stats.vfd_md_read_bytes_hist[i],
(long long unsigned) file->stats.vfd_md_read_bytes_hist[i],
(int) (100.0 * file->stats.vfd_md_read_bytes_hist[i] / tot_md_bytes),
(int) (100.0 * cum_md_bytes / tot_md_bytes));
}
Expand Down
2 changes: 1 addition & 1 deletion src/silo/silo.c
Original file line number Diff line number Diff line change
Expand Up @@ -5933,7 +5933,7 @@ db_can_overwrite_dstobj_with_srcobj(

for (q = 0; q < srcObj->ncomponents; q++)
{
int r, dstr = -1;;
int r, dstr = -1;
char const *curr_compname = srcObj->comp_names[q];

for (r = 0; r < dstObj->ncomponents && dstr==-1; r++)
Expand Down
10 changes: 6 additions & 4 deletions src/silo/silo_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ json_object_new_strptr(void *p)
{
static char tmp[32];
if (sizeof(p) == sizeof(unsigned))
snprintf(tmp, sizeof(tmp), "0x%016x", (unsigned) p);
snprintf(tmp, sizeof(tmp), "0x%016x", (unsigned) ((unsigned long long) p));
else if (sizeof(p) == sizeof(unsigned long))
snprintf(tmp, sizeof(tmp), "0x%016lx", (unsigned long) p);
snprintf(tmp, sizeof(tmp), "0x%016lx", (unsigned long) ((unsigned long long) p));
else if (sizeof(p) == sizeof(unsigned long long))
snprintf(tmp, sizeof(tmp), "0x%016llx", (unsigned long long) p);

Expand Down Expand Up @@ -479,10 +479,11 @@ int
json_object_to_binary_file(char const *filename, struct json_object *obj)
{
void *buf; int len; int fd;
size_t _nbyt;

json_object_to_binary_buf(obj, 0, &buf, &len);
fd = open(filename, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR);
write(fd, buf, len);
_nbyt = write(fd, buf, len);
close(fd);
free(buf);
return 0;
Expand Down Expand Up @@ -1639,10 +1640,11 @@ DBGetJsonObject(DBfile *dbfile, char const *objname)
else if (!strncmp(sobj->pdb_names[i], "'<s>", 4))
{
char tmp[256];
char *tmp_path;
size_t len = strlen(sobj->pdb_names[i])-5;
memset(tmp, 0, sizeof(tmp));
strncpy(tmp, sobj->pdb_names[i]+4, len);
char *tmp_path = db_join_path(obj_dirname, tmp);
tmp_path = db_join_path(obj_dirname, tmp);
if (DBInqVarExists(dbfile, tmp_path))
{
if (DBInqVarType(dbfile, tmp_path) == DB_VARIABLE)
Expand Down
22 changes: 11 additions & 11 deletions src/taurus/silo_taurus.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,10 @@ db_taur_NewToc(DBfile *_dbfile)
toc->dir_names[i] = ALLOC_N(char, 12);

if (taurus->nstates < 100) {
sprintf(toc->dir_names[i], "state%02d", i);
snprintf(toc->dir_names[i], 12, "state%02d", i);
}
else {
sprintf(toc->dir_names[i], "state%03d", i);
snprintf(toc->dir_names[i], 12, "state%03d", i);
}
}
toc->ndir = taurus->nstates;
Expand Down Expand Up @@ -1455,9 +1455,9 @@ db_taur_InqMeshname(DBfile *_dbfile, char const *var_name, char *mesh_name)
*/
if (strcmp(var_name, "mat1") == 0) {
if (taurus->nstates < 100)
sprintf(mesh_name, "/state%02d/mesh1", taurus->state);
snprintf(mesh_name, 14, "/state%02d/mesh1", taurus->state);
else
sprintf(mesh_name, "/state%03d/mesh1", taurus->state);
snprintf(mesh_name, 15, "/state%03d/mesh1", taurus->state);
return (0);
}
}
Expand All @@ -1480,10 +1480,10 @@ db_taur_InqMeshname(DBfile *_dbfile, char const *var_name, char *mesh_name)

if (taur_var_list[i].idir == idir) {
if (taurus->nstates < 100)
sprintf(mesh_name, "/state%02d/%s", taurus->state,
snprintf(mesh_name, 256, "/state%02d/%s", taurus->state,
taur_var_list[i].mesh);
else
sprintf(mesh_name, "/state%03d/%s", taurus->state,
snprintf(mesh_name, 256, "/state%03d/%s", taurus->state,
taur_var_list[i].mesh);
return (0);
}
Expand Down Expand Up @@ -1786,7 +1786,7 @@ db_taur_cd(TAURUSfile *taurus, char const *path)
}
else {
db_taur_pwd(taurus, opath);
sprintf(npath, "%s/%s", opath, path);
snprintf(npath, 256, "%s/%s", opath, path);
}
reduce_path(npath);

Expand Down Expand Up @@ -1873,19 +1873,19 @@ db_taur_pwd(TAURUSfile *taurus, char *path)
else {
if (taurus->idir == -1) {
if (taurus->nstates < 100) {
sprintf(path, "/state%02d", taurus->state);
snprintf(path, 7, "/state%02d", taurus->state);
}
else {
sprintf(path, "/state%03d", taurus->state);
snprintf(path, 8, "/state%03d", taurus->state);
}
}
else {
if (taurus->nstates < 100) {
sprintf(path, "/state%02d/%s", taurus->state,
snprintf(path, 256, "/state%02d/%s", taurus->state,
dir_names[taurus->idir]);
}
else {
sprintf(path, "/state%03d/%s", taurus->state,
snprintf(path, 256, "/state%03d/%s", taurus->state,
dir_names[taurus->idir]);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/zfp-0.5.5/src/template/decodef.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ _t2(decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock)
uint bits = 1;
/* test if block has nonzero values */
if (stream_read_bit(zfp->stream)) {
int emax;
int maxprec;
cache_align_(Int iblock[BLOCK_SIZE]);
/* decode common exponent */
bits += EBITS;
int emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS;
int maxprec = precision(emax, zfp->maxprec, zfp->minexp, DIMS);
emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS;
maxprec = precision(emax, zfp->maxprec, zfp->minexp, DIMS);
/* decode integer block */
bits += _t2(decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, maxprec, iblock);
/* perform inverse block-floating-point transform */
Expand Down
3 changes: 2 additions & 1 deletion src/zfp-0.5.5/src/template/revdecodef.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ _t2(rev_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock)
_t1(rev_inv_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE);
}
else {
int emax;
/* decode common exponent */
bits += EBITS;
int emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS;
emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS;
/* decode integer block */
bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, iblock);
/* perform inverse block-floating-point transform */
Expand Down
5 changes: 3 additions & 2 deletions tools/browser/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ be used for advertising or product endorsement purposes.
#ifdef HAVE_FNMATCH_H
# include <fnmatch.h>
#endif
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -2333,9 +2334,9 @@ file_deref (obj_t _self, int argc, obj_t argv[]) {
if (DBGetDir(file, cwd)<0) return NIL;
if ('/'!=name[0]) {
if (!strcmp(cwd, "/")) {
sprintf(fullname, "/%s", name);
snprintf(fullname, sizeof(fullname), "/%s", name);
} else {
sprintf(fullname, "%s/%s", cwd, name);
snprintf(fullname, sizeof(fullname), "%s/%s", cwd, name);
}
name = fullname;
}
Expand Down

0 comments on commit afad9b5

Please sign in to comment.