[Getdata-commits] SF.net SVN: getdata:[877] trunk/getdata
Scientific Database Format
Brought to you by:
ketiltrout
|
From: <ket...@us...> - 2014-02-19 00:22:59
|
Revision: 877
http://sourceforge.net/p/getdata/code/877
Author: ketiltrout
Date: 2014-02-19 00:22:56 +0000 (Wed, 19 Feb 2014)
Log Message:
-----------
Fix bugs reported by Coverity Scan.
Modified Paths:
--------------
trunk/getdata/ChangeLog
trunk/getdata/NEWS
trunk/getdata/bindings/cxx/entry.cpp
trunk/getdata/bindings/cxx/fragment.cpp
trunk/getdata/bindings/f77/fgetdata.c
trunk/getdata/bindings/idl/getdata.c
trunk/getdata/bindings/make_parameters.c
trunk/getdata/bindings/php/getdata.c
trunk/getdata/bindings/python/pydirfile.c
trunk/getdata/bindings/python/pyentry.c
trunk/getdata/bindings/python/pygetdata.h
trunk/getdata/src/add.c
trunk/getdata/src/bzip.c
trunk/getdata/src/common.c
trunk/getdata/src/entry.c
trunk/getdata/src/getdata.h.in
trunk/getdata/src/gzip.c
trunk/getdata/src/include.c
trunk/getdata/src/lzma.c
trunk/getdata/src/mod.c
trunk/getdata/src/name.c
trunk/getdata/src/open.c
trunk/getdata/src/parse.c
trunk/getdata/src/putdata.c
trunk/getdata/src/sie.c
trunk/getdata/src/types.c
trunk/getdata/test/add_alias.c
trunk/getdata/test/add_alias_affix.c
trunk/getdata/test/add_alias_meta.c
trunk/getdata/test/add_resolv.c
trunk/getdata/test/add_spec_resolv.c
trunk/getdata/test/alias_num.c
trunk/getdata/test/alias_num_alias.c
trunk/getdata/test/alias_num_missing.c
trunk/getdata/test/madd_alias.c
trunk/getdata/test/madd_alias_affix.c
trunk/getdata/test/madd_spec_resolv.c
trunk/getdata/util/checkdirfile.c
trunk/getdata/util/dirfile2ascii.c
Added Paths:
-----------
trunk/getdata/doc/cov_mod.c
Property Changed:
----------------
trunk/getdata/
Index: trunk/getdata
===================================================================
--- trunk/getdata 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata 2014-02-19 00:22:56 UTC (rev 877)
Property changes on: trunk/getdata
___________________________________________________________________
Modified: svn:ignore
## -7,6 +7,7 ##
config.status
config.sub
configure
+cov-int
depcomp
getdata_win-*.zip
getdata_win-*.sig
Modified: trunk/getdata/ChangeLog
===================================================================
--- trunk/getdata/ChangeLog 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/ChangeLog 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,58 @@
-2014-02-21 D. V. Wiebe <ge...@ke...> svn:876
+2014-02-14 D. V. Wiebe <ge...@ke...> svn:877
+ * bindings/cxx/entry.cpp (Entry::Entry): Zero E if gd_entry call fails.
+
+ * bindings/cxx/fragment.cpp (Fragment::Fragment): Handle error in
+ gd_fragment_affixes call.
+
+ * bindings/f77/fgetdata.c (GDASCA): Handle error in gd_entry call.
+
+ * bindings/php/getdata.c (gdphp_data_to_array): Add missing break.
+
+ * bindings/php/getdata.c (gd_error_string): Handle error in gd_error_string
+ call.
+
+ * bindings/python/pygetdata.h (PYGD_REPORT_ERROR): Added.
+
+ * bindings/python/pydirfile.c (gdpy_dirfile_getentry gdpy_dirfile_getstring
+ gdpy_dirfile_putcarray gdpy_dirfile_putdata) src/include.c (_GD_Include)
+ src/name.c (_GD_PrepareRename) src/putdata.c (_GD_DoMplexOut) src/sie.c
+ (_GD_SampIndWrite) src/types.c (_GD_ConvertType): Deallocate buffers on error.
+
+ * bindings/python/pyentry.c (gdpy_entry_seta): Set a[i] if the pyobj is
+ complex.
+
+ * src/bzip.c (_GD_Bzip2Size): Free ptr only after we're done with it.
+
+ * src/common.c (_GD_CanonicalPath): Don't let readlink overrun the buffer.
+ Also fix double free.
+
+ * src/entry.c (_GD_FreeE): Fix overrun on zeroing of in_fields.
+
+ * src/entry.c (gd_linterp_tablename): Don't use field_code after free.
+
+ * src/getdata.h.in: Remove __nonnull__ from parameter two of
+ gd_verbose_prefix.
+
+ * src/gzip.c (_GD_GzipOpen): Check that _GD_MakeTempFile() worked.
+
+ * src/open.c (_GD_CreateDirfile _GD_Open): Close descriptors on error.
+
+ * src/parse.c (_GD_ParseCarray): Return on error.
+
+ * src/parse.c (_GD_ParseFieldSpec): Only resize the dot_list when necessary.
+ Also, clean up if the resize doesn't work.
+
+ * util/dirfile2ascii.c (main): Fix check for too many fields.
+
+ * src/entry.c (gd_naliases): Return unsigned int and zero on error per
+ documentation.
+ * bindings/idl/getdata.c (gdidl_naliases) src/entry.c (gd_aliases)
+ test/add_alias.c test/add_alias_affix.c test/add_alias_meta.c
+ test/add_resolv.c test/add_spec_resolv.c test/alias_num.c
+ test/alias_num_alias.c test/alias_num_missing.c test/madd_alias.c
+ test/madd_alias_affix.c test/madd_spec_resolv.c: Handle unsigned gd_naliases.
+
+2014-02-13 D. V. Wiebe <ge...@ke...> svn:876
* bindings/python/pyfragment.c (gdpy_fragment_init): Fix typo in keyword
names.
Modified: trunk/getdata/NEWS
===================================================================
--- trunk/getdata/NEWS 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/NEWS 2014-02-19 00:22:56 UTC (rev 877)
@@ -6,6 +6,17 @@
semicolon) when the parameter is purely real. However, a non-zero imaginary
part is still an error.
+ * gd_free_entry_strings() now NULLs pointers after freeing them.
+
+ * gd_entry() now returns entry metadata when they contain scalar field codes
+ which do not exist. In this case the GD_EN_CALC flag in the object will
+ not be set. Previously, on such entries, this function would fail with the
+ error GD_E_BAD_SCALAR, and return nothing.
+
+ * gd_rename() now by default updates the target of ALIASes pointing to a
+ renamed field to point to the new field instead of leaving them dangle.
+ (But see GD_REN_DANGLE).
+
* BUG FIX: The parsing of the \x and \u escape sequences are now correct.
* BUG FIX: Computation of LINCOMs with complex valued input fields now
@@ -26,7 +37,7 @@
Previously they would store these invalid field codes, causing problems
later.
- * BUG FIX: Returning complex-valued CARRAYs as purely real now works.
+ * BUG FIX: Returning complex-valued CARRAYs as purely real data now works.
Previously only the first element requested would be returned, the remaining
output buffer containing uninitialised data.
@@ -34,10 +45,10 @@
entry is no longer ignored by gd_[m]add().
* BUG FIX: Entry members spf, bitnum, numbits, and period are now completely
- ignored by gd_[m]add() when corresponding named scalars are specified.
+ ignored by gd_[m]add() if corresponding named scalars are specified.
Previously, an invalid value in these members would result in the entry
- being rejected, even though the rest of GetData ignored the invalid, unsued
- value.
+ being rejected, even though the invalid value was immediately discarded
+ when the field was added.
* BUG FIX: gd_[m]add() no longer rejects MPLEX fields with negative count_val.
@@ -47,58 +58,19 @@
* BUG FIX: reading a LINTERP table with fewer than two lines no longer results
in a segfault on close/discard.
- * BUG FIX: DIVIDE fields with complex valued divisors are now properly
+ * BUG FIX: DIVIDE fields with complex-valued divisors are now properly
computed.
* BUG FIX: Complex-valued DIVIDE, POLYNOM, and RECIP fields are now computed
properly when the library is built in ANSI C mode.
- * BUG FIX: Writing complex MPLEX fields no longer corrupts the stored data.
+ * BUG FIX: Writing complex-valued MPLEX fields no longer corrupts the stored
+ data.
* BUG FIX: Several fixes have been made to the sample index encoding (SIE)
engine, which should now produce properly encoded data when performing
random writes.
- API Changes:
-
- * gd_free_entry_strings() now NULLs pointers after freeing them.
-
- * The comp_scal member of the gd_entry_t object has been replaced with a flags
- member, containing a flag (GD_EN_COMPSCAL) with the meaning of the former
- comp_scal member. There are also flags for hiddenness (GD_EN_HIDDEN) and
- whether the scalar entries have been computed (GD_EN_CALC).
-
- * gd_entry() now returns entry metadata when they contain scalar field codes
- which do not exist. In this case the GD_EN_CALC flag in the object will
- not be set. Previously, on such entries, this function would fail with the
- error GD_E_BAD_SCALAR and return nothing.
-
- * gd_[m]add() and gd_alter_entry() can now be used to set or change the
- hiddenness of a field by setting or clearing the GD_EN_HIDDEN bit in the
- supplied gd_entry_t object.
-
- * Two new rename flags have been added:
- - GD_REN_DANGLE which indicates the library shouldn't update ALIASes whose
- target has been renamed (turning them into dangling aliases)
- - GD_REN_FORCE which causes the library to skip updating field codes which
- would be invalid due to affixes instead of failing.
-
- * gd_rename() now by default updates the target of ALIASes pointing to a
- renamed field to point to the new field instead of leaving them dangle.
- (But see GD_REN_DANGLE).
-
- * The move_data argument of gd_move() has been replaced with a flags argument
- which accepts the GD_REN_* flags, which have the same meaning as they do
- with gd_rename().
-
- * gd_move_alias() has been deleted: its function is now performed by
- gd_move(). If gd_move() is passed the field code of an alias, the alias is
- now moved, instead of moving the field the alias points to.
-
- * BUG FIX: If the dirfile path provided cannot be resolved (due to, for
- instance, a symbolic link pointing to a non-existent path), gd_open() and
- friends now return GD_E_OPEN, as documented, instead of GD_E_RAW_IO.
-
* BUG FIX: gd_bof() now returns the correct number (i.e.: zero) when reporting
the beginning of field of derived fields shifted to before the start of the
dirfile. Previously, this function incorrectly returned values ranging from
@@ -134,11 +106,41 @@
of the affected fragment; previously, these old, cached filenames could lead
to I/O errors when reading and writing the re-encoded RAW data files.
- Legacy API Changes:
+ * BUG FIX: Calling the Legacy API function GetFormat() on a Dirfile with MPLEX
+ or WINDOW fields no longer results in a segmentation fault.
- * BUG FIX: Calling GetFormat on a Dirfile with MPLEX or WINDOW fields no
- longer results in a segmentation fault.
+ API Changes:
+ * The comp_scal member of the gd_entry_t object has been replaced with a flags
+ member, containing a flag (GD_EN_COMPSCAL) with the meaning of the former
+ comp_scal member. There are also flags for hiddenness (GD_EN_HIDDEN) and
+ whether the scalar entries have been computed (GD_EN_CALC).
+
+ * gd_[m]add() and gd_alter_entry() can now be used to set or change the
+ hiddenness of a field by setting or clearing the GD_EN_HIDDEN bit in the
+ supplied gd_entry_t object.
+
+ * Two new rename flags have been added:
+ - GD_REN_DANGLE which indicates the library shouldn't update ALIASes whose
+ target has been renamed (turning them into dangling aliases)
+ - GD_REN_FORCE which causes the library to skip updating field codes which
+ would be invalid due to affixes instead of failing.
+
+ * The move_data argument of gd_move() has been replaced with a flags argument
+ which accepts the GD_REN_* flags, which have the same meaning as they do
+ with gd_rename().
+
+ * gd_move_alias() has been deleted: its function is now performed by
+ gd_move(). If gd_move() is passed the field code of an alias, the alias is
+ now moved, instead of moving the field the alias points to.
+
+ * BUG FIX: If the dirfile path provided cannot be resolved (due to, for
+ instance, a symbolic link pointing to a non-existent path), gd_open() and
+ friends now return GD_E_OPEN, as documented, instead of GD_E_RAW_IO.
+
+ * BUG FIX: gd_naliases() now returns an unsigned int, and zero on error,
+ as documented.
+
Bindings Changes:
* PHP bindings have been added.
@@ -240,10 +242,6 @@
Library Changes:
- * The count_max member of the gd_entry_t object has been renamed to period.
- The corresponding dummy argument in various function prototypes has been
- similarly renamed.
-
* BUG FIX: The library no longer incorrectly rejects negative count_val MPLEX
parameters. Furthermore, a count_val of -1 in gd_alter_entry or
gd_[m]alter_mplex calls is not a special value: it just sets count_val to
@@ -273,6 +271,12 @@
included with affixes is no longer corrupted by spurious application of the
affixes when the subfragment's metadata are (re-)written. Reported by Seth.
+ API Changes:
+
+ * The count_max member of the gd_entry_t object has been renamed to period.
+ The corresponding dummy argument in various function prototypes has been
+ similarly renamed.
+
Bindings Changes:
* C++: The Entry and MplexEntry member functions CountMax and SetCountMax have
@@ -340,6 +344,9 @@
Library Changes:
+ * gd_dirfilename() now returns a fully canonicalised version of the dirfile
+ path.
+
* BUG FIX: A segfault when negotiating symbolic links in file paths, typically
manifesting in gd_open calls, has been fixed.
@@ -358,6 +365,13 @@
the current Standards Version, potentially leading to rejected valid
dirfiles. Reported by Daniel Flanigan.
+ * BUG FIX: gd_alter_entry() and gd_madd_alias() weren't clearing the Dirfile
+ error before operation, resulting in them failing erroneously in certain
+ situations.
+
+ * BUG FIX: When including an existing fragment which itself has subfragments,
+ gd_include() no longer returns the wrong fragment index.
+
* WIN32 BUG FIX: On Windows, the parser can now properly handle hexadecimal
floating point.
@@ -368,21 +382,11 @@
suffix, if any, which should remove the need to do manual affix bookkeeping
when reading metadata. The other side to this change is that when modifying
metdata (gd_add(), gd_alter_entry(), &c.), supplied field codes must also
- contain the appropriate suffixes.
+ contain the appropriate affixes.
- * gd_dirfilename() now returns a fully canonicalised version of the dirfile
- path.
-
* A new function, gd_linterp_tablename() has been added which returns a fully
canonicalised version of the look-up table pathname for a LINTERP.
- * BUG FIX: gd_alter_entry() and gd_madd_alias() weren't clearing the Dirfile
- error before operation, resulting in them failing erroneously in certain
- situations.
-
- * BUG FIX: When including an existing fragment which itself has subfragments,
- gd_include() no longer returns the wrong fragment index.
-
Bindings Changes:
* F77 BUG FIX: A memory leak has been fixed in GDALLC.
@@ -537,6 +541,9 @@
documentation indicates it should) and checks the protection of the
fragment containing the parent field.
+ * BUG FIX: calling gd_putdata() with num_frames and num_samples both zero
+ no longer confuses GetData: instead it simply does nothing.
+
API Changes:
* Functions which add fields (gd_add(), gd_add_<type>(), &c.) can now be
@@ -640,9 +647,6 @@
* C89 API: Passing NULL to gd_alter_crecip() for cdividend is now treated
as if it were passed zero (ie. it indicates no change for cdividend).
- * BUG FIX: calling gd_putdata() with num_frames and num_samples both zero
- no longer confuses GetData: instead it simply does nothing.
-
* BUG FIX: gd_spf() now returns GD_E_DIMENSION when passed a scalar field
code, as the documentation says it should. Previously it returned
GD_E_BAD_FIELD_TYPE.
@@ -799,6 +803,7 @@
Bindings Changes:
* F77 BUG FIX: A memory leak in GDASCA has been fixed.
+
* Python BUG FIX: The first element of a python list (instead of a NumPy
array) is no longer dropped when passed to pygetdata on 64-bit systems.
Modified: trunk/getdata/bindings/cxx/entry.cpp
===================================================================
--- trunk/getdata/bindings/cxx/entry.cpp 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/bindings/cxx/entry.cpp 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008-2012 D. V. Wiebe
+// Copyright (C) 2008-2012, 2014 D. V. Wiebe
//
///////////////////////////////////////////////////////////////////////////
//
@@ -31,7 +31,8 @@
Entry::Entry(const GetData::Dirfile *dirfile, const char* field_code)
{
D = dirfile;
- gd_entry(D->D, field_code, &E);
+ if (gd_entry(D->D, field_code, &E))
+ memset(&E, 0, sizeof(E));
}
Entry::~Entry()
@@ -101,6 +102,19 @@
if (E.field == NULL) {
E.field = strdup(new_name);
} else {
+ /* this buffer is used if E is a metafield, in which case we'll
+ * replace the subfield name in E.field with new_name. The length
+ * of the new code is
+ *
+ * strlen(E.field) - strlen(<subfield-name>) + strlen(new_name)
+ * + 1 (for the trailing NUL).
+ *
+ * The subfield name in E.field must be at least one character long, so
+ * the length of the new code is at most:
+ *
+ * strlen(E.field) - 1 + strlen(new_name) + 1
+ * = strlen(E.field) + strlen(new_name)
+ */
char* nn = (char*)malloc(strlen(E.field) + strlen(new_name));
strcpy(nn, E.field);
ptr = strchr(nn, '/');
Modified: trunk/getdata/bindings/cxx/fragment.cpp
===================================================================
--- trunk/getdata/bindings/cxx/fragment.cpp 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/bindings/cxx/fragment.cpp 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2010, 2011 D. V. Wiebe
+// Copyright (C) 2008, 2010, 2011, 2014 D. V. Wiebe
//
///////////////////////////////////////////////////////////////////////////
//
@@ -35,8 +35,10 @@
prot = gd_protection(D->D, index);
name = gd_fragmentname(D->D, index);
parent = (index == 0) ? -1 : gd_parent_fragment(D->D, index);
- gd_fragment_affixes(D->D, index, &prefix, &suffix);
+ if (gd_fragment_affixes(D->D, index, &prefix, &suffix) == -1)
+ prefix = suffix = NULL;
+
dreturnvoid();
}
Modified: trunk/getdata/bindings/f77/fgetdata.c
===================================================================
--- trunk/getdata/bindings/f77/fgetdata.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/bindings/f77/fgetdata.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2013 D. V. Wiebe
+/* Copyright (C) 2008-2014 D. V. Wiebe
*
*************************************************************************
*
@@ -3142,7 +3142,10 @@
return;
}
- gd_entry(D, _GDF_CString(&fc, field_code, *field_code_l), &E);
+ if (gd_entry(D, _GDF_CString(&fc, field_code, *field_code_l), &E) == -1) {
+ dreturnvoid();
+ return;
+ }
switch (E.field_type) {
case GD_NO_ENTRY:
Modified: trunk/getdata/bindings/idl/getdata.c
===================================================================
--- trunk/getdata/bindings/idl/getdata.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/bindings/idl/getdata.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009-2013 D. V. Wiebe
+/* Copyright (C) 2009-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -5466,7 +5466,7 @@
{
dtraceidl();
- int nalias;
+ unsigned int nalias;
GDIDL_KW_ONLY_ERROR;
@@ -5479,7 +5479,7 @@
IDL_KW_FREE;
- IDL_VPTR r = IDL_GettmpLong(nalias);
+ IDL_VPTR r = IDL_GettmpUInt(nalias);
dreturn("%p", r);
return r;
}
Modified: trunk/getdata/bindings/make_parameters.c
===================================================================
--- trunk/getdata/bindings/make_parameters.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/bindings/make_parameters.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -470,7 +470,7 @@
printf("s/@PARAMLIST@/");
for (i = 0; constant_list[i].lname != NULL; ++i)
- printf("%s ", constant_list[i].sname, constant_list[i].value);
+ printf("%s ", constant_list[i].sname);
printf("/\n");
}
Modified: trunk/getdata/bindings/php/getdata.c
===================================================================
--- trunk/getdata/bindings/php/getdata.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/bindings/php/getdata.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2013 D. V. Wiebe
+/* Copyright (C) 2013, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -1560,6 +1560,7 @@
for (i = 0; i < n; ++i)
add_index_zval(a, i, gdphp_from_complex(NULL, ((float*)(data))[i * 2],
((float*)(data))[i * 2 + 1]));
+ break;
case GD_COMPLEX128:
for (i = 0; i < n; ++i)
add_index_zval(a, i, gdphp_from_complex(NULL, ((double*)(data))[i * 2],
@@ -3017,9 +3018,12 @@
s = gd_error_string(D, NULL, 0);
- RETVAL_STRING(s, 1);
- free(s);
- dreturn("\"%s\"", s);
+ if (s) {
+ RETVAL_STRING(s, 1);
+ dreturn("\"%s\"", s);
+ free(s);
+ } else
+ GDPHP_RETURN_F;
}
PHP_FUNCTION(gd_field_list)
Modified: trunk/getdata/bindings/python/pydirfile.c
===================================================================
--- trunk/getdata/bindings/python/pydirfile.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/bindings/python/pydirfile.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009-2013 D. V. Wiebe
+/* Copyright (C) 2009-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -728,6 +728,7 @@
const char *field_code;
struct gdpy_entry_t *obj;
gd_entry_t *E;
+ int e;
dtrace("%p, %p, %p", self, args, keys);
@@ -748,12 +749,20 @@
gd_entry(self->D, field_code, E);
- PYGD_CHECK_ERROR(self->D, NULL);
+ if ((e = gd_error(D))) {
+ PYGD_REPORT_ERROR(D,e);
+ gd_free_entry_strings(E);
+ free(E);
+ dreturn("%p", NULL);
+ return NULL;
+ }
obj = (struct gdpy_entry_t*)gdpy_entry.tp_alloc(&gdpy_entry, 0);
if (obj == NULL) {
PyErr_NoMemory();
+ gd_free_entry_strings(E);
+ free(E);
dreturn("%p", NULL);
return NULL;
}
@@ -1682,7 +1691,7 @@
gd_get_string(self->D, field_code, len, data);
- PYGD_CHECK_ERROR(self->D, NULL);
+ PYGD_CHECK_ERROR2(self->D, NULL, free(data));
pyobj = PyString_FromString(data);
@@ -1848,6 +1857,7 @@
if (type == GD_UNKNOWN) {
PyErr_SetString(PyExc_ValueError,
"pygetdata.dirfile.put_carray() unknown data type for argument 2.");
+ free(data);
dreturn ("%p", NULL);
return NULL;
}
@@ -1961,6 +1971,7 @@
if (type == GD_UNKNOWN) {
PyErr_SetString(PyExc_ValueError,
"pygetdata.dirfile.putdata() unknown data type for argument 2.");
+ free(data);
dreturn ("%p", NULL);
return NULL;
}
Modified: trunk/getdata/bindings/python/pyentry.c
===================================================================
--- trunk/getdata/bindings/python/pyentry.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/bindings/python/pyentry.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009-2013 D. V. Wiebe
+/* Copyright (C) 2009-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -1828,6 +1828,8 @@
PyObject *obj = PyTuple_GetItem(value, i);
if (PyComplex_Check(obj)) {
comp_scal = GD_EN_COMPSCAL;
+ gdpy_as_complex(gd_csp_(ca[i]), obj);
+ a[i] = creal(ca[i]);
scalar[i] = NULL;
} else if (comp_scal) {
gdpy_set_scalar_from_pyobj(obj, GD_COMPLEX128, scalar + i, ca + i);
Modified: trunk/getdata/bindings/python/pygetdata.h
===================================================================
--- trunk/getdata/bindings/python/pygetdata.h 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/bindings/python/pygetdata.h 2014-02-19 00:22:56 UTC (rev 877)
@@ -69,17 +69,26 @@
#define PYGD_CHECK_ERROR2(D,R,E) \
do { \
- int the_error; \
- if ((the_error = gd_error(D))) { \
- char buffer[GD_MAX_LINE_LENGTH]; \
- PyErr_SetString(gdpy_exceptions[the_error], gd_error_string((D), \
- buffer, GD_MAX_LINE_LENGTH)); \
+ int e; \
+ if ((e = gd_error(D))) { \
+ PYGD_REPORT_ERROR(D,e); \
E; \
dreturnvoid(); \
return (R); \
} \
} while(0)
+#define PYGD_REPORT_ERROR(D,e) \
+ do { \
+ char *buffer = gd_error_string((D), NULL, 0); \
+ if (buffer) { \
+ PyErr_SetString(gdpy_exceptions[e], buffer); \
+ free(buffer); \
+ } else \
+ PyErr_SetString(gdpy_exceptions[e], "Unspecified error"); \
+ } while (0)
+
+
extern PyObject *gdpy_exceptions[GD_N_ERROR_CODES];
extern PyTypeObject gdpy_dirfile;
extern PyTypeObject gdpy_entry;
Added: trunk/getdata/doc/cov_mod.c
===================================================================
--- trunk/getdata/doc/cov_mod.c (rev 0)
+++ trunk/getdata/doc/cov_mod.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -0,0 +1,87 @@
+/* This is the GetData model file for Coverity Scan. It provides hints to
+ * Coverity Scan's static code analysis.
+ *
+ * Although this looks like a C source file, it isn't meant to be compiled.
+ * Expect to see stack variables being used without initialisation.
+ */
+
+#define assert(...) /* */
+typedef struct {int error;} DIRFILE;
+typedef struct {} gd_entry_t;
+
+/* sets D->error to non-zero when it returns zero */
+unsigned int _GD_GetSPF(DIRFILE *D, gd_entry_t *E)
+{
+ unsigned int spf;
+
+ if (spf == 0) {
+ assert(D->error != 0);
+ }
+ return spf;
+}
+
+/* only allocates memory if supplied no buffer */
+char *gd_error_string(const DIRFILE *D, char *buffer, size_t buflen)
+{
+ if (buffer == 0)
+ __coverity_alloc__(buffer);
+
+ return buffer;
+}
+
+
+/* sets D->error to non-zero when it returns NULL */
+char *_GD_MungeFrag(DIRFILE *D, const gd_entry_t *P, int me, const char *code,
+ int *offset)
+{
+ char *new_code;
+ if (new_code == 0) {
+ assert(D->error != 0);
+ }
+ return new_code;
+}
+
+/* sets D->error to non-zero when it returns NULL */
+gd_entry_t *_GD_FindField(const DIRFILE *D, const char *field_code,
+ gd_entry_t *const *list, unsigned int u, int dealias, unsigned int *index)
+{
+ gd_entry_t *E;
+ if (E == 0) {
+ assert(D->error != 0);
+ }
+ return E;
+}
+
+/* either sets D->error to non-zero and returns NULL or else allocates memory */
+void *_GD_Malloc(DIRFILE *D, size_t size)
+{
+ void *ptr;
+
+ __coverity_alloc__(ptr);
+ if (ptr == 0) {
+ assert(D->error != 0);
+ }
+ return ptr;
+}
+
+/* When fdopendir returns non-NULL, it has stolen the descriptor */
+typedef struct {int fd} DIR;
+DIR *fdopendir(int fd)
+{
+ DIR *d;
+ if (d) {
+ d->fd = fd;
+ }
+ return d;
+}
+
+int closedir(DIR *d)
+{
+ __coverity_close__(d->fd);
+}
+
+/* doesn't return */
+void zend_error(int type, const char *format, ...)
+{
+ __coverity_panic__();
+}
Modified: trunk/getdata/src/add.c
===================================================================
--- trunk/getdata/src/add.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/add.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2013 D. V. Wiebe
+/* Copyright (C) 2008-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -2037,25 +2037,25 @@
offset = strlen(parent) + 1;
munged_code = (char *)_GD_Malloc(D, offset + strlen(field_code) + 1);
- if (munged_code) {
- strcpy(munged_code, parent);
- munged_code[offset - 1] = '/';
- strcpy(munged_code + offset, field_code);
- }
- } else
+ if (munged_code == NULL)
+ goto add_alias_error;
+
+ strcpy(munged_code, parent);
+ munged_code[offset - 1] = '/';
+ strcpy(munged_code + offset, field_code);
+ } else {
/* this will check for affixes and take care of detecting Barth-style
* metafield definitions */
P = _GD_FixName(D, &munged_code, field_code, fragment_index, &offset);
- if (D->error)
- goto add_alias_error;
+ if (D->error)
+ goto add_alias_error;
+ }
/* check alias name */
- if (munged_code && _GD_ValidateField(munged_code + offset, D->standards, 1, 0,
- NULL))
- {
+ if (_GD_ValidateField(munged_code + offset, D->standards, 1, 0, NULL))
_GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_INVALID, NULL, 0, field_code);
- } else if (_GD_FindField(D, munged_code, D->entry, D->n_entries, 1, &u))
+ else if (_GD_FindField(D, munged_code, D->entry, D->n_entries, 1, &u))
_GD_SetError(D, GD_E_DUPLICATE, 0, NULL, 0, munged_code);
else
_GD_CheckCodeAffixes(D, NULL, target, fragment_index, 1); /* check target */
Modified: trunk/getdata/src/bzip.c
===================================================================
--- trunk/getdata/src/bzip.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/bzip.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -268,9 +268,9 @@
ptr->pos = 0;
ptr->end = n;
} else {
- free(ptr);
BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile);
fclose(ptr->stream);
+ free(ptr);
dreturn("%i", -1);
return -1;
}
Modified: trunk/getdata/src/common.c
===================================================================
--- trunk/getdata/src/common.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/common.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,5 +1,5 @@
/* Copyright (C) 2002-2005 C. Barth Netterfield
- * Copyright (C) 2005-2013 D. V. Wiebe
+ * Copyright (C) 2005-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -1024,7 +1024,6 @@
work = (char*)malloc(PATH_MAX);
if (res == NULL || work == NULL) {
free(res);
- free(res);
dreturn("%p", NULL);
return NULL;
}
@@ -1164,7 +1163,7 @@
}
/* get the link target */
- slen = readlink(res, target, PATH_MAX);
+ slen = readlink(res, target, PATH_MAX - 1);
if (slen == -1) {
free(res);
free(work);
Modified: trunk/getdata/src/entry.c
===================================================================
--- trunk/getdata/src/entry.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/entry.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2013 D. V. Wiebe
+/* Copyright (C) 2008-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -127,7 +127,7 @@
free(entry);
} else {
entry->field = NULL;
- memset(entry->in_fields, 0, sizeof(char*) * GD_MAX_LINCOM * 2);
+ memset(entry->in_fields, 0, sizeof(char*) * GD_MAX_LINCOM);
memset(entry->scalar, 0, sizeof(char*) * GD_MAX_LINCOM * 2);
}
@@ -523,8 +523,8 @@
const char **gd_aliases(DIRFILE *D, const char *field_code) gd_nothrow
{
gd_entry_t *E;
- int n, j = 1;
- unsigned u;
+ int j = 1;
+ unsigned u, n;
dtrace("%p, \"%s\"", D, field_code);
@@ -573,26 +573,25 @@
return E->e->alias_list;
}
-int gd_naliases(DIRFILE *D, const char *field_code) gd_nothrow
+unsigned int gd_naliases(DIRFILE *D, const char *field_code) gd_nothrow
{
gd_entry_t *E;
- int n = 1;
- unsigned u;
+ unsigned u, n = 1;
dtrace("%p, \"%s\"", D, field_code);
if (D->flags & GD_INVALID) {
_GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL);
- dreturn("%i", -1);
- return -1;
+ dreturn("%u", 0);
+ return 0;
}
E = _GD_FindField(D, field_code, D->entry, D->n_entries, 1, NULL);
if (E == NULL) {
_GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_MISSING, NULL, 0, field_code);
- dreturn("%i", -1);
- return -1;
+ dreturn("%u", 0);
+ return 0;
}
for (u = 0; u < D->n_entries; ++u)
@@ -602,7 +601,7 @@
n++;
}
- dreturn("%i", n);
+ dreturn("%u", n);
return n;
}
@@ -870,7 +869,8 @@
free(field_code);
if (E->field_type != GD_LINTERP_ENTRY) {
- _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code);
+ _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0,
+ field_code_in);
dreturn("%p", NULL);
return NULL;
}
Modified: trunk/getdata/src/getdata.h.in
===================================================================
--- trunk/getdata/src/getdata.h.in 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/getdata.h.in 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,6 +1,6 @@
/* Copyright (C) 2002-2005 C. Barth Netterfield
* Copyright (C) 2003-2005 Theodore Kisner
- * Copyright (C) 2005-2013 D. V. Wiebe
+ * Copyright (C) 2005-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -855,8 +855,8 @@
extern const char *gd_dirfilename(DIRFILE *dirfile) gd_nothrow gd_nonnull ((1));
-extern int gd_naliases(DIRFILE *dirfile, const char *field_code) gd_nothrow
-gd_nonnull ((1,2));
+extern unsigned int gd_naliases(DIRFILE *dirfile,
+ const char *field_code) gd_nothrow gd_nonnull ((1,2));
extern gd_type_t gd_native_type(DIRFILE *dirfile,
const char *field_code) gd_nothrow gd_nonnull ((1,2));
@@ -921,7 +921,7 @@
gd_nonnull((1,2));
extern int gd_verbose_prefix(DIRFILE *D, const char *prefix) gd_nothrow
-gd_nonnull ((1,2));
+gd_nonnull ((1));
extern const char **gd_vector_list(DIRFILE *dirfile) gd_nothrow gd_nonnull((1));
Modified: trunk/getdata/src/gzip.c
===================================================================
--- trunk/getdata/src/gzip.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/gzip.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -45,11 +45,6 @@
if (mode & GD_FILE_READ) {
file->idata = gd_OpenAt(file->D, fd, file->name, O_RDONLY | O_BINARY, 0666);
-
- if (file->idata == -1) {
- dreturn("%i", 1);
- return 1;
- }
gzmode = "r";
} else if (mode & GD_FILE_TEMP) {
file->idata = _GD_MakeTempFile(file->D, fd, file->name);
@@ -59,6 +54,11 @@
return 1;
}
+ if (file->idata == -1) {
+ dreturn("%i", 1);
+ return 1;
+ }
+
file->edata = gzdopen(file->idata, gzmode);
if (file->edata == NULL) {
Modified: trunk/getdata/src/include.c
===================================================================
--- trunk/getdata/src/include.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/include.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2011 D. V. Wiebe
+/* Copyright (C) 2008-2011, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -197,6 +197,7 @@
ptr = _GD_Realloc(D, D->fragment,
(++D->n_fragment) * sizeof(struct gd_fragment_t));
if (ptr == NULL) {
+ fclose(new_fp);
_GD_ReleaseDir(D, dirfd);
D->n_fragment--;
goto include_error;
Modified: trunk/getdata/src/lzma.c
===================================================================
--- trunk/getdata/src/lzma.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/lzma.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -110,11 +110,9 @@
int _GD_LzmaOpen(int dirfd, struct gd_raw_file_* file, int swap gd_unused_,
unsigned int mode gd_unused_)
{
- struct gd_lzmadata *ptr;
-
dtrace("%i, %p, <unused>, <unused>", dirfd, file);
- file->edata = ptr = _GD_LzmaDoOpen(dirfd, file);
+ file->edata = _GD_LzmaDoOpen(dirfd, file);
if (file->edata == NULL) {
dreturn("%i", 1);
Modified: trunk/getdata/src/mod.c
===================================================================
--- trunk/getdata/src/mod.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/mod.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -112,8 +112,6 @@
*(int32_t *)lout = *(int32_t *)lin;
else if (type == GD_UINT32)
*(uint32_t *)lout = *(uint32_t *)lin;
- else if (type == GD_INT64)
- *(int64_t *)lout = *(int64_t *)lin;
else if (type == GD_UINT64)
*(uint64_t *)lout = *(uint64_t *)lin;
else
Modified: trunk/getdata/src/name.c
===================================================================
--- trunk/getdata/src/name.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/name.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2013 D. V. Wiebe
+/* Copyright (C) 2008-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -694,6 +694,7 @@
* fails */
rdat->meta_name = (char**)_GD_Malloc(D, sizeof(char *) * rdat->n_meta);
if (!rdat->meta_name) {
+ _GD_CleanUpRename(rdat, 1);
dreturn("%p", NULL);
return NULL;
}
Modified: trunk/getdata/src/open.c
===================================================================
--- trunk/getdata/src/open.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/open.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -347,6 +347,10 @@
_GD_SetError(D, GD_E_CREAT, GD_E_CREAT_FORMAT, format_file, errno, NULL);
free(dirfile);
free(format_file);
+#ifndef GD_NO_DIR_OPEN
+ if (dirfd >= 0)
+ close(dirfd);
+#endif
dreturn("%p", NULL);
return NULL;
}
@@ -364,6 +368,10 @@
free(dirfile);
free(format_file);
close(fd);
+#ifndef GD_NO_DIR_OPEN
+ if (dirfd >= 0)
+ close(dirfd);
+#endif
dreturn("%p", NULL);
return NULL;
}
@@ -459,7 +467,8 @@
if (D == NULL) {
free(dirfile);
#ifndef GD_NO_DIR_OPEN
- close(dirfd);
+ if (dirfd >= 0)
+ close(dirfd);
#endif
dreturn("%p", NULL);
return NULL;
@@ -482,7 +491,8 @@
if (dirfile == NULL) {
_GD_SetError(D, GD_E_OPEN, GD_E_OPEN_IO, filedir, dirfd_error, NULL);
#ifndef GD_NO_DIR_OPEN
- close(dirfd);
+ if (dirfd >= 0)
+ close(dirfd);
#endif
dreturn("%p", D);
return D;
@@ -524,7 +534,8 @@
if ((fp = _GD_CreateDirfile(D, dirfd, dirfd_error, dirfile, &mtime)) == NULL)
{
#ifndef GD_NO_DIR_OPEN
- close(dirfd);
+ if (dirfd >= 0)
+ close(dirfd);
#endif
D->name = NULL; /* so a subsequent gd_discard() doesn't go awry. */
dreturn("%p", D);
@@ -536,6 +547,7 @@
D->name = strdup(filedir);
if (D->name == NULL) {
+ fclose(fp);
_GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL);
dreturn("%p", D);
return D;
Modified: trunk/getdata/src/parse.c
===================================================================
--- trunk/getdata/src/parse.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/parse.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,5 +1,5 @@
/* Copyright (C) 2002-2005 C. Barth Netterfield
- * Copyright (C) 2005-2013 D. V. Wiebe
+ * Copyright (C) 2005-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -1335,6 +1335,8 @@
_GD_FreeE(D, E, 1);
_GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line,
in_cols[c]);
+ dreturn("%p", NULL);
+ return NULL;
}
}
@@ -1626,15 +1628,6 @@
_GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_BAD_LINE, format_file, linenum,
NULL);
- if (is_dot) {
- ptr = _GD_Realloc(D, D->dot_list, (D->n_dot + 1) * sizeof(gd_entry_t*));
- if (ptr == NULL) {
- dreturn ("%p", NULL);
- return NULL;
- }
- D->dot_list = (gd_entry_t **)ptr;
- }
-
if (insert && D->error == GD_E_OK && E != NULL) {
/* the Format file fragment index */
unsigned int u;
@@ -1651,6 +1644,16 @@
return NULL;
}
+ if (is_dot) {
+ ptr = _GD_Realloc(D, D->dot_list, (D->n_dot + 1) * sizeof(gd_entry_t*));
+ if (ptr == NULL) {
+ _GD_FreeE(D, E, 1);
+ dreturn ("%p", NULL);
+ return NULL;
+ }
+ D->dot_list = (gd_entry_t **)ptr;
+ }
+
/* Initialse the meta counts */
if (P != NULL) {
E->e->n_meta = -1;
@@ -1663,6 +1666,9 @@
dreturn ("%p", NULL);
return NULL;
}
+
+ /* Nothing may fail from now on */
+
P->e->p.meta_entry = (gd_entry_t **)ptr;
P->e->p.meta_entry[P->e->n_meta++] = E;
}
Modified: trunk/getdata/src/putdata.c
===================================================================
--- trunk/getdata/src/putdata.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/putdata.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,6 +1,6 @@
/* Copyright (C) 2003-2005 C. Barth Netterfield
* Copyright (C) 2003-2005 Theodore Kisner
- * Copyright (C) 2005-2013 D. V. Wiebe
+ * Copyright (C) 2005-2014 D. V. Wiebe
*
***************************************************************************
*
@@ -574,6 +574,7 @@
cntbuf = (int*)_GD_Alloc(D, GD_INT_TYPE, num_samp2);
if (tmpbuf == NULL || cntbuf == NULL) {
+ free(cntbuf);
free(tmpbuf);
dreturn("%i", 0);
return 0;
Modified: trunk/getdata/src/sie.c
===================================================================
--- trunk/getdata/src/sie.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/sie.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -335,7 +335,7 @@
f->p += nelem - count;
count = nelem;
} else {
- cur = _GD_Duplicate(cur, f->d + 1, GD_SIZE(data_type), f->s - f->p + 1);
+ _GD_Duplicate(cur, f->d + 1, GD_SIZE(data_type), f->s - f->p + 1);
count += f->s - f->p + 1;
f->p = f->s + 1;
}
@@ -569,6 +569,7 @@
/* truncate the file if necessary */
if (rin < rout) {
if (gd_truncate(fileno(f->fp), (nrec - rout + rin) * size)) {
+ free(p);
dreturn("%i", -1);
return -1;
}
Modified: trunk/getdata/src/types.c
===================================================================
--- trunk/getdata/src/types.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/src/types.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,5 +1,5 @@
/* Copyright (C) 2002-2005 C. Barth Netterfield
- * Copyright (C) 2005-2010 D. V. Wiebe
+ * Copyright (C) 2005-2010, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -633,6 +633,7 @@
_GD_SetError(D, GD_E_BAD_TYPE, out_type, NULL, 0, NULL);
break;
}
+ break;
case GD_COMPLEX128:
switch (out_type) {
case GD_INT8:
Modified: trunk/getdata/test/add_alias.c
===================================================================
--- trunk/getdata/test/add_alias.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/add_alias.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 D. V. Wiebe
+/* Copyright (C) 2011, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -26,7 +26,8 @@
const char *format = "dirfile/format";
const char *data = "dirfile/data";
const char *target;
- int error, i, n, r = 0;
+ int error, i, r = 0;
+ unsigned int n;
DIRFILE *D;
rmdirfile();
@@ -51,7 +52,7 @@
CHECKI(error, GD_E_OK);
CHECKI(i, 0);
- CHECKI(n, 2);
+ CHECKU(n, 2);
return r;
}
Modified: trunk/getdata/test/add_alias_affix.c
===================================================================
--- trunk/getdata/test/add_alias_affix.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/add_alias_affix.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012 D. V. Wiebe
+/* Copyright (C) 2012, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -27,7 +27,8 @@
const char *format1 = "dirfile/format";
const char *data = "dirfile/data";
const char *target;
- int e1, e2, e3, i, n, r = 0;
+ int e1, e2, e3, i, r = 0;
+ unsigned int n;
DIRFILE *D;
rmdirfile();
@@ -60,7 +61,7 @@
CHECKI(e2, GD_E_BAD_CODE);
CHECKI(e3, GD_E_OK);
CHECKI(i, 1);
- CHECKI(n, 2);
+ CHECKU(n, 2);
return r;
}
Modified: trunk/getdata/test/add_alias_meta.c
===================================================================
--- trunk/getdata/test/add_alias_meta.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/add_alias_meta.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012 D. V. Wiebe
+/* Copyright (C) 2012, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -26,8 +26,9 @@
const char *format = "dirfile/format";
const char *data = "dirfile/data";
const char *target;
- int error, i, n, r = 0;
+ int error, i, r = 0;
DIRFILE *D;
+ unsigned int n;
rmdirfile();
@@ -51,7 +52,7 @@
CHECKI(error, GD_E_OK);
CHECKI(i, 0);
- CHECKI(n, 2);
+ CHECKU(n, 2);
return r;
}
Modified: trunk/getdata/test/add_resolv.c
===================================================================
--- trunk/getdata/test/add_resolv.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/add_resolv.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 D. V. Wiebe
+/* Copyright (C) 2011, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -25,7 +25,8 @@
const char *filedir = "dirfile";
const char *format = "dirfile/format";
const char *data = "dirfile/data";
- int error, i, n, r = 0;
+ int error, i, r = 0;
+ unsigned int n;
DIRFILE *D;
const char *target;
@@ -51,7 +52,7 @@
CHECKI(error, GD_E_OK);
CHECKI(i, 0);
- CHECKI(n, 2);
+ CHECKU(n, 2);
return r;
}
Modified: trunk/getdata/test/add_spec_resolv.c
===================================================================
--- trunk/getdata/test/add_spec_resolv.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/add_spec_resolv.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 D. V. Wiebe
+/* Copyright (C) 2011, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -25,7 +25,8 @@
const char *filedir = "dirfile";
const char *format = "dirfile/format";
const char *data = "dirfile/data";
- int error, i, n, r = 0;
+ int error, i, r = 0;
+ unsigned int n;
DIRFILE *D;
const char *target;
@@ -51,7 +52,7 @@
CHECKI(error, GD_E_OK);
CHECKI(i, 0);
- CHECKI(n, 2);
+ CHECKU(n, 2);
return r;
}
Modified: trunk/getdata/test/alias_num.c
===================================================================
--- trunk/getdata/test/alias_num.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/alias_num.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011, 2013 D. V. Wiebe
+/* Copyright (C) 2011, 2013, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -31,7 +31,8 @@
"/ALIAS c d\n"
"/ALIAS d f\n"
"f CONST UINT8 1\n";
- int fd, e, n, r = 0;
+ int fd, e, r = 0;
+ unsigned int n;
DIRFILE *D;
rmdirfile();
@@ -47,7 +48,7 @@
e = gd_error(D);
CHECKI(e, GD_E_OK);
- CHECKI(n, 6);
+ CHECKU(n, 6);
gd_discard(D);
unlink(format);
Modified: trunk/getdata/test/alias_num_alias.c
===================================================================
--- trunk/getdata/test/alias_num_alias.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/alias_num_alias.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011, 2013 D. V. Wiebe
+/* Copyright (C) 2011, 2013, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -31,7 +31,8 @@
"/ALIAS c d\n"
"/ALIAS d f\n"
"f CONST UINT8 1\n";
- int fd, e, n, r = 0;
+ int fd, e, r = 0;
+ unsigned int n;
DIRFILE *D;
rmdirfile();
@@ -47,7 +48,7 @@
e = gd_error(D);
CHECKI(e, GD_E_OK);
- CHECKI(n, 6);
+ CHECKU(n, 6);
gd_discard(D);
unlink(format);
Modified: trunk/getdata/test/alias_num_missing.c
===================================================================
--- trunk/getdata/test/alias_num_missing.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/alias_num_missing.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011, 2013 D. V. Wiebe
+/* Copyright (C) 2011, 2013, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -30,7 +30,8 @@
"/ALIAS b d\n"
"/ALIAS c d\n"
"/ALIAS d f\n";
- int fd, e, n, r = 0;
+ int fd, e, r = 0;
+ unsigned n;
DIRFILE *D;
rmdirfile();
@@ -46,7 +47,7 @@
e = gd_error(D);
CHECKI(e, GD_E_BAD_CODE);
- CHECKI(n, -1);
+ CHECKU(n, 0);
gd_discard(D);
unlink(format);
Modified: trunk/getdata/test/madd_alias.c
===================================================================
--- trunk/getdata/test/madd_alias.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/madd_alias.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 D. V. Wiebe
+/* Copyright (C) 2011, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -25,8 +25,9 @@
const char *filedir = "dirfile";
const char *format = "dirfile/format";
const char *data = "dirfile/data";
- int error, i, n, r = 0;
+ int error, i, r = 0;
DIRFILE *D;
+ unsigned int n;
const char *target;
rmdirfile();
@@ -51,7 +52,7 @@
CHECKI(error, GD_E_OK);
CHECKI(i, 0);
- CHECKI(n, 2);
+ CHECKU(n, 2);
return r;
}
Modified: trunk/getdata/test/madd_alias_affix.c
===================================================================
--- trunk/getdata/test/madd_alias_affix.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/madd_alias_affix.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012 D. V. Wiebe
+/* Copyright (C) 2012, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -27,7 +27,8 @@
const char *format1 = "dirfile/format";
const char *data = "dirfile/data";
const char *target1, *target2;
- int e1, e2, e3, e4, e5, i, n, r = 0;
+ int e1, e2, e3, e4, e5, i, r = 0;
+ unsigned int n;
DIRFILE *D;
rmdirfile();
@@ -69,7 +70,7 @@
CHECKI(e4, GD_E_OK);
CHECKI(e5, GD_E_OK);
CHECKI(i, 1);
- CHECKI(n, 4);
+ CHECKU(n, 4);
return r;
}
Modified: trunk/getdata/test/madd_spec_resolv.c
===================================================================
--- trunk/getdata/test/madd_spec_resolv.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/test/madd_spec_resolv.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 D. V. Wiebe
+/* Copyright (C) 2011, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -25,7 +25,8 @@
const char *filedir = "dirfile";
const char *format = "dirfile/format";
const char *data = "dirfile/data";
- int error, i, n, r = 0;
+ int error, i, r = 0;
+ unsigned int n;
DIRFILE *D;
const char *target;
@@ -52,7 +53,7 @@
CHECKI(error, GD_E_OK);
CHECKI(i, 0);
- CHECKI(n, 2);
+ CHECKU(n, 2);
return r;
}
Modified: trunk/getdata/util/checkdirfile.c
===================================================================
--- trunk/getdata/util/checkdirfile.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/util/checkdirfile.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -82,7 +82,8 @@
return 1;
}
- /* open the dirfile */
+ /* open the dirfile -- the callback will print syntax errors as
+ * found, and return the number of lines with errors in ne. */
puts("Checking syntax...");
dirfile = gd_cbopen(argv[1], GD_RDONLY, callback, &ne);
@@ -107,6 +108,10 @@
printf(" Syntax OK.\n\n");
+ /* Run through every known standards version and check whether the dirfile
+ * is conformant by trying to set the loaded dirfile's version to that
+ * value
+ */
for (i = 0; i <= GD_DIRFILE_STANDARDS_VERSION; ++i) {
if (gd_dirfile_standards(dirfile, i) == i) {
vers[i] = 1;
@@ -121,6 +126,7 @@
printf("Dirfile conforms to Standards %s ",
(nvers == 1) ? "Version" : "Versions");
+ /* pretty-print the list of conformed versions */
for (i = 0; i <= GD_DIRFILE_STANDARDS_VERSION; ++i) {
if (vers[i]) {
if (first == -1)
@@ -161,7 +167,7 @@
}
- /* Check the validity of each field defined */
+ /* Check the validity of each entry defined */
ne = 0;
puts("\nChecking fields...");
flist = gd_entry_list(dirfile, NULL, 0, GD_ENTRIES_HIDDEN |
@@ -186,6 +192,8 @@
nfields++;
}
+ /* ferret out dangling meta ALIASes by first collecting a list
+ * of all of them, and then trying to use them as field codes */
mflist = gd_entry_list(dirfile, flist[i], GD_ALIAS_ENTRIES,
GD_ENTRIES_HIDDEN);
for (j = 0; mflist[j] != NULL; ++j) {
@@ -205,7 +213,8 @@
}
}
- /* look for dangling aliases */
+ /* ferret out dangling ALIASes by first collecting a list
+ * of all of them, and then trying to use them as field codes */
flist = gd_entry_list(dirfile, NULL, GD_ALIAS_ENTRIES, GD_ENTRIES_HIDDEN);
for (i = 0; flist[i] != NULL; ++i) {
if (gd_entry_type(dirfile, flist[i]) == GD_NO_ENTRY) {
Modified: trunk/getdata/util/dirfile2ascii.c
===================================================================
--- trunk/getdata/util/dirfile2ascii.c 2014-02-13 21:26:18 UTC (rev 876)
+++ trunk/getdata/util/dirfile2ascii.c 2014-02-19 00:22:56 UTC (rev 877)
@@ -1,5 +1,5 @@
/* Copyright (C) 2010, 2011 Matthew Truch
- * Copyright (C) 2010 D. V. Wiebe
+ * Copyright (C) 2010, 2014 D. V. Wiebe
*
***************************************************************************
*
@@ -61,7 +61,7 @@
void version(void)
{
printf("dirfile2ascii (%s)\n"
- "Copyright (C) 2010 Matthew Truch\n\n"
+ "Copyright (C) 2010, 2011, 2014 Matthew Truch and others\n\n"
"Please send reports of bugs and other communication to:\n %s\n\n"
"This program comes with NO WARRANTY, not even for MERCHANTABILITY "
"or FITNESS\n"
@@ -236,7 +236,7 @@
if (dirfile_name == NULL) {
dirfile_name = optarg;
} else { /* Standard output field */
- if (numfields > BUF_LEN) {
+ if (numfields >= BUF_LEN) {
fprintf(stderr, "Error: Too many fields!\n");
exit(-2);
}
@@ -260,7 +260,7 @@
case 'F':
case 'A':
case 'a':
- if (numfields > BUF_LEN) {
+ if (numfields >= BUF_LEN) {
fprintf(stderr, "Error: Too many fields!\n");
exit(-2);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|