diff --git a/hdf/util/he_main.c b/hdf/util/he_main.c index 1809f9b8c6..eb5ff27a6e 100644 --- a/hdf/util/he_main.c +++ b/hdf/util/he_main.c @@ -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; @@ -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); @@ -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); } diff --git a/mfhdf/dumper/hdp_list.c b/mfhdf/dumper/hdp_list.c index dcaf50c5c5..b0a5e2f15c 100644 --- a/mfhdf/dumper/hdp_list.c +++ b/mfhdf/dumper/hdp_list.c @@ -892,24 +892,26 @@ 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) { @@ -917,14 +919,14 @@ do_list(intn curr_arg, intn argc, char *argv[], intn help) 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; diff --git a/mfhdf/hdfimport/hdfimport.c b/mfhdf/hdfimport/hdfimport.c index 0cdba747b6..7151ec0a3a 100644 --- a/mfhdf/hdfimport/hdfimport.c +++ b/mfhdf/hdfimport/hdfimport.c @@ -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]; @@ -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; diff --git a/mfhdf/test/tcoordvar.c b/mfhdf/test/tcoordvar.c index 12a0be9ca9..f58c56e1d5 100644 --- a/mfhdf/test/tcoordvar.c +++ b/mfhdf/test/tcoordvar.c @@ -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;