summaryrefslogtreecommitdiffstats
path: root/tools/h5import
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2014-03-16 04:44:13 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2014-03-16 04:44:13 (GMT)
commit164b4c75341ee4aa31dcd47c189e415a36ae35e2 (patch)
tree121120c9d2df2d601730e4c371afbf5f82004f92 /tools/h5import
parent288c7760a4a55d56df7a9019a8522625e305b9b7 (diff)
downloadhdf5-164b4c75341ee4aa31dcd47c189e415a36ae35e2.zip
hdf5-164b4c75341ee4aa31dcd47c189e415a36ae35e2.tar.gz
hdf5-164b4c75341ee4aa31dcd47c189e415a36ae35e2.tar.bz2
[svn-r24804] Description:
Brought changes from Coverity branch back to trunk, and cleaned up misc. other warnings & formatting issues: r20833: Fixed Coverity 667 and 668 with real integer overflow tests this time. r20834: Use HDstrncpy and HDstrncat. --gh r20835: Change to use strncpy - use base_len + 1 for line 156, use HDstrlen(path) + 1 for line 159 r20836: Fixed coverity 585 by casting output of fgetc() to a char. r20837: Changed sprintf calls to snprintf with size 1 less than the allocated buffer to address coverity issue #967. Tested on: Mac OSX/64 10.9.2 (amazon) w/C++, FORTRAN & parallel (too minor to require h5committest)
Diffstat (limited to 'tools/h5import')
-rw-r--r--tools/h5import/h5import.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c
index a10ef24..74c67b9 100644
--- a/tools/h5import/h5import.c
+++ b/tools/h5import/h5import.c
@@ -863,11 +863,11 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
hid_t handle;
hsize_t dims[1];
char str[1024];
- char c;
+ int c;
int i = 0;
int j;
- int nlines = 0;
- int line;
+ hsize_t nlines = 0;
+ hsize_t line;
/*-------------------------------------------------------------------------
* get number of lines in the input file
@@ -877,9 +877,8 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
while (!HDfeof(strm)) {
c = HDfgetc(strm);
- if (c == 10) { /* eol */
+ if (c == 10) /* eol */
nlines++;
- }
}
if (!nlines)
@@ -944,7 +943,7 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
while (!HDfeof(strm)) {
c = HDfgetc(strm);
- str[i] = c;
+ str[i] = (char)c;
i++;
@@ -1012,7 +1011,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
char *str3 = NULL;
char str[1024] = "";
int j;
- int line;
+ hsize_t line;
/*-------------------------------------------------------------------------
* read file and generate an HDF5 dataset
@@ -1079,7 +1078,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
str2 = NULL;
str3 = NULL;
#ifdef H5DEBUGIMPORT
- printf("processStrHDFData DATATYPE STRING[%d]={%s}\n", line, str1);
+ printf("processStrHDFData DATATYPE STRING[%llu]={%s}\n", (unsigned long long)line, str1);
#endif
/* process string to remove the first and last quote char */
str2 = strchr(str1, '"');
@@ -1108,7 +1107,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
hsize_t count[1] = { 1 };
#ifdef H5DEBUGIMPORT
- printf("processStrHDFData DATATYPE STRING[%d] store %s\n", line, str2);
+ printf("processStrHDFData DATATYPE STRING[%llu] store %s\n", (unsigned long long)line, str2);
#endif
if ((fspace_id = H5Dget_space(dset_id)) < 0)
goto out;