Skip to content

Commit

Permalink
Fix all maybe-uninitialized warnings (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
derobins authored Feb 5, 2024
1 parent cf85150 commit fce1de3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
15 changes: 9 additions & 6 deletions hdf/util/he_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,7 @@ putElement(char *file, uint16 tag, uint16 ref, char *data, int32 len)
int
writeGrp(char *file)
{
int i;
uint16 ref;
uint16 ref = DFREF_NONE;
int grp;
int elt;
int ret;
Expand All @@ -676,14 +675,16 @@ writeGrp(char *file)

grp = currGrpNo;
gid = DFdisetup(he_grp[grp].size);
for (i = 0; i < he_grp[grp].size; i++) {
for (int i = 0; i < he_grp[grp].size; i++) {
elt = findDesc(he_grp[grp].ddList + i);
if (elt >= 0)
writeElt(file, ref, elt);
/* update the group dd list */

/* Update the group dd list */
DFdiput(gid, he_grp[grp].ddList[i].tag, ref);
}
/* do the group now */

/* Do the group now */

if ((fid = Hopen(file, DFACC_READ | DFACC_WRITE, 0)) == FAIL) {
HEprint(stderr, 0);
Expand All @@ -701,12 +702,14 @@ getNewRef(char *file, uint16 *pRef)
{
int32 fid;

if ((fid = Hopen(file, DFACC_READ | DFACC_WRITE, 0)) == FAIL)
if ((fid = Hopen(file, DFACC_READ | DFACC_WRITE, 0)) == FAIL) {
/* a little tricky here */
if (HEvalue(0) != DFE_FNF || (fid = Hopen(file, DFACC_ALL, 0)) == FAIL) {
HEprint(stderr, 0);
return FAIL;
}
}

*pRef = Hnewref(fid);
return Hclose(fid);
}
Expand Down
20 changes: 11 additions & 9 deletions mfhdf/dumper/hdp_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,39 +892,41 @@ do_list(intn curr_arg, intn argc, char *argv[], intn help)
int32 an_id = FAIL; /* annotation interface handle */
intn ret_value = SUCCEED;

/* Do this early, to avoid uninitialized warnings in cleanup code */
init_list_opts(&list_opts);

if (help == TRUE) {
list_usage(argc, argv);
goto done;
} /* end if */
}

/* incomplete command */
/* Incomplete command */
if (curr_arg >= argc) {
list_usage(argc, argv);
ret_value = FAIL; /* so caller can be traced in debugging */
ret_value = FAIL; /* So caller can be traced in debugging */
goto done;
}

init_list_opts(&list_opts);
if ((status = parse_list_opts(&list_opts, curr_arg, argc, argv)) == FAIL) {
list_usage(argc, argv);
ret_value = FAIL;
goto done;
} /* end if */
}

curr_arg += status;
if (curr_arg >= argc || (f_list = make_file_list(curr_arg, argc, argv)) == NULL) {
fprintf(stderr, "ERROR: No files to dump!\n");
list_usage(argc, argv);
ret_value = FAIL;
goto done;
} /* end if */
}

/* process each file */
/* Process each file */
f_name = get_next_file(f_list, 0);
while (f_name != NULL) {
int label_flag, desc_flag;
vinit_done = FALSE; /* reset global Vset variable */
obj_num = 0; /* number of the object we are displaying */
vinit_done = FALSE; /* Reset global Vset variable */
obj_num = 0; /* Number of the object we are displaying */
fid = FAIL;
an_id = FAIL;

Expand Down
5 changes: 3 additions & 2 deletions mfhdf/hdfimport/hdfimport.c
Original file line number Diff line number Diff line change
Expand Up @@ -2501,7 +2501,7 @@ pixrep(struct Input *in, struct Raster *im)
static int32
create_SDS(int32 sd_id, int32 nt, struct Input *in)
{
int32 sds_id;
int32 sds_id = FAIL;

if (in->rank == 2) {
int32 edges[2];
Expand Down Expand Up @@ -2712,7 +2712,8 @@ process(struct Options *opt)
int32 len;
FILE *strm = NULL;
int32 hdf;
int32 sd_id, sds_id;
int32 sd_id = FAIL;
int32 sds_id = FAIL;

#ifdef DEBUG
int h, v, d;
Expand Down
3 changes: 2 additions & 1 deletion mfhdf/test/tcoordvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ test_dim1_SDS1(void)
float32 sds1_data[] = {0.1, 2.3, 4.5, 6.7, 8.9};
float32 out_data[5];
int32 dimsize[1];
int32 sds_id, file_id, dim_id, index;
int32 sds_id, file_id, dim_id;
int32 index = FAIL;
int32 start = 0, stride = 1;
int32 num_type, count;
int32 n_datasets, n_file_attrs, n_vars = 0;
Expand Down

0 comments on commit fce1de3

Please sign in to comment.