r22071 - gnucash/trunk/src/libqof/qof - Remove obsolete strspn() call that causes valgrind warnings about invalid read().

Christian Stimming cstim at code.gnucash.org
Thu Mar 8 17:47:59 EST 2012


Author: cstim
Date: 2012-03-08 17:47:59 -0500 (Thu, 08 Mar 2012)
New Revision: 22071
Trac: http://svn.gnucash.org/trac/changeset/22071

Modified:
   gnucash/trunk/src/libqof/qof/gnc-numeric.c
Log:
Remove obsolete strspn() call that causes valgrind warnings about invalid read().

The strspn() call was added in r8500 but the usage of its return value
was removed in r10315, so it isn't neccesary anyway.

The macro GNC_DEPRECATED is defined nowhere and used nowhere else, so
we can remove that block altogether.

Modified: gnucash/trunk/src/libqof/qof/gnc-numeric.c
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-numeric.c	2012-03-08 21:20:07 UTC (rev 22070)
+++ gnucash/trunk/src/libqof/qof/gnc-numeric.c	2012-03-08 22:47:59 UTC (rev 22071)
@@ -1381,27 +1381,17 @@
 gboolean
 string_to_gnc_numeric(const gchar* str, gnc_numeric *n)
 {
-    size_t num_read;
     gint64 tmpnum;
     gint64 tmpdenom;
 
     if (!str) return FALSE;
 
-#ifdef GNC_DEPRECATED
-    /* must use "<" here because %n's effects aren't well defined */
-    if (sscanf(str, " " QOF_SCANF_LLD "/" QOF_SCANF_LLD "%n",
-               &tmpnum, &tmpdenom, &num_read) < 2)
-    {
-        return FALSE;
-    }
-#else
     tmpnum = g_ascii_strtoll (str, NULL, 0);
     str = strchr (str, '/');
     if (!str) return FALSE;
     str ++;
     tmpdenom = g_ascii_strtoll (str, NULL, 0);
-    num_read = strspn (str, "0123456789");
-#endif
+
     n->num = tmpnum;
     n->denom = tmpdenom;
     return TRUE;



More information about the gnucash-changes mailing list