r22021 - gnucash/trunk/src/engine - Fix "'txn' may be used uninitialized in this function" warning

Geert Janssens gjanssens at code.gnucash.org
Mon Feb 13 10:47:43 EST 2012


Author: gjanssens
Date: 2012-02-13 10:47:43 -0500 (Mon, 13 Feb 2012)
New Revision: 22021
Trac: http://svn.gnucash.org/trac/changeset/22021

Modified:
   gnucash/trunk/src/engine/gncOwner.c
Log:
Fix "'txn' may be used uninitialized in this function" warning

Modified: gnucash/trunk/src/engine/gncOwner.c
===================================================================
--- gnucash/trunk/src/engine/gncOwner.c	2012-02-13 15:22:21 UTC (rev 22020)
+++ gnucash/trunk/src/engine/gncOwner.c	2012-02-13 15:47:43 UTC (rev 22021)
@@ -871,10 +871,9 @@
         Account *acct;
         const gchar *name;
         GList *lot_list, *lot_iter;
-        Transaction *txn;
+        Transaction *txn = NULL;
         gnc_numeric base_lot_bal, val_to_pay, val_paid = { 0, 1 };
         gboolean base_bal_is_pos;
-        gboolean txn_created = FALSE;
         const gchar *action, *memo;
 
         /* Only attempt to apply payments to open lots.
@@ -957,7 +956,7 @@
 
             /* If not created yet, create a new transaction linking
              * the base lot and the balancing lot(s) */
-            if (!txn_created)
+            if (!txn)
             {
                 Timespec ts = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_latest_split (base_lot)));
 
@@ -971,7 +970,6 @@
                 xaccTransSetDateEnteredSecs (txn, time(NULL));
                 xaccTransSetDatePostedTS (txn, &ts);
                 xaccTransSetTxnType (txn, TXN_TYPE_LINK);
-                txn_created = TRUE;
             }
 
             /* Create the split for this link in current balancing lot */
@@ -1000,7 +998,7 @@
 
         /* If the above loop managed to create a transaction and some balancing splits,
          * create the final split for the link transaction in the base lot */
-        if (txn_created)
+        if (txn)
         {
             GncInvoice *this_invoice;
             Split *split = xaccMallocSplit (book);



More information about the gnucash-changes mailing list