summaryrefslogtreecommitdiffstats
path: root/tools/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-01-15 17:32:01 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-01-15 17:32:01 (GMT)
commit1f8f6f019c85df6c031a32f6bf703fa18e225973 (patch)
tree29e642ec8de803f102bb0a593c86368e786b1a4b /tools/src
parentd14b96e95976967c03c7623f6800506b89292656 (diff)
downloadhdf5-1f8f6f019c85df6c031a32f6bf703fa18e225973.zip
hdf5-1f8f6f019c85df6c031a32f6bf703fa18e225973.tar.gz
hdf5-1f8f6f019c85df6c031a32f6bf703fa18e225973.tar.bz2
Fixed stack and frame size warnings. Not complete, but fixes most of
the easier cases.
Diffstat (limited to 'tools/src')
-rw-r--r--tools/src/h5import/h5import.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c
index bd1689f..a8cbc10 100644
--- a/tools/src/h5import/h5import.c
+++ b/tools/src/h5import/h5import.c
@@ -72,7 +72,7 @@ uint64_t swap_uint64(uint64_t val);
int main(int argc, char *argv[])
{
- struct Options opt;
+ struct Options *opt;
int outfile_named = FALSE;
int token;
int i;
@@ -99,8 +99,8 @@ int main(int argc, char *argv[])
(void) HDsetvbuf(stderr, (char *) NULL, _IOLBF, 0);
(void) HDsetvbuf(stdout, (char *) NULL, _IOLBF, 0);
- /* Initialize the file structure to 0 */
- HDmemset(&opt, 0, sizeof(struct Options));
+ if((opt = (struct Options *)HDcalloc(1, sizeof(struct Options))) == NULL)
+ goto err;
if (argv[1] && (HDstrcmp("-V", argv[1]) == 0)) {
print_version(PROGRAMNAME);
@@ -130,12 +130,12 @@ int main(int argc, char *argv[])
switch (state) {
case 1: /* counting input files */
- if (opt.fcount < 29) {
- (void) HDstrcpy(opt.infiles[opt.fcount].datafile, argv[i]);
- in = &(opt.infiles[opt.fcount].in);
- opt.infiles[opt.fcount].config = 0;
- setDefaultValues(in, opt.fcount);
- opt.fcount++;
+ if (opt->fcount < 29) {
+ (void) HDstrcpy(opt->infiles[opt->fcount].datafile, argv[i]);
+ in = &(opt->infiles[opt->fcount].in);
+ opt->infiles[opt->fcount].config = 0;
+ setDefaultValues(in, opt->fcount);
+ opt->fcount++;
}
else {
(void) HDfprintf(stderr, err9, argv[i]);
@@ -148,8 +148,8 @@ int main(int argc, char *argv[])
break;
case 3: /* get configfile name */
- (void) HDstrcpy(opt.infiles[opt.fcount-1].configfile, argv[i]);
- opt.infiles[opt.fcount - 1].config = 1;
+ (void) HDstrcpy(opt->infiles[opt->fcount-1].configfile, argv[i]);
+ opt->infiles[opt->fcount - 1].config = 1;
break;
case 4: /* -o found; look for outfile */
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
(void) HDfprintf(stderr, err10, argv[i]);
goto err;
}
- (void) HDstrcpy(opt.outfile, argv[i]);
+ (void) HDstrcpy(opt->outfile, argv[i]);
outfile_named = TRUE;
break;
@@ -232,11 +232,11 @@ int main(int argc, char *argv[])
goto err;
}
- if (process(&opt) == -1)
+ if (process(opt) == -1)
goto err;
- for (i = 0; i < opt.fcount; i++) {
- in = &(opt.infiles[i].in);
+ for (i = 0; i < opt->fcount; i++) {
+ in = &(opt->infiles[i].in);
if (in->sizeOfDimension)
HDfree(in->sizeOfDimension);
if (in->sizeOfChunk)
@@ -248,12 +248,13 @@ int main(int argc, char *argv[])
if (in->data)
HDfree(in->data);
}
+ HDfree(opt);
- return (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
err:
(void) HDfprintf(stderr, "%s", err4);
- for (i = 0; i < opt.fcount; i++) {
- in = &(opt.infiles[i].in);
+ for (i = 0; i < opt->fcount; i++) {
+ in = &(opt->infiles[i].in);
if (in->sizeOfDimension)
HDfree(in->sizeOfDimension);
if (in->sizeOfChunk)
@@ -265,7 +266,9 @@ err:
if (in->data)
HDfree(in->data);
}
- return (EXIT_FAILURE);
+ HDfree(opt);
+
+ return EXIT_FAILURE;
}
static int gtoken(char *s)