r17983 - gnucash/trunk - Fix lots of splint issues (including memory leaks). This includes some changes
Phil Longstaff
plongstaff at cvs.gnucash.org
Mon Mar 9 13:17:59 EDT 2009
Author: plongstaff
Date: 2009-03-09 13:17:57 -0400 (Mon, 09 Mar 2009)
New Revision: 17983
Trac: http://svn.gnucash.org/trac/changeset/17983
Added:
gnucash/trunk/splint-defs.h
gnucash/trunk/src/backend/dbi/.splintrc
gnucash/trunk/src/backend/sql/.splintrc
Modified:
gnucash/trunk/lib/libqof/qof/guid.h
gnucash/trunk/lib/libqof/qof/kvp_frame.h
gnucash/trunk/lib/libqof/qof/qofbackend-p.h
gnucash/trunk/lib/libqof/qof/qofbackend.h
gnucash/trunk/lib/libqof/qof/qofbook.h
gnucash/trunk/lib/libqof/qof/qofclass.h
gnucash/trunk/lib/libqof/qof/qofid.h
gnucash/trunk/lib/libqof/qof/qofinstance.h
gnucash/trunk/lib/libqof/qof/qoflog.h
gnucash/trunk/lib/libqof/qof/qofobject.h
gnucash/trunk/lib/libqof/qof/qofquery-p.h
gnucash/trunk/lib/libqof/qof/qofquery.h
gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
gnucash/trunk/src/backend/dbi/gncmod-backend-dbi.c
gnucash/trunk/src/backend/sql/gnc-account-sql.c
gnucash/trunk/src/backend/sql/gnc-backend-sql.c
gnucash/trunk/src/backend/sql/gnc-backend-sql.h
gnucash/trunk/src/backend/sql/gnc-book-sql.c
gnucash/trunk/src/backend/sql/gnc-budget-sql.c
gnucash/trunk/src/backend/sql/gnc-commodity-sql.c
gnucash/trunk/src/backend/sql/gnc-lots-sql.c
gnucash/trunk/src/backend/sql/gnc-price-sql.c
gnucash/trunk/src/backend/sql/gnc-recurrence-sql.c
gnucash/trunk/src/backend/sql/gnc-recurrence-sql.h
gnucash/trunk/src/backend/sql/gnc-schedxaction-sql.c
gnucash/trunk/src/backend/sql/gnc-slots-sql.c
gnucash/trunk/src/backend/sql/gnc-transaction-sql.c
gnucash/trunk/src/backend/sql/gnc-transaction-sql.h
gnucash/trunk/src/core-utils/gnc-gconf-utils.h
gnucash/trunk/src/engine/Account.h
gnucash/trunk/src/engine/SX-book.h
gnucash/trunk/src/engine/SchedXaction.h
gnucash/trunk/src/engine/Transaction.h
gnucash/trunk/src/engine/gnc-budget.h
gnucash/trunk/src/engine/gnc-commodity.h
gnucash/trunk/src/engine/gnc-lot.h
gnucash/trunk/src/engine/gnc-pricedb.h
gnucash/trunk/src/gnc-module/gnc-module.h
Log:
Fix lots of splint issues (including memory leaks). This includes some changes
in qof and gnc files adding annotation comments to help splint analyze ownership
of memory and objects.
Modified: gnucash/trunk/lib/libqof/qof/guid.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/guid.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/guid.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -183,7 +183,7 @@
*
* @return A pointer to the terminating null character of the string.
*/
-gchar * guid_to_string_buff (const GUID * guid, gchar *buff);
+gchar * guid_to_string_buff (const GUID * guid, /*@ out @*/ gchar *buff);
/** Given a string, decode the id into the guid if guid is non-NULL.
@@ -191,7 +191,7 @@
* hexadecimal number. This function accepts both upper and lower case
* hex digits. If the return value is FALSE, the effect on guid is
* undefined. */
-gboolean string_to_guid(const gchar * string, GUID * guid);
+gboolean string_to_guid(const gchar * string, /*@ out @*/ GUID * guid);
/** Given two GUIDs, return TRUE if they are non-NULL and equal.
Modified: gnucash/trunk/lib/libqof/qof/kvp_frame.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/kvp_frame.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/kvp_frame.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -373,7 +373,7 @@
* @return The KvpFrame at the specified path, or NULL if it doesn't
* exist.
*/
-KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path);
+/*@ dependent @*/ KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path);
/** This routine returns the last frame of the path.
* If the frame path doesn't exist, it is created.
@@ -641,7 +641,7 @@
/** Value accessor. This one is non-copying -- the caller can modify
* the value directly. */
-KvpFrame * kvp_value_get_frame(const KvpValue * value);
+/*@ dependent @*/ KvpFrame * kvp_value_get_frame(const KvpValue * value);
Timespec kvp_value_get_timespec(const KvpValue * value);
/**
Modified: gnucash/trunk/lib/libqof/qof/qofbackend-p.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofbackend-p.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qofbackend-p.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -241,12 +241,12 @@
struct QofBackendProvider_s
{
/** Some arbitrary name given for this particular backend provider */
- const char * provider_name;
+ /*@ observer @*/ const char * provider_name;
/** The access method that this provider provides, for example,
* file:// http:// postgres:// or sqlite://, but without the :// at the end
*/
- const char * access_method;
+ /*@ observer @*/ const char * access_method;
/** \brief Partial QofBook handler
@@ -277,10 +277,10 @@
types match the incoming data. The backend should not assume that
returning TRUE will mean that the data will naturally follow.
*/
- gboolean (*check_data_type) (const char*);
+ /*@ null @*/ gboolean (*check_data_type) (const char*);
/** Free this structure, unregister this backend handler. */
- void (*provider_free) (QofBackendProvider *);
+ void (*provider_free) (/*@ only @*/ QofBackendProvider *);
};
typedef enum {
@@ -296,9 +296,9 @@
gboolean ignore_lock,
gboolean create_if_nonexistent);
void (*session_end) (QofBackend *);
- void (*destroy_backend) (QofBackend *);
+ void (*destroy_backend) (/*@ only @*/ QofBackend *);
- void (*load) (QofBackend *, QofBook *, QofBackendLoadType);
+ void (*load) (QofBackend *, /*@ dependent @*/ QofBook *, QofBackendLoadType);
void (*begin) (QofBackend *, QofInstance *);
void (*commit) (QofBackend *, QofInstance *);
@@ -308,9 +308,9 @@
void (*free_query) (QofBackend *, gpointer);
void (*run_query) (QofBackend *, gpointer);
- void (*sync) (QofBackend *, QofBook *);
+ void (*sync) (QofBackend *, /*@ dependent @*/ QofBook *);
void (*load_config) (QofBackend *, KvpFrame *);
- KvpFrame* (*get_config) (QofBackend *);
+ /*@ observer @*/ KvpFrame* (*get_config) (QofBackend *);
gint64 (*counter) (QofBackend *, const char *counter_name);
gboolean (*events_pending) (QofBackend *);
@@ -370,7 +370,7 @@
* backend library may register more than one provider, if it is
* capable of handling more than one URL access method.
*/
-void qof_backend_register_provider (QofBackendProvider *);
+void qof_backend_register_provider (/*@ only @*/ QofBackendProvider *);
/** The qof_backend_set_message() assigns a string to the backend error message.
*/
Modified: gnucash/trunk/lib/libqof/qof/qofbackend.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofbackend.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qofbackend.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -158,7 +158,7 @@
typedef struct QofBackend_s QofBackend;
/** \brief DOCUMENT ME! */
-typedef void (*QofBePercentageFunc) (const char *message, double percent);
+typedef void (*QofBePercentageFunc) (/*@ null @*/ const char *message, double percent);
/** @name Allow access to the begin routine for this backend. */
//@{
Modified: gnucash/trunk/lib/libqof/qof/qofbook.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofbook.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qofbook.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -175,7 +175,7 @@
* a non-NULL value. (Unless the system malloc failed (out of
* memory) in which case what happens??).
*/
-QofCollection * qof_book_get_collection (const QofBook *, QofIdType);
+/*@ dependent @*/ QofCollection * qof_book_get_collection (const QofBook *, QofIdType);
/** Invoke the indicated callback on each collection in the book. */
typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);
Modified: gnucash/trunk/lib/libqof/qof/qofclass.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofclass.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qofclass.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -142,14 +142,14 @@
* also provides a place for the user to hang additional user-defined
* data.
*/
-typedef gpointer (*QofAccessFunc)(gpointer object, const QofParam *param);
+typedef gpointer (*QofAccessFunc)(gpointer object, /*@ null @*/ const QofParam *param);
/** The QofSetterFunc defines an function pointer for parameter
* setters. Real functions must be of the form:
*
* void setter_func (object_type *self, param_type *param);
*/
-typedef void (*QofSetterFunc) (gpointer, gpointer);
+typedef void (*QofSetterFunc) (gpointer, /*@ null @*/ gpointer);
/* A callback for how to compare two (same-type) objects based on a
* common getter (parameter member), using the provided comparison
Modified: gnucash/trunk/lib/libqof/qof/qofid.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofid.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qofid.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -168,7 +168,7 @@
QofIdType qof_collection_get_type (const QofCollection *);
/** Find the entity going only from its guid */
-QofInstance * qof_collection_lookup_entity (const QofCollection *, const GUID *);
+/*@ dependent @*/ QofInstance * qof_collection_lookup_entity (const QofCollection *, const GUID *);
/** Callback type for qof_collection_foreach */
typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
Modified: gnucash/trunk/lib/libqof/qof/qofinstance.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofinstance.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qofinstance.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -87,7 +87,7 @@
void qof_instance_init_data (QofInstance *, QofIdType, QofBook *);
/** Return the book pointer */
-QofBook *qof_instance_get_book (gconstpointer);
+/*@ dependent @*/ QofBook *qof_instance_get_book (gconstpointer);
/** Set the book pointer */
void qof_instance_set_book (gconstpointer inst, QofBook *book);
@@ -99,14 +99,14 @@
gboolean qof_instance_books_equal (gconstpointer ptr1, gconstpointer ptr2);
/** Return the GUID of this instance */
-const GUID * qof_instance_get_guid (gconstpointer);
+/*@ dependent @*/ const GUID * qof_instance_get_guid (gconstpointer);
/** \deprecated Use qof_instance_get_guid instead.
* Works like qof_instance_get_guid, but returns NULL on NULL */
-const GUID * qof_entity_get_guid (gconstpointer);
+/*@ dependent @*/ const GUID * qof_entity_get_guid (gconstpointer);
/** Return the collection this instance belongs to */
-QofCollection* qof_instance_get_collection (gconstpointer inst);
+/*@ dependent @*/ QofCollection* qof_instance_get_collection (gconstpointer inst);
/** Set the GUID of this instance */
void qof_instance_set_guid (gpointer inst, const GUID *guid);
@@ -125,7 +125,7 @@
//void qof_instance_set_e_type (QofInstance *ent, QofIdType e_type);
/** Return the pointer to the kvp_data */
-KvpFrame* qof_instance_get_slots (const QofInstance *);
+/*@ dependent @*/ KvpFrame* qof_instance_get_slots (const QofInstance *);
/** Return the last time this instance was modified. If QofInstances
* are used with the QofObject storage backends, then the instance
Modified: gnucash/trunk/lib/libqof/qof/qoflog.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qoflog.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qoflog.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -199,7 +199,7 @@
/** Print a function entry debugging message */
#define ENTER(format, args...) do { \
- if (qof_log_check(log_module, G_LOG_LEVEL_DEBUG)) { \
+ if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[enter %s:%s()] " format, __FILE__, \
PRETTY_FUNC_NAME , ## args); \
@@ -221,7 +221,7 @@
/** Print a function exit debugging message. **/
#define LEAVE(format, args...) do { \
- if (qof_log_check(log_module, G_LOG_LEVEL_DEBUG)) { \
+ if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
qof_log_dedent(); \
g_log (log_module, G_LOG_LEVEL_DEBUG, \
"[leave %s()] " format, \
Modified: gnucash/trunk/lib/libqof/qof/qofobject.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofobject.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qofobject.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -167,7 +167,7 @@
const char *backend_name,
gpointer be_data);
-gpointer qof_object_lookup_backend (QofIdTypeConst type_name,
+/*@ dependent @*/ gpointer qof_object_lookup_backend (QofIdTypeConst type_name,
const char *backend_name);
void qof_object_foreach_backend (const char *backend_name,
Modified: gnucash/trunk/lib/libqof/qof/qofquery-p.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofquery-p.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qofquery-p.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -43,10 +43,10 @@
* Note that you should NOT modify this list in any way. It belongs
* to the query.
*/
-GList * qof_query_get_terms (const QofQuery *q);
+/*@ dependent @*/ GList * qof_query_get_terms (const QofQuery *q);
-GSList * qof_query_term_get_param_path (const QofQueryTerm *queryterm);
-QofQueryPredData *qof_query_term_get_pred_data (const QofQueryTerm *queryterm);
+/*@ dependent @*/ GSList * qof_query_term_get_param_path (const QofQueryTerm *queryterm);
+/*@ dependent @*/ QofQueryPredData *qof_query_term_get_pred_data (const QofQueryTerm *queryterm);
gboolean qof_query_term_is_inverted (const QofQueryTerm *queryterm);
@@ -58,7 +58,7 @@
void qof_query_get_sorts (QofQuery *q, QofQuerySort **primary,
QofQuerySort **secondary, QofQuerySort **tertiary);
-GSList * qof_query_sort_get_param_path (const QofQuerySort *querysort);
+/*@ dependent @*/ GSList * qof_query_sort_get_param_path (const QofQuerySort *querysort);
gint qof_query_sort_get_sort_options (const QofQuerySort *querysort);
gboolean qof_query_sort_get_increasing (const QofQuerySort *querysort);
Modified: gnucash/trunk/lib/libqof/qof/qofquery.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofquery.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/lib/libqof/qof/qofquery.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -371,7 +371,7 @@
void qof_query_print (QofQuery *query);
/** Return the type of data we're querying for */
-QofIdType qof_query_get_search_for (const QofQuery *q);
+/*@ dependent @*/ QofIdType qof_query_get_search_for (const QofQuery *q);
/** Return the list of books we're using */
GList * qof_query_get_books (QofQuery *q);
Added: gnucash/trunk/splint-defs.h
===================================================================
--- gnucash/trunk/splint-defs.h (rev 0)
+++ gnucash/trunk/splint-defs.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -0,0 +1,121 @@
+/********************************************************************
+ * splint-defs.h: declarations from system include files needed to *
+ * provide splint with memory usage patterns. *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 2 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact: *
+ * *
+ * Free Software Foundation Voice: +1-617-542-5942 *
+ * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
+ * Boston, MA 02110-1301, USA gnu at gnu.org *
+\********************************************************************/
+
+/* Only need this if running splint. This file contains lines copied from the other
+include files, but with the splint annotations added. Yes, this is dangerous if the
+definitions change. However, these definitions aren't used during regular compilation,
+only when running splint, so the danger is manageable. */
+
+#if !defined( SPLINT_DEFS_H ) && defined( S_SPLINT_S )
+#define SPLINT_DEFS_H
+
+/*@ -incondefs @*/
+
+/* Each section is surrounded by the include guard of the appropriate include file */
+
+/* dbi.h */
+
+#ifdef __DBI_H__
+void dbi_conn_close( /*@ only @*/ dbi_conn );
+int dbi_conn_error( dbi_conn, /*@ out @*/ const char** );
+dbi_result dbi_conn_get_table_list( dbi_conn, const char*, /*@ null @*/ const char* );
+/*@ dependent @*/ const char* dbi_conn_get_option( dbi_conn, const char* );
+int dbi_result_free( /*@ only @*/ dbi_result );
+/*@ dependent @*/ const char* dbi_result_get_string_idx( dbi_result, unsigned int );
+dbi_driver dbi_driver_list( /*@ null @*/ dbi_driver );
+size_t dbi_conn_quote_string_copy( dbi_conn, const char*, /*@ out @*/ char** );
+/*@ dependent @*/ dbi_driver_get_name( dbi_driver );
+#endif
+
+/* gdate.h */
+
+#ifdef __G_DATE_H__
+void g_date_free( /*@ only @*/ GDate* );
+#endif
+
+/* gmem.h */
+
+#ifdef __G_MEM_H__
+/*@ null @*/ /*@ only @*/ /*@ out @*/ gpointer g_malloc(gsize n_bytes);
+/*@ null @*/ /*@ only @*/ /*@ out @*/ gpointer g_malloc0(gsize n_bytes);
+void g_free( /*@ only @*/ gpointer );
+#endif
+
+/* gvalue.h */
+
+#ifdef __G_VALUE_H__
+GValue* g_value_init( /*@ out @*/ GValue*, GType );
+/*@ dependent @*/ const gchar* g_value_get_string(const GValue *value);
+void g_value_take_string( GValue*, /*@ only @*/ const gchar *);
+#endif
+
+/* gstring.h */
+
+#ifdef __G_STRING_H__
+gchar* g_string_free( /*@ only @*/ GString*, gboolean );
+#endif
+
+/* ghash.h */
+
+#ifdef __G_HASH_H__
+GHashTable* g_hash_table_new_full( GHashFunc, GEqualFunc, /*@ null @*/ GDestroyNotify, /*@ null @*/ GDestroyNotify );
+void g_hash_table_insert(GHashTable *hash_table, /*@ only @*/ gpointer key, gpointer value);
+/*@ dependent @*/ g_hash_table_lookup( GHashTable* hash_table, gpointer key );
+#endif
+
+/* glist.h */
+
+#ifdef __G_LIST_H__
+GList* g_list_append( /*@ returned @*//*@ null @*/ GList*, /*@ keep @*/ gpointer );
+GList* g_list_prepend( /*@ returned @*//*@ null @*/ GList*, /*@ keep @*/ gpointer );
+void g_list_free( /*@ only @*/ GList* );
+#endif
+
+/* gslist.h */
+
+#ifdef __G_SLIST_H__
+GSList* g_slist_append( /*@ returned @*//*@ null @*/ GSList*, /*@ keep @*/ gpointer );
+void g_slist_free( /*@ only @*/ GSList* );
+#endif
+
+/* gstrfuncs.h */
+
+#ifdef __G_STRFUNCS_H__
+gint64 g_ascii_strtoll( const gchar*, /*@ null @*/ gchar**, guint );
+#endif
+
+/* gtype.h */
+
+#ifdef __G_TYPE_H__
+/*@ dependent @*/ GTypeInstance* g_type_check_instance_cast(GTypeInstance *instance,
+ GType iface_type);
+#endif
+
+/* gtestutils.h */
+
+#ifdef __G_TEST_UTILS_H__
+#undef g_assert
+#define g_assert assert
+#endif
+
+/*@ +incondefs @*/
+#endif /* SPLINT_DEFS_H */
Added: gnucash/trunk/src/backend/dbi/.splintrc
===================================================================
--- gnucash/trunk/src/backend/dbi/.splintrc (rev 0)
+++ gnucash/trunk/src/backend/dbi/.splintrc 2009-03-09 17:17:57 UTC (rev 17983)
@@ -0,0 +1,31 @@
+-DHAVE_CONFIG_H
+-DG_LOG_DOMAIN="gnc.backend.dbi"
+-DLOCALE_DIR="/opt/gnucash2-svn/share/locale"
+-DORBIT2=1
+-D_FORTIFY_SOURCE=2
+-I.
+-I..
+-I../..
+-I../../..
+-I../../gnc-module
+-I../../../src/backend
+-I../../../src/backend/sql
+-I../../../src/engine
+-I../../../src/core-utils
+-I../../../lib/libc
+-I../../../lib/libqof/qof
+-I../../../lib/libqof/qof
+-I/usr/include/glib-2.0
+-I/usr/lib/glib-2.0/include
+-I/usr/include/gconf/2
+-I/usr/include/orbit-2.0
+-I/usr/include/dbus-1.0
+-I/usr/lib/dbus-1.0/include
+-I/usr/include/glib-2.0
+-I/usr/lib/glib-2.0/include
+
+-booltype gboolean
+
++posixlib
+-branchstate
+-fcnuse
Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -50,6 +50,10 @@
#include "gnc-backend-dbi.h"
+#ifdef S_SPLINT_S
+#include "splint-defs.h"
+#endif
+
#define TRANSACTION_NAME "trans"
static QofLogModule log_module = G_LOG_DOMAIN;
@@ -62,36 +66,43 @@
typedef gchar* (*CREATE_TABLE_DDL_FN)( GncSqlConnection* conn,
const gchar* table_name,
const GList* col_info_list );
+typedef const gchar* (*GET_COLUMN_TYPE_NAME_FN)( GType type, gint size );
typedef struct {
- CREATE_TABLE_DDL_FN create_table_ddl;
+ CREATE_TABLE_DDL_FN create_table_ddl;
+ GET_COLUMN_TYPE_NAME_FN get_column_type_name;
} provider_functions_t;
-static gchar* conn_create_table_ddl_sqlite3( GncSqlConnection* conn,
+static /*@ null @*/ gchar* conn_create_table_ddl_sqlite3( GncSqlConnection* conn,
const gchar* table_name,
const GList* col_info_list );
-
+static /*@ observer @*/ const gchar* sqlite3_get_column_type_name( GType type, gint size );
static provider_functions_t provider_sqlite3 =
{
- conn_create_table_ddl_sqlite3
+ conn_create_table_ddl_sqlite3,
+ sqlite3_get_column_type_name
};
-static gchar* conn_create_table_ddl_mysql( GncSqlConnection* conn,
+static /*@ null @*/ gchar* conn_create_table_ddl_mysql( GncSqlConnection* conn,
const gchar* table_name,
const GList* col_info_list );
+static /*@ observer @*/ const gchar* mysql_get_column_type_name( GType type, gint size );
static provider_functions_t provider_mysql =
{
- conn_create_table_ddl_mysql
+ conn_create_table_ddl_mysql,
+ mysql_get_column_type_name
};
-static gchar* conn_create_table_ddl_pgsql( GncSqlConnection* conn,
+static /*@ null @*/ gchar* conn_create_table_ddl_pgsql( GncSqlConnection* conn,
const gchar* table_name,
const GList* col_info_list );
+static /*@ observer @*/ const gchar* pgsql_get_column_type_name( GType type, gint size );
static provider_functions_t provider_pgsql =
{
- conn_create_table_ddl_pgsql
+ conn_create_table_ddl_pgsql,
+ pgsql_get_column_type_name
};
-static GncSqlConnection* create_dbi_connection( provider_functions_t* provider, dbi_conn conn );
+static GncSqlConnection* create_dbi_connection( /*@ observer @*/ provider_functions_t* provider, /*@ observer @*/ dbi_conn conn );
#define GNC_DBI_PROVIDER_SQLITE (&provider_sqlite3)
#define GNC_DBI_PROVIDER_MYSQL (&provider_mysql)
@@ -103,7 +114,7 @@
dbi_conn conn;
- QofBook *primary_book; /* The primary, main open book */
+ /*@ dependent @*/ QofBook *primary_book; /* The primary, main open book */
gboolean loading; /* We are performing an initial load */
gboolean in_query;
gboolean supports_transactions;
@@ -133,20 +144,20 @@
}
static void
-sqlite3_error_fn( dbi_conn conn, void* user_data )
+sqlite3_error_fn( dbi_conn conn, /*@ unused @*/ void* user_data )
{
- GncDbiBackend *be = (GncDbiBackend*)user_data;
+ //GncDbiBackend *be = (GncDbiBackend*)user_data;
const gchar* msg;
- dbi_conn_error( conn, &msg );
+ (void)dbi_conn_error( conn, &msg );
PERR( "DBI error: %s\n", msg );
}
static void
gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
const gchar *book_id,
- gboolean ignore_lock,
- gboolean create_if_nonexistent )
+ /*@ unused @*/ gboolean ignore_lock,
+ /*@ unused @*/ gboolean create_if_nonexistent )
{
GncDbiBackend *be = (GncDbiBackend*)qbe;
gint result;
@@ -174,6 +185,9 @@
return;
}
+ if( be->conn != NULL ) {
+ dbi_conn_close( be->conn );
+ }
be->conn = dbi_conn_new( "sqlite3" );
if( be->conn == NULL ) {
PERR( "Unable to create sqlite3 dbi connection\n" );
@@ -185,9 +199,9 @@
dirname = g_path_get_dirname( book_id );
basename = g_path_get_basename( book_id );
dbi_conn_error_handler( be->conn, sqlite3_error_fn, be );
- dbi_conn_set_option( be->conn, "host", "localhost" );
- dbi_conn_set_option( be->conn, "dbname", basename );
- dbi_conn_set_option( be->conn, "sqlite3_dbdir", dirname );
+ (void)dbi_conn_set_option( be->conn, "host", "localhost" );
+ (void)dbi_conn_set_option( be->conn, "dbname", basename );
+ (void)dbi_conn_set_option( be->conn, "sqlite3_dbdir", dirname );
result = dbi_conn_connect( be->conn );
g_free( basename );
g_free( dirname );
@@ -198,6 +212,9 @@
return;
}
+ if( be->sql_be.conn != NULL ) {
+ gnc_sql_connection_dispose( be->sql_be.conn );
+ }
be->sql_be.conn = create_dbi_connection( GNC_DBI_PROVIDER_SQLITE, be->conn );
LEAVE (" ");
@@ -209,7 +226,7 @@
GncDbiBackend *be = (GncDbiBackend*)user_data;
const gchar* msg;
- dbi_conn_error( conn, &msg );
+ (void)dbi_conn_error( conn, &msg );
PERR( "DBI error: %s\n", msg );
if( g_str_has_prefix( msg, "1049: Unknown database" ) ) {
be->exists = FALSE;
@@ -219,8 +236,8 @@
static void
gnc_dbi_mysql_session_begin( QofBackend *qbe, QofSession *session,
const gchar *book_id,
- gboolean ignore_lock,
- gboolean create_if_nonexistent )
+ /*@ unused @*/gboolean ignore_lock,
+ /*@ unused @*/gboolean create_if_nonexistent )
{
GncDbiBackend *be = (GncDbiBackend*)qbe;
gchar* dsn;
@@ -247,6 +264,9 @@
for( password = username; *password != ':'; password++ ) {}
*password++ = '\0';
+ if( be->conn != NULL ) {
+ dbi_conn_close( be->conn );
+ }
be->conn = dbi_conn_new( "mysql" );
if( be->conn == NULL ) {
PERR( "Unable to create mysql dbi connection\n" );
@@ -255,16 +275,19 @@
return;
}
dbi_conn_error_handler( be->conn, mysql_error_fn, be );
- dbi_conn_set_option( be->conn, "host", host );
- dbi_conn_set_option_numeric( be->conn, "port", 0 );
- dbi_conn_set_option( be->conn, "dbname", "mysql" );
- dbi_conn_set_option( be->conn, "username", username );
- dbi_conn_set_option( be->conn, "password", password );
+ (void)dbi_conn_set_option( be->conn, "host", host );
+ (void)dbi_conn_set_option_numeric( be->conn, "port", 0 );
+ (void)dbi_conn_set_option( be->conn, "dbname", "mysql" );
+ (void)dbi_conn_set_option( be->conn, "username", username );
+ (void)dbi_conn_set_option( be->conn, "password", password );
be->exists = TRUE;
result = dbi_conn_connect( be->conn );
if( result == 0 ) {
result = dbi_conn_select_db( be->conn, dbname );
if( result == 0 ) {
+ if( be->sql_be.conn != NULL ) {
+ gnc_sql_connection_dispose( be->sql_be.conn );
+ }
be->sql_be.conn = create_dbi_connection( GNC_DBI_PROVIDER_MYSQL, be->conn );
} else {
if( create_if_nonexistent ) {
@@ -273,11 +296,17 @@
dresult = dbi_conn_queryf( be->conn, "CREATE DATABASE %s", dbname );
result = dbi_conn_select_db( be->conn, dbname );
if( result == 0 ) {
+ if( be->sql_be.conn != NULL ) {
+ gnc_sql_connection_dispose( be->sql_be.conn );
+ }
be->sql_be.conn = create_dbi_connection( GNC_DBI_PROVIDER_MYSQL, be->conn );
} else {
PERR( "Unable to connect to %s: %d\n", book_id, result );
qof_backend_set_error( qbe, ERR_BACKEND_CANT_CONNECT );
}
+ if( dresult != NULL ) {
+ (void)dbi_result_free( dresult );
+ }
} else {
qof_backend_set_error( qbe, ERR_BACKEND_NO_SUCH_DB );
}
@@ -292,20 +321,20 @@
}
static void
-pgsql_error_fn( dbi_conn conn, void* user_data )
+pgsql_error_fn( dbi_conn conn, /*@ unused @*/ void* user_data )
{
- GncDbiBackend *be = (GncDbiBackend*)user_data;
+ //GncDbiBackend *be = (GncDbiBackend*)user_data;
const gchar* msg;
- dbi_conn_error( conn, &msg );
+ (void)dbi_conn_error( conn, &msg );
PERR( "DBI error: %s\n", msg );
}
static void
gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
const gchar *book_id,
- gboolean ignore_lock,
- gboolean create_if_nonexistent )
+ /*@ unused @*/ gboolean ignore_lock,
+ /*@ unused @*/ gboolean create_if_nonexistent )
{
GncDbiBackend *be = (GncDbiBackend*)qbe;
gint result;
@@ -332,6 +361,9 @@
for( password = username; *password != ':'; password++ ) {}
*password++ = '\0';
+ if( be->conn != NULL ) {
+ dbi_conn_close( be->conn );
+ }
be->conn = dbi_conn_new( "pgsql" );
if( be->conn == NULL ) {
PERR( "Unable to create pgsql dbi connection\n" );
@@ -340,11 +372,11 @@
return;
}
dbi_conn_error_handler( be->conn, pgsql_error_fn, be );
- dbi_conn_set_option( be->conn, "host", host );
- dbi_conn_set_option_numeric( be->conn, "port", 0 );
- dbi_conn_set_option( be->conn, "dbname", dbname );
- dbi_conn_set_option( be->conn, "username", username );
- dbi_conn_set_option( be->conn, "password", password );
+ (void)dbi_conn_set_option( be->conn, "host", host );
+ (void)dbi_conn_set_option_numeric( be->conn, "port", 0 );
+ (void)dbi_conn_set_option( be->conn, "dbname", dbname );
+ (void)dbi_conn_set_option( be->conn, "username", username );
+ (void)dbi_conn_set_option( be->conn, "password", password );
result = dbi_conn_connect( be->conn );
g_free( dsn );
if( result < 0 ) {
@@ -354,6 +386,9 @@
return;
}
+ if( be->sql_be.conn != NULL ) {
+ gnc_sql_connection_dispose( be->sql_be.conn );
+ }
be->sql_be.conn = create_dbi_connection( GNC_DBI_PROVIDER_PGSQL, be->conn );
LEAVE (" ");
@@ -377,7 +412,7 @@
}
static void
-gnc_dbi_destroy_backend( QofBackend *be )
+gnc_dbi_destroy_backend( /*@ only @*/ QofBackend *be )
{
g_return_if_fail( be != NULL );
@@ -387,12 +422,9 @@
/* ================================================================= */
static void
-gnc_dbi_load( QofBackend* qbe, QofBook *book, QofBackendLoadType loadType )
+gnc_dbi_load( QofBackend* qbe, /*@ dependent @*/ QofBook *book, QofBackendLoadType loadType )
{
GncDbiBackend *be = (GncDbiBackend*)qbe;
- GncSqlObjectBackend* pData;
- int i;
- Account* root;
g_return_if_fail( qbe != NULL );
g_return_if_fail( book != NULL );
@@ -423,26 +455,22 @@
GncDbiBackend* be = (GncDbiBackend*)qbe;
const gchar* dbname;
dbi_result tables;
- gint numTables;
+ unsigned long long numTables;
/* Data may be clobbered iff the number of tables != 0 */
dbname = dbi_conn_get_option( be->conn, "dbname" );
tables = dbi_conn_get_table_list( be->conn, dbname, NULL );
numTables = dbi_result_get_numrows( tables );
- dbi_result_free( tables );
+ (void)dbi_result_free( tables );
return (numTables != 0);
}
static void
-gnc_dbi_sync_all( QofBackend* qbe, QofBook *book )
+gnc_dbi_sync_all( QofBackend* qbe, /*@ dependent @*/ QofBook *book )
{
GncDbiBackend* be = (GncDbiBackend*)qbe;
dbi_result tables;
- GError* error = NULL;
- gint row;
- gint numTables;
- gboolean status;
const gchar* dbname;
g_return_if_fail( be != NULL );
@@ -453,15 +481,15 @@
/* Destroy the current contents of the database */
dbname = dbi_conn_get_option( be->conn, "dbname" );
tables = dbi_conn_get_table_list( be->conn, dbname, NULL );
- while( dbi_result_next_row( tables ) ) {
+ while( dbi_result_next_row( tables ) != 0 ) {
const gchar* table_name;
dbi_result result;
table_name = dbi_result_get_string_idx( tables, 1 );
result = dbi_conn_queryf( be->conn, "DROP TABLE %s", table_name );
- dbi_result_free( result );
+ (void)dbi_result_free( result );
}
- dbi_result_free( tables );
+ (void)dbi_result_free( tables );
/* Save all contents */
be->is_pristine_db = TRUE;
@@ -545,61 +573,48 @@
}
static QofBackend*
-gnc_dbi_backend_sqlite3_new( void )
+new_backend( void (*session_begin)( QofBackend *, QofSession *, const gchar *,
+ /*@ unused @*/ gboolean, /*@ unused @*/ gboolean ) )
{
GncDbiBackend *dbi_be;
QofBackend *be;
dbi_be = g_new0( GncDbiBackend, 1 );
+ g_assert( dbi_be != NULL );
+
be = (QofBackend*)dbi_be;
qof_backend_init( be );
- be->session_begin = gnc_dbi_sqlite3_session_begin;
+ be->session_begin = session_begin;
init_sql_backend( dbi_be );
return be;
}
static QofBackend*
+gnc_dbi_backend_sqlite3_new( void )
+{
+ return new_backend( gnc_dbi_sqlite3_session_begin );
+}
+
+static QofBackend*
gnc_dbi_backend_mysql_new( void )
{
- GncDbiBackend *dbi_be;
- QofBackend *be;
-
- dbi_be = g_new0( GncDbiBackend, 1 );
- be = (QofBackend*)dbi_be;
- qof_backend_init( be );
-
- be->session_begin = gnc_dbi_mysql_session_begin;
- init_sql_backend( dbi_be );
-
- return be;
+ return new_backend( gnc_dbi_mysql_session_begin );
}
static QofBackend*
gnc_dbi_backend_postgres_new( void )
{
- GncDbiBackend *dbi_be;
- QofBackend *be;
-
- dbi_be = g_new0( GncDbiBackend, 1 );
- be = (QofBackend*)dbi_be;
- qof_backend_init( be );
-
- be->session_begin = gnc_dbi_postgres_session_begin;
- init_sql_backend( dbi_be );
-
- return be;
+ return new_backend( gnc_dbi_postgres_session_begin );
}
static void
-gnc_dbi_provider_free( QofBackendProvider *prov )
+gnc_dbi_provider_free( /*@ only @*/ QofBackendProvider *prov )
{
g_return_if_fail( prov != NULL );
- prov->provider_name = NULL;
- prov->access_method = NULL;
- g_free (prov);
+ g_free( prov );
}
/*
@@ -611,7 +626,7 @@
{
FILE* f;
gchar buf[50];
- gint chars_read;
+ size_t chars_read;
// BAD if the path is null
g_return_val_if_fail( path != NULL, FALSE );
@@ -626,7 +641,7 @@
// OK if file has the correct header
chars_read = fread( buf, sizeof(buf), 1, f );
- fclose( f );
+ (void)fclose( f );
if( g_str_has_prefix( buf, "SQLite format 3" ) ) {
PINFO( "has SQLite format string -> DBI" );
return TRUE;
@@ -681,7 +696,9 @@
}
if( have_sqlite3_driver ) {
- prov = g_new0 (QofBackendProvider, 1);
+ prov = g_new0( QofBackendProvider, 1 );
+ g_assert( prov != NULL );
+
prov->provider_name = "GnuCash Libdbi (SQLITE3) Backend";
prov->access_method = FILE_URI_TYPE;
prov->partial_book_supported = FALSE;
@@ -690,7 +707,9 @@
prov->check_data_type = gnc_dbi_check_sqlite3_file;
qof_backend_register_provider( prov );
- prov = g_new0 (QofBackendProvider, 1);
+ prov = g_new0( QofBackendProvider, 1 );
+ g_assert( prov != NULL );
+
prov->provider_name = "GnuCash Libdbi (SQLITE3) Backend";
prov->access_method = SQLITE3_URI_TYPE;
prov->partial_book_supported = FALSE;
@@ -701,22 +720,28 @@
}
if( have_mysql_driver ) {
- prov = g_new0 (QofBackendProvider, 1);
+ prov = g_new0( QofBackendProvider, 1 );
+ g_assert( prov != NULL );
+
prov->provider_name = "GnuCash Libdbi (MYSQL) Backend";
prov->access_method = "mysql";
prov->partial_book_supported = FALSE;
prov->backend_new = gnc_dbi_backend_mysql_new;
prov->provider_free = gnc_dbi_provider_free;
+ prov->check_data_type = NULL;
qof_backend_register_provider( prov );
}
if( have_pgsql_driver ) {
- prov = g_new0 (QofBackendProvider, 1);
+ prov = g_new0( QofBackendProvider, 1 );
+ g_assert( prov != NULL );
+
prov->provider_name = "GnuCash Libdbi (POSTGRESQL) Backend";
prov->access_method = "postgres";
prov->partial_book_supported = FALSE;
prov->backend_new = gnc_dbi_backend_postgres_new;
prov->provider_free = gnc_dbi_provider_free;
+ prov->check_data_type = NULL;
qof_backend_register_provider( prov );
}
}
@@ -726,12 +751,12 @@
{
GncSqlRow base;
- dbi_result result;
+ /*@ dependent @*/ dbi_result result;
GList* gvalue_list;
} GncDbiSqlRow;
static void
-row_dispose( GncSqlRow* row )
+row_dispose( /*@ only @*/ GncSqlRow* row )
{
GncDbiSqlRow* dbi_row = (GncDbiSqlRow*)row;
GList* node;
@@ -749,7 +774,7 @@
g_free( dbi_row );
}
-static const GValue*
+static /*@ null @*/ const GValue*
row_get_value_at_col_name( GncSqlRow* row, const gchar* col_name )
{
GncDbiSqlRow* dbi_row = (GncDbiSqlRow*)row;
@@ -758,17 +783,19 @@
type = dbi_result_get_field_type( dbi_row->result, col_name );
value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
+
switch( type ) {
case DBI_TYPE_INTEGER:
- g_value_init( value, G_TYPE_INT64 );
+ (void)g_value_init( value, G_TYPE_INT64 );
g_value_set_int64( value, dbi_result_get_longlong( dbi_row->result, col_name ) );
break;
case DBI_TYPE_DECIMAL:
- g_value_init( value, G_TYPE_DOUBLE );
+ (void)g_value_init( value, G_TYPE_DOUBLE );
g_value_set_double( value, dbi_result_get_double( dbi_row->result, col_name ) );
break;
case DBI_TYPE_STRING:
- g_value_init( value, G_TYPE_STRING );
+ (void)g_value_init( value, G_TYPE_STRING );
g_value_take_string( value, dbi_result_get_string_copy( dbi_row->result, col_name ) );
break;
default:
@@ -782,11 +809,13 @@
}
static GncSqlRow*
-create_dbi_row( dbi_result result )
+create_dbi_row( /*@ dependent @*/ dbi_result result )
{
GncDbiSqlRow* row;
row = g_new0( GncDbiSqlRow, 1 );
+ g_assert( row != NULL );
+
row->base.getValueAtColName = row_get_value_at_col_name;
row->base.dispose = row_dispose;
row->result = result;
@@ -798,14 +827,14 @@
{
GncSqlResult base;
- dbi_result result;
- gint num_rows;
- gint cur_row;
+ /*@ owned @*/ dbi_result result;
+ guint num_rows;
+ guint cur_row;
GncSqlRow* row;
} GncDbiSqlResult;
static void
-result_dispose( GncSqlResult* result )
+result_dispose( /*@ only @*/ GncSqlResult* result )
{
GncDbiSqlResult* dbi_result = (GncDbiSqlResult*)result;
@@ -813,12 +842,12 @@
gnc_sql_row_dispose( dbi_result->row );
}
if( dbi_result->result != NULL ) {
- dbi_result_free( dbi_result->result );
+ (void)dbi_result_free( dbi_result->result );
}
g_free( result );
}
-static gint
+static guint
result_get_num_rows( GncSqlResult* result )
{
GncDbiSqlResult* dbi_result = (GncDbiSqlResult*)result;
@@ -826,7 +855,7 @@
return dbi_result->num_rows;
}
-static GncSqlRow*
+static /*@ null @*/ GncSqlRow*
result_get_first_row( GncSqlResult* result )
{
GncDbiSqlResult* dbi_result = (GncDbiSqlResult*)result;
@@ -836,7 +865,7 @@
dbi_result->row = NULL;
}
if( dbi_result->num_rows > 0 ) {
- dbi_result_first_row( dbi_result->result );
+ (void)dbi_result_first_row( dbi_result->result );
dbi_result->cur_row = 1;
dbi_result->row = create_dbi_row( dbi_result->result );
return dbi_result->row;
@@ -845,7 +874,7 @@
}
}
-static GncSqlRow*
+static /*@ null @*/ GncSqlRow*
result_get_next_row( GncSqlResult* result )
{
GncDbiSqlResult* dbi_result = (GncDbiSqlResult*)result;
@@ -855,7 +884,7 @@
dbi_result->row = NULL;
}
if( dbi_result->cur_row < dbi_result->num_rows ) {
- dbi_result_next_row( dbi_result->result );
+ (void)dbi_result_next_row( dbi_result->result );
dbi_result->cur_row++;
dbi_result->row = create_dbi_row( dbi_result->result );
return dbi_result->row;
@@ -865,17 +894,19 @@
}
static GncSqlResult*
-create_dbi_result( dbi_result result )
+create_dbi_result( /*@ owned @*/ dbi_result result )
{
GncDbiSqlResult* dbi_result;
dbi_result = g_new0( GncDbiSqlResult, 1 );
+ g_assert( dbi_result != NULL );
+
dbi_result->base.dispose = result_dispose;
dbi_result->base.getNumRows = result_get_num_rows;
dbi_result->base.getFirstRow = result_get_first_row;
dbi_result->base.getNextRow = result_get_next_row;
dbi_result->result = result;
- dbi_result->num_rows = dbi_result_get_numrows( result );
+ dbi_result->num_rows = (guint)dbi_result_get_numrows( result );
dbi_result->cur_row = 0;
return (GncSqlResult*)dbi_result;
@@ -886,16 +917,16 @@
GncSqlStatement base;
GString* sql;
- GncSqlConnection* conn;
+ /*@ observer @*/ GncSqlConnection* conn;
} GncDbiSqlStatement;
static void
-stmt_dispose( GncSqlStatement* stmt )
+stmt_dispose( /*@ only @*/ GncSqlStatement* stmt )
{
GncDbiSqlStatement* dbi_stmt = (GncDbiSqlStatement*)stmt;
if( dbi_stmt->sql != NULL ) {
- g_string_free( dbi_stmt->sql, TRUE );
+ (void)g_string_free( dbi_stmt->sql, TRUE );
}
g_free( stmt );
}
@@ -909,8 +940,8 @@
}
static void
-stmt_add_where_cond( GncSqlStatement* stmt, QofIdTypeConst type_name,
- gpointer obj, const GncSqlColumnTableEntry* table_row, GValue* value )
+stmt_add_where_cond( GncSqlStatement* stmt, /*@ unused @*/ QofIdTypeConst type_name,
+ /*@ unused @*/ gpointer obj, const GncSqlColumnTableEntry* table_row, GValue* value )
{
GncDbiSqlStatement* dbi_stmt = (GncDbiSqlStatement*)stmt;
gchar* buf;
@@ -920,21 +951,22 @@
buf = g_strdup_printf( " WHERE %s = %s", table_row->col_name,
value_str );
g_free( value_str );
- g_string_append( dbi_stmt->sql, buf );
+ (void)g_string_append( dbi_stmt->sql, buf );
g_free( buf );
}
static GncSqlStatement*
-create_dbi_statement( GncSqlConnection* conn, gchar* sql )
+create_dbi_statement( /*@ observer @*/ GncSqlConnection* conn, const gchar* sql )
{
GncDbiSqlStatement* stmt;
stmt = g_new0( GncDbiSqlStatement, 1 );
+ g_assert( stmt != NULL );
+
stmt->base.dispose = stmt_dispose;
stmt->base.toSql = stmt_to_sql;
stmt->base.addWhereCond = stmt_add_where_cond;
stmt->sql = g_string_new( sql );
- g_free( sql );
stmt->conn = conn;
return (GncSqlStatement*)stmt;
@@ -944,19 +976,19 @@
{
GncSqlConnection base;
- dbi_conn conn;
- provider_functions_t* provider;
+ /*@ observer @*/ dbi_conn conn;
+ /*@ observer @*/ provider_functions_t* provider;
} GncDbiSqlConnection;
static void
-conn_dispose( GncSqlConnection* conn )
+conn_dispose( /*@ only @*/ GncSqlConnection* conn )
{
- GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
+ //GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
g_free( conn );
}
-static GncSqlResult*
+static /*@ null @*/ GncSqlResult*
conn_execute_select_statement( GncSqlConnection* conn, GncSqlStatement* stmt )
{
GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
@@ -986,26 +1018,28 @@
return -1;
}
DEBUG( "SQL: %s\n", dbi_stmt->sql->str );
- num_rows = dbi_result_get_numrows_affected( result );
- dbi_result_free( result );
+ num_rows = (gint)dbi_result_get_numrows_affected( result );
+ (void)dbi_result_free( result );
return num_rows;
}
static GncSqlStatement*
-conn_create_statement_from_sql( GncSqlConnection* conn, gchar* sql )
+conn_create_statement_from_sql( /*@ observer @*/ GncSqlConnection* conn, const gchar* sql )
{
- GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
+ //GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
return create_dbi_statement( conn, sql );
}
static GValue*
-create_gvalue_from_string( gchar* s )
+create_gvalue_from_string( /*@ only @*/ gchar* s )
{
GValue* s_gval;
s_gval = g_new0( GValue, 1 );
- g_value_init( s_gval, G_TYPE_STRING );
+ g_assert( s_gval != NULL );
+
+ (void)g_value_init( s_gval, G_TYPE_STRING );
g_value_take_string( s_gval, s );
return s_gval;
@@ -1024,8 +1058,8 @@
dbname = dbi_conn_get_option( dbi_conn->conn, "dbname" );
tables = dbi_conn_get_table_list( dbi_conn->conn, dbname, table_name );
- nTables = dbi_result_get_numrows( tables );
- dbi_result_free( tables );
+ nTables = (gint)dbi_result_get_numrows( tables );
+ (void)dbi_result_free( tables );
if( nTables == 1 ) {
return TRUE;
@@ -1035,95 +1069,109 @@
}
static gboolean
-conn_begin_transaction( GncSqlConnection* conn )
+conn_begin_transaction( /*@ unused @*/ GncSqlConnection* conn )
{
- GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
+ //GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
return TRUE;
}
static gboolean
-conn_rollback_transaction( GncSqlConnection* conn )
+conn_rollback_transaction( /*@ unused @*/ GncSqlConnection* conn )
{
- GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
+ //GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
return TRUE;
}
static gboolean
-conn_commit_transaction( GncSqlConnection* conn )
+conn_commit_transaction( /*@ unused @*/ GncSqlConnection* conn )
{
- GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
+ //GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
return TRUE;
}
-static const gchar*
-conn_get_column_type_name( GncSqlConnection* conn, GType type, gint size )
+static /*@ observer @*/ const gchar*
+sqlite3_get_column_type_name( GType type, /*@ unused @*/ gint size )
{
+ switch( type ) {
+ case G_TYPE_INT:
+ return "integer";
+
+ case G_TYPE_INT64:
+ return "bigint";
+
+ case G_TYPE_DOUBLE:
+ return "real";
+
+ case G_TYPE_STRING:
+ return "text";
+
+ default:
+ PERR( "Unknown GType: %s\n", g_type_name( type ) );
+ return "";
+ }
+}
+
+static /*@ observer @*/ const gchar*
+mysql_get_column_type_name( GType type, /*@ unused @*/ gint size )
+{
+ switch( type ) {
+ case G_TYPE_INT:
+ return "integer";
+
+ case G_TYPE_INT64:
+ return "bigint";
+
+ case G_TYPE_DOUBLE:
+ return "double";
+
+ case G_TYPE_STRING:
+ return "varchar";
+
+ default:
+ PERR( "Unknown GType: %s\n", g_type_name( type ) );
+ return "";
+ }
+}
+
+static /*@ observer @*/ const gchar*
+pgsql_get_column_type_name( GType type, /*@ unused @*/ gint size )
+{
+ switch( type ) {
+ case G_TYPE_INT:
+ return "integer";
+
+ case G_TYPE_INT64:
+ return "int8";
+
+ case G_TYPE_DOUBLE:
+ return "double precision";
+
+ case G_TYPE_STRING:
+ return "varchar";
+
+ default:
+ PERR( "Unknown GType: %s\n", g_type_name( type ) );
+ return "";
+ }
+}
+
+static /*@ observer @*/ const gchar*
+conn_get_column_type_name( GncSqlConnection* conn, GType type, /*@ unused @*/ gint size )
+{
GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
- if( dbi_conn->provider == GNC_DBI_PROVIDER_SQLITE ) {
- switch( type ) {
- case G_TYPE_INT:
- return "integer";
- break;
- case G_TYPE_INT64:
- return "bigint";
- break;
- case G_TYPE_DOUBLE:
- return "real";
- break;
- case G_TYPE_STRING:
- return "text";
- break;
- default:
- PERR( "Unknown GType: %s\n", g_type_name( type ) );
- return "";
- }
- } else if( dbi_conn->provider == GNC_DBI_PROVIDER_MYSQL ) {
- switch( type ) {
- case G_TYPE_INT:
- return "integer";
- break;
- case G_TYPE_INT64:
- return "bigint";
- break;
- case G_TYPE_DOUBLE:
- return "double";
- break;
- case G_TYPE_STRING:
- return "varchar";
- break;
- default:
- PERR( "Unknown GType: %s\n", g_type_name( type ) );
- return "";
- }
- } else if( dbi_conn->provider == GNC_DBI_PROVIDER_PGSQL ) {
- switch( type ) {
- case G_TYPE_INT:
- return "integer";
- break;
- case G_TYPE_INT64:
- return "int8";
- break;
- case G_TYPE_DOUBLE:
- return "double precision";
- break;
- case G_TYPE_STRING:
- return "varchar";
- break;
- default:
- PERR( "Unknown GType: %s\n", g_type_name( type ) );
- return "";
- }
+ if( dbi_conn->provider != NULL && dbi_conn->provider->get_column_type_name != NULL ) {
+ return dbi_conn->provider->get_column_type_name( type, size );
} else {
PERR( "Unknown provider type\n" );
return "";
}
}
-static gchar*
+static /*@ null @*/ gchar*
conn_create_table_ddl_sqlite3( GncSqlConnection* conn,
const gchar* table_name,
const GList* col_info_list )
@@ -1144,29 +1192,29 @@
GncSqlColumnInfo* info = (GncSqlColumnInfo*)(list_node->data);
if( col_num != 0 ) {
- g_string_append( ddl, ", " );
+ (void)g_string_append( ddl, ", " );
}
g_string_append_printf( ddl, "%s %s", info->name,
gnc_sql_connection_get_column_type_name( conn, info->type, info->size ) );
if( info->size != 0 ) {
- g_string_append_printf( ddl, "(%d)", info->size );
+ (void)g_string_append_printf( ddl, "(%d)", info->size );
}
if( info->is_primary_key ) {
- g_string_append( ddl, " PRIMARY KEY" );
+ (void)g_string_append( ddl, " PRIMARY KEY" );
}
if( !info->null_allowed ) {
- g_string_append( ddl, " NOT NULL" );
+ (void)g_string_append( ddl, " NOT NULL" );
}
}
- g_string_append( ddl, ")" );
+ (void)g_string_append( ddl, ")" );
ddl_result = ddl->str;
- g_string_free( ddl, FALSE );
+ (void)g_string_free( ddl, FALSE );
return ddl_result;
}
-static gchar*
+static /*@ null @*/ gchar*
conn_create_table_ddl_mysql( GncSqlConnection* conn, const gchar* table_name,
const GList* col_info_list )
{
@@ -1186,7 +1234,7 @@
GncSqlColumnInfo* info = (GncSqlColumnInfo*)(list_node->data);
if( col_num != 0 ) {
- g_string_append( ddl, ", " );
+ (void)g_string_append( ddl, ", " );
}
g_string_append_printf( ddl, "%s %s", info->name,
gnc_sql_connection_get_column_type_name( conn, info->type, info->size ) );
@@ -1194,24 +1242,24 @@
g_string_append_printf( ddl, "(%d)", info->size );
}
if( info->is_unicode ) {
- g_string_append( ddl, " CHARACTER SET utf8" );
+ (void)g_string_append( ddl, " CHARACTER SET utf8" );
}
if( info->is_primary_key ) {
- g_string_append( ddl, " PRIMARY KEY" );
+ (void)g_string_append( ddl, " PRIMARY KEY" );
}
if( !info->null_allowed ) {
- g_string_append( ddl, " NOT NULL" );
+ (void)g_string_append( ddl, " NOT NULL" );
}
}
- g_string_append( ddl, ")" );
+ (void)g_string_append( ddl, ")" );
ddl_result = ddl->str;
- g_string_free( ddl, FALSE );
+ (void)g_string_free( ddl, FALSE );
return ddl_result;
}
-static gchar*
+static /*@ null @*/ gchar*
conn_create_table_ddl_pgsql( GncSqlConnection* conn, const gchar* table_name,
const GList* col_info_list )
{
@@ -1232,7 +1280,7 @@
GncSqlColumnInfo* info = (GncSqlColumnInfo*)(list_node->data);
if( col_num != 0 ) {
- g_string_append( ddl, ", " );
+ (void)g_string_append( ddl, ", " );
}
g_string_append_printf( ddl, "%s %s", info->name,
gnc_sql_connection_get_column_type_name( conn, info->type, info->size ) );
@@ -1240,19 +1288,19 @@
g_string_append_printf( ddl, "(%d)", info->size );
}
if( info->is_primary_key ) {
- g_string_append( ddl, " PRIMARY KEY" );
+ (void)g_string_append( ddl, " PRIMARY KEY" );
}
if( !info->null_allowed ) {
- g_string_append( ddl, " NOT NULL" );
+ (void)g_string_append( ddl, " NOT NULL" );
}
is_unicode = is_unicode || info->is_unicode;
}
- g_string_append( ddl, ")" );
+ (void)g_string_append( ddl, ")" );
if( is_unicode ) {
}
ddl_result = ddl->str;
- g_string_free( ddl, FALSE );
+ (void)g_string_free( ddl, FALSE );
return ddl_result;
}
@@ -1263,8 +1311,6 @@
{
GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
gchar* ddl;
- const GList* list_node;
- guint col_num;
dbi_result result;
g_return_val_if_fail( conn != NULL, FALSE );
@@ -1277,7 +1323,7 @@
if( ddl != NULL ) {
DEBUG( "SQL: %s\n", ddl );
result = dbi_conn_query( dbi_conn->conn, ddl );
- dbi_result_free( result );
+ (void)dbi_result_free( result );
} else {
return FALSE;
}
@@ -1286,8 +1332,8 @@
}
static gboolean
-conn_create_index( GncSqlConnection* conn, const gchar* index_name,
- const gchar* table_name, const GncSqlColumnTableEntry* col_table )
+conn_create_index( /*@ unused @*/ GncSqlConnection* conn, /*@ unused @*/ const gchar* index_name,
+ /*@ unused @*/ const gchar* table_name, /*@ unused @*/ const GncSqlColumnTableEntry* col_table )
{
#if 0
GdaServerOperation *op;
@@ -1370,12 +1416,12 @@
return TRUE;
}
-static gchar*
+static /*@ null @*/ gchar*
conn_quote_string( const GncSqlConnection* conn, gchar* unquoted_str )
{
GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
gchar* quoted_str;
- gint size;
+ size_t size;
size = dbi_conn_quote_string_copy( dbi_conn->conn, unquoted_str,
"ed_str );
@@ -1387,11 +1433,13 @@
}
static GncSqlConnection*
-create_dbi_connection( provider_functions_t* provider, dbi_conn conn )
+create_dbi_connection( /*@ observer @*/ provider_functions_t* provider, /*@ observer @*/ dbi_conn conn )
{
GncDbiSqlConnection* dbi_conn;
dbi_conn = g_new0( GncDbiSqlConnection, 1 );
+ g_assert( dbi_conn != NULL );
+
dbi_conn->base.dispose = conn_dispose;
dbi_conn->base.executeSelectStatement = conn_execute_select_statement;
dbi_conn->base.executeNonSelectStatement = conn_execute_nonselect_statement;
Modified: gnucash/trunk/src/backend/dbi/gncmod-backend-dbi.c
===================================================================
--- gnucash/trunk/src/backend/dbi/gncmod-backend-dbi.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/dbi/gncmod-backend-dbi.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -20,44 +20,46 @@
int gnc_module_revision = 0;
int gnc_module_age = 0;
-static GNCModule engine;
+/*@ dependent @*//*@ null @*/ static GNCModule engine;
gchar *
gnc_module_path(void)
{
- return g_strdup("gnucash/backend/dbi");
+ return g_strdup( "gnucash/backend/dbi" );
}
gchar *
gnc_module_description(void)
{
- return g_strdup("The DBI/SQL backend for GnuCash");
+ return g_strdup( "The DBI/SQL backend for GnuCash" );
}
int
gnc_module_init(int refcount)
{
- engine = gnc_module_load("gnucash/engine", 0);
- if(!engine) return FALSE;
+ engine = gnc_module_load( "gnucash/engine", 0 );
+ if( !engine ) return FALSE;
- /* Need to initialize g-type engine for gconf */
- if (refcount == 0) {
- g_type_init();
- }
+ /* Need to initialize g-type engine for gconf */
+ if (refcount == 0) {
+ g_type_init();
+ }
- return TRUE;
+ return TRUE;
}
int
gnc_module_end(int refcount)
{
- int unload = TRUE;
+ int unload = TRUE;
- if (engine)
- unload = gnc_module_unload(engine);
+ if( engine != NULL ) {
+ unload = gnc_module_unload(engine);
+ }
- if (refcount == 0)
- engine = NULL;
+ if( refcount == 0 ) {
+ engine = NULL;
+ }
- return unload;
+ return unload;
}
Added: gnucash/trunk/src/backend/sql/.splintrc
===================================================================
--- gnucash/trunk/src/backend/sql/.splintrc (rev 0)
+++ gnucash/trunk/src/backend/sql/.splintrc 2009-03-09 17:17:57 UTC (rev 17983)
@@ -0,0 +1,39 @@
+-DHAVE_CONFIG_H
+-I.
+-I../../..
+-DG_LOG_DOMAIN="gnc.backend.sql"
+-I..
+-I../..
+-DLOCALE_DIR="/opt/gnucash2-svn/share/locale"
+-I../../../src/backend
+-I../../../src/engine
+-I../../../src/core-utils
+-I../../../lib/libc
+-I../../../lib/libqof/qof
+-I../../../lib/libqof/qof
+-I/usr/include/glib-2.0
+-I/usr/lib/glib-2.0/include
+-DORBIT2=1
+-I/usr/include/gconf/2
+-I/usr/include/orbit-2.0
+-I/usr/include/dbus-1.0
+-I/usr/lib/dbus-1.0/include
+-I/usr/include/glib-2.0
+-I/usr/lib/glib-2.0/include
+-D_FORTIFY_SOURCE=2
+
++posixlib
+
+# Needed for programs using glib typedefs
+-booltype gboolean
+
+# Extra flags about stuff we don't want to worry about right now
+-dependenttrans
+-branchstate
+-fcnuse
+-temptrans
+-exportlocal
+-unqualifiedtrans
+-onlytrans
+-usedef
+-compmempass
Modified: gnucash/trunk/src/backend/sql/gnc-account-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-account-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-account-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -42,14 +42,18 @@
#include "gnc-slots-sql.h"
#include "gnc-transaction-sql.h"
+#if defined( S_SPLINT_S )
+#include "splint-defs.h"
+#endif
+
static QofLogModule log_module = G_LOG_DOMAIN;
#define TABLE_NAME "accounts"
#define TABLE_VERSION 1
-static gpointer get_parent( gpointer pObject, const QofParam* );
-static void set_parent( gpointer pObject, gpointer pValue );
-static void set_parent_guid( gpointer pObject, gpointer pValue );
+static /*@ null @*//*@ dependent @*/ gpointer get_parent( gpointer pObject );
+static void set_parent( gpointer pObject, /*@ null @*/ gpointer pValue );
+static void set_parent_guid( gpointer pObject, /*@ null @*/ gpointer pValue );
#define ACCOUNT_MAX_NAME_LEN 2048
#define ACCOUNT_MAX_TYPE_LEN 2048
@@ -58,36 +62,37 @@
static const GncSqlColumnTableEntry col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "name", CT_STRING, ACCOUNT_MAX_NAME_LEN, COL_NNUL, "name" },
{ "account_type", CT_STRING, ACCOUNT_MAX_TYPE_LEN, COL_NNUL, NULL, ACCOUNT_TYPE_ },
{ "commodity_guid", CT_COMMODITYREF, 0, COL_NNUL, "commodity" },
{ "commodity_scu", CT_INT, 0, COL_NNUL, "commodity-scu" },
{ "non_std_scu", CT_BOOLEAN, 0, COL_NNUL, "non-std-scu" },
- { "parent_guid", CT_GUID, 0, 0, NULL, NULL, get_parent, set_parent },
+ { "parent_guid", CT_GUID, 0, 0, NULL, NULL,
+ (QofAccessFunc)get_parent, set_parent },
{ "code", CT_STRING, ACCOUNT_MAX_CODE_LEN, 0, "code" },
{ "description", CT_STRING, ACCOUNT_MAX_DESCRIPTION_LEN, 0, "description" },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
static GncSqlColumnTableEntry parent_col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "parent_guid", CT_GUID, 0, 0, NULL, NULL, NULL, set_parent_guid },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
typedef struct {
- Account* pAccount;
+ /*@ dependent @*/ Account* pAccount;
GUID guid;
} account_parent_guid_struct;
/* ================================================================= */
-static gpointer
-get_parent( gpointer pObject, const QofParam* param )
+static /*@ null @*//*@ dependent @*/ gpointer
+get_parent( gpointer pObject )
{
const Account* pAccount;
const Account* pParent;
@@ -108,7 +113,7 @@
}
static void
-set_parent( gpointer pObject, gpointer pValue )
+set_parent( gpointer pObject, /*@ null @*/ gpointer pValue )
{
Account* pAccount;
QofBook* pBook;
@@ -129,7 +134,7 @@
}
static void
-set_parent_guid( gpointer pObject, gpointer pValue )
+set_parent_guid( gpointer pObject, /*@ null @*/ gpointer pValue )
{
account_parent_guid_struct* s = (account_parent_guid_struct*)pObject;
GUID* guid = (GUID*)pValue;
@@ -140,22 +145,21 @@
s->guid = *guid;
}
-static Account*
+static /*@ dependent @*//*@ null @*/ Account*
load_single_account( GncSqlBackend* be, GncSqlRow* row,
GList** l_accounts_needing_parents )
{
const GUID* guid;
- GUID acc_guid;
- Account* pAccount;
+ Account* pAccount = NULL;
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( row != NULL, NULL );
g_return_val_if_fail( l_accounts_needing_parents != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
- acc_guid = *guid;
-
- pAccount = xaccAccountLookup( &acc_guid, be->primary_book );
+ if( guid != NULL ) {
+ pAccount = xaccAccountLookup( guid, be->primary_book );
+ }
if( pAccount == NULL ) {
pAccount = xaccMallocAccount( be->primary_book );
}
@@ -167,6 +171,8 @@
been loaded yet. Remember the account and its parent guid for later. */
if( gnc_account_get_parent( pAccount ) == NULL ) {
account_parent_guid_struct* s = g_malloc( (gsize)sizeof(account_parent_guid_struct) );
+ g_assert( s != NULL );
+
s->pAccount = pAccount;
gnc_sql_load_object( be, row, GNC_ID_ACCOUNT, s, parent_col_table );
*l_accounts_needing_parents = g_list_prepend( *l_accounts_needing_parents, s );
@@ -195,6 +201,10 @@
pTable = gnc_commodity_table_get_table( pBook );
stmt = gnc_sql_create_select_statement( be, TABLE_NAME );
+ if( stmt == NULL ) {
+ LEAVE( "stmt == NULL" );
+ return;
+ }
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -212,6 +222,7 @@
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
+ g_list_free( list );
}
/* While there are items on the list of accounts needing parents,
@@ -262,7 +273,9 @@
NULL);
}
- g_slist_free( bal_slist );
+ if( bal_slist != NULL ) {
+ g_slist_free( bal_slist );
+ }
}
LEAVE( "" );
@@ -290,6 +303,7 @@
const GUID* guid;
gboolean is_infant;
gboolean is_ok = FALSE;
+ gnc_commodity* commodity;
g_return_val_if_fail( be != NULL, FALSE );
g_return_val_if_fail( inst != NULL, FALSE );
@@ -303,7 +317,8 @@
// has been entered directly into the register and an account window will
// be opened. The account info is not complete yet, but the name has been
// set, triggering this commit
- if( xaccAccountGetCommodity( pAcc ) != NULL ) {
+ commodity = xaccAccountGetCommodity( pAcc );
+ if( commodity != NULL ) {
gint op;
is_ok = TRUE;
@@ -317,7 +332,7 @@
// If not deleting the account, ensure the commodity is in the db
if( op != OP_DB_DELETE ) {
- is_ok = gnc_sql_save_commodity( be, xaccAccountGetCommodity( pAcc ) );
+ is_ok = gnc_sql_save_commodity( be, commodity );
}
if( is_ok ) {
@@ -343,7 +358,7 @@
/* ================================================================= */
static void
load_account_guid( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -360,17 +375,20 @@
if( val == NULL ) {
pGuid = NULL;
} else {
- string_to_guid( g_value_get_string( val ), &guid );
+ (void)string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid;
}
if( pGuid != NULL ) {
account = xaccAccountLookup( pGuid, be->primary_book );
}
- if( table_row->gobj_param_name != NULL ) {
- g_object_set( pObject, table_row->gobj_param_name, account, NULL );
- } else {
- (*setter)( pObject, (const gpointer)account );
- }
+ if( account != NULL ) {
+ if( table_row->gobj_param_name != NULL ) {
+ g_object_set( pObject, table_row->gobj_param_name, account, NULL );
+ } else {
+ g_return_if_fail( setter != NULL );
+ (*setter)( pObject, (const gpointer)account );
+ }
+ }
}
static GncSqlColumnTypeHandler account_guid_handler
@@ -395,7 +413,7 @@
NULL /* write */
};
- qof_object_register_backend( GNC_ID_ACCOUNT, GNC_SQL_BACKEND, &be_data );
+ (void)qof_object_register_backend( GNC_ID_ACCOUNT, GNC_SQL_BACKEND, &be_data );
gnc_sql_register_col_type_handler( CT_ACCOUNTREF, &account_guid_handler );
}
Modified: gnucash/trunk/src/backend/sql/gnc-backend-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-backend-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-backend-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -59,6 +59,10 @@
#include "gnc-slots-sql.h"
#include "gnc-transaction-sql.h"
+#if defined( S_SPLINT_S )
+#include "splint-defs.h"
+#endif
+
#if 0
static const gchar* convert_search_obj( QofIdType objType );
#endif
@@ -66,15 +70,15 @@
static void update_save_progress( GncSqlBackend* be );
static void register_standard_col_type_handlers( void );
static gboolean reset_version_info( GncSqlBackend* be );
-static GncSqlStatement* build_insert_statement( GncSqlBackend* be,
+/*@ null @*/ static GncSqlStatement* build_insert_statement( GncSqlBackend* be,
const gchar* table_name,
QofIdTypeConst obj_name, gpointer pObject,
const GncSqlColumnTableEntry* table );
-static GncSqlStatement* build_update_statement( GncSqlBackend* be,
+/*@ null @*/ static GncSqlStatement* build_update_statement( GncSqlBackend* be,
const gchar* table_name,
QofIdTypeConst obj_name, gpointer pObject,
const GncSqlColumnTableEntry* table );
-static GncSqlStatement* build_delete_statement( GncSqlBackend* be,
+/*@ null @*/ static GncSqlStatement* build_delete_statement( GncSqlBackend* be,
const gchar* table_name,
QofIdTypeConst obj_name, gpointer pObject,
const GncSqlColumnTableEntry* table );
@@ -82,19 +86,19 @@
#define TRANSACTION_NAME "trans"
typedef struct {
- QofIdType searchObj;
- gpointer pCompiledQuery;
+ /*@ dependent @*/ QofIdType searchObj;
+ /*@ dependent @*/ gpointer pCompiledQuery;
} gnc_sql_query_info;
/* callback structure */
typedef struct {
gboolean is_known;
gboolean is_ok;
- GncSqlBackend* be;
- QofInstance* inst;
- QofQuery* pQuery;
- gpointer pCompiledQuery;
- gnc_sql_query_info* pQueryInfo;
+ /*@ dependent @*/ GncSqlBackend* be;
+ /*@ dependent @*/ QofInstance* inst;
+ /*@ dependent @*/ QofQuery* pQuery;
+ /*@ dependent @*/ gpointer pCompiledQuery;
+ /*@ owned @*/ gnc_sql_query_info* pQueryInfo;
} sql_backend;
static QofLogModule log_module = G_LOG_DOMAIN;
@@ -105,7 +109,7 @@
/* ================================================================= */
void
-gnc_sql_init( GncSqlBackend* be )
+gnc_sql_init( /*@ unused @*/ GncSqlBackend* be )
{
static gboolean initialized = FALSE;
@@ -135,20 +139,21 @@
/* ================================================================= */
static const gchar* fixed_load_order[] =
-{ GNC_ID_BOOK, GNC_ID_COMMODITY, GNC_ID_ACCOUNT, GNC_ID_LOT, NULL };
+{ GNC_ID_BOOK, GNC_ID_COMMODITY, GNC_ID_ACCOUNT, GNC_ID_LOT };
+#define NUM_FIXED_LOAD_ORDER (gint)(sizeof(fixed_load_order)/sizeof(fixed_load_order[0]))
static void
initial_load_cb( const gchar* type, gpointer data_p, gpointer be_p )
{
GncSqlObjectBackend* pData = data_p;
GncSqlBackend* be = be_p;
- int i;
+ gint i;
g_return_if_fail( type != NULL && data_p != NULL && be_p != NULL );
g_return_if_fail( pData->version == GNC_SQL_BACKEND_VERSION );
// Don't need to load anything if it has already been loaded with the fixed order
- for( i = 0; fixed_load_order[i] != NULL; i++ ) {
+ for( i = 0; i < NUM_FIXED_LOAD_ORDER; i++ ) {
if( g_ascii_strcasecmp( type, fixed_load_order[i] ) == 0 ) return;
}
@@ -158,10 +163,10 @@
}
void
-gnc_sql_load( GncSqlBackend* be, QofBook *book, QofBackendLoadType loadType )
+gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoadType loadType )
{
GncSqlObjectBackend* pData;
- int i;
+ gint i;
Account* root;
g_return_if_fail( be != NULL );
@@ -172,11 +177,11 @@
be->loading = TRUE;
if( loadType == LOAD_TYPE_INITIAL_LOAD ) {
- /*# -ifempty */ g_assert( be->primary_book == NULL );
+ g_assert( be->primary_book == NULL );
be->primary_book = book;
/* Load any initial stuff. Some of this needs to happen in a certain order */
- for( i = 0; fixed_load_order[i] != NULL; i++ ) {
+ for( i = 0; i < NUM_FIXED_LOAD_ORDER; i++ ) {
pData = qof_object_lookup_backend( fixed_load_order[i], GNC_SQL_BACKEND );
if( pData->initial_load != NULL ) {
(pData->initial_load)( be );
@@ -257,7 +262,7 @@
write_account_tree( GncSqlBackend* be, Account* root )
{
GList* descendants;
- GList* node;
+ /*@ dependent @*/ GList* node;
gboolean is_ok = TRUE;
g_return_val_if_fail( be != NULL, FALSE );
@@ -308,7 +313,7 @@
data.be = be;
data.is_ok = TRUE;
- xaccAccountTreeForEachTransaction( gnc_book_get_root_account( be->primary_book ),
+ (void)xaccAccountTreeForEachTransaction( gnc_book_get_root_account( be->primary_book ),
write_tx,
&data );
return data.is_ok;
@@ -323,12 +328,12 @@
g_return_val_if_fail( be != NULL, FALSE );
data.is_ok = TRUE;
+ data.be = be;
ra = gnc_book_get_template_root( be->primary_book );
if( gnc_account_n_descendants( ra ) > 0 ) {
data.is_ok = write_account_tree( be, ra );
if( data.is_ok ) {
- data.be = be;
- xaccAccountTreeForEachTransaction( ra, write_tx, &data );
+ (void)xaccAccountTreeForEachTransaction( ra, write_tx, &data );
}
}
@@ -364,7 +369,7 @@
g_return_if_fail( pData->version == GNC_SQL_BACKEND_VERSION );
if( pData->write != NULL ) {
- (pData->write)( be );
+ (void)(pData->write)( be );
}
}
@@ -384,7 +389,7 @@
}
void
-gnc_sql_sync_all( GncSqlBackend* be, QofBook *book )
+gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book )
{
gboolean is_ok;
@@ -393,7 +398,7 @@
ENTER( "book=%p, primary=%p", book, be->primary_book );
- reset_version_info( be );
+ (void)reset_version_info( be );
/* Create new tables */
be->is_pristine_db = TRUE;
@@ -406,7 +411,7 @@
be->obj_total += gnc_book_count_transactions( book );
be->operations_done = 0;
- gnc_sql_connection_begin_transaction( be->conn );
+ (void)gnc_sql_connection_begin_transaction( be->conn );
// FIXME: should write the set of commodities that are used
//write_commodities( be, book );
@@ -427,7 +432,7 @@
qof_object_foreach_backend( GNC_SQL_BACKEND, write_cb, be );
}
- gnc_sql_connection_commit_transaction( be->conn );
+ (void)gnc_sql_connection_commit_transaction( be->conn );
be->is_pristine_db = FALSE;
// Mark the book as clean
@@ -515,16 +520,17 @@
return;
}
- gnc_sql_connection_begin_transaction( be->conn );
+ (void)gnc_sql_connection_begin_transaction( be->conn );
be_data.is_known = FALSE;
be_data.be = be;
be_data.inst = inst;
+ be_data.is_ok = TRUE;
qof_object_foreach_backend( GNC_SQL_BACKEND, commit_cb, &be_data );
if( !be_data.is_known ) {
PERR( "gnc_sql_commit_edit(): Unknown object type '%s'\n", inst->e_type );
- gnc_sql_connection_rollback_transaction( be->conn );
+ (void)gnc_sql_connection_rollback_transaction( be->conn );
// Don't let unknown items still mark the book as being dirty
qof_instance_mark_clean(inst);
@@ -534,14 +540,14 @@
}
if( !be_data.is_ok ) {
// Error - roll it back
- gnc_sql_connection_rollback_transaction( be->conn );
+ (void)gnc_sql_connection_rollback_transaction( be->conn );
// This *should* leave things marked dirty
LEAVE( "Rolled back - database error" );
return;
}
- gnc_sql_connection_commit_transaction( be->conn );
+ (void)gnc_sql_connection_commit_transaction( be->conn );
qof_instance_mark_clean(inst);
qof_book_mark_saved( be->primary_book );
@@ -671,7 +677,7 @@
}
}
-gpointer
+/*@ null @*/ gpointer
gnc_sql_compile_query( QofBackend* pBEnd, QofQuery* pQuery )
{
GncSqlBackend *be = (GncSqlBackend*)pBEnd;
@@ -687,6 +693,7 @@
searchObj = qof_query_get_search_for( pQuery );
pQueryInfo = g_malloc( (gsize)sizeof( gnc_sql_query_info ) );
+ g_assert( pQueryInfo != NULL );
// Try various objects first
be_data.is_ok = FALSE;
@@ -890,20 +897,20 @@
}
/* ----------------------------------------------------------------- */
-static gpointer
-get_autoinc_id( gpointer pObject, const QofParam* param )
+/*@ null @*/ static gpointer
+get_autoinc_id()
{
// Just need a 0 to force a new recurrence id
return (gpointer)0;
}
static void
-set_autoinc_id( gpointer pObject, gpointer pValue )
+set_autoinc_id()
{
// Nowhere to put the ID
}
-QofAccessFunc
+/*@ null @*/ QofAccessFunc
gnc_sql_get_getter( QofIdTypeConst obj_name, const GncSqlColumnTableEntry* table_row )
{
QofAccessFunc getter;
@@ -951,11 +958,12 @@
GncSqlColumnInfo* info;
info = g_new0( GncSqlColumnInfo, 1 );
- info->name = table_row->col_name;
+ g_assert( info != NULL );
+ info->name = g_strdup( table_row->col_name );
info->type = type;
info->size = size;
- info->is_primary_key = (table_row->flags & COL_PKEY) ? TRUE : FALSE;
- info->null_allowed = (table_row->flags & COL_NNUL) ? FALSE : TRUE;
+ info->is_primary_key = ((table_row->flags & COL_PKEY) != 0) ? TRUE : FALSE;
+ info->null_allowed = ((table_row->flags & COL_NNUL) != 0) ? FALSE : TRUE;
info->is_unicode = is_unicode;
return info;
@@ -964,7 +972,7 @@
/* ----------------------------------------------------------------- */
static void
load_string( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -976,14 +984,12 @@
g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
- if( val == NULL ) {
- s = NULL;
- } else {
- s = g_value_get_string( val );
- }
+ g_return_if_fail( val != NULL );
+ s = g_value_get_string( val );
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, s, NULL );
} else {
+ g_return_if_fail( setter != NULL );
(*setter)( pObject, (const gpointer)s );
}
}
@@ -1008,8 +1014,8 @@
const gpointer pObject, const GncSqlColumnTableEntry* table_row, GSList** pList )
{
QofAccessFunc getter;
- gchar* s;
- GValue* value = g_new0( GValue, 1 );
+ gchar* s = NULL;
+ GValue* value;
g_return_if_fail( be != NULL );
g_return_if_fail( obj_name != NULL );
@@ -1017,12 +1023,16 @@
g_return_if_fail( table_row != NULL );
g_return_if_fail( pList != NULL );
+ value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
memset( value, 0, sizeof( GValue ) );
if( table_row->gobj_param_name != NULL ) {
g_object_get( pObject, table_row->gobj_param_name, &s, NULL );
} else {
getter = gnc_sql_get_getter( obj_name, table_row );
- s = (gchar*)(*getter)( pObject, NULL );
+ if( getter != NULL ) {
+ s = (gchar*)(*getter)( pObject, NULL );
+ }
}
(void)g_value_init( value, G_TYPE_STRING );
if( s ) {
@@ -1043,7 +1053,7 @@
static void
load_int( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -1064,6 +1074,7 @@
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, int_value, NULL );
} else {
+ g_return_if_fail( setter != NULL );
i_setter = (IntSetterFunc)setter;
(*i_setter)( pObject, int_value );
}
@@ -1088,7 +1099,7 @@
add_gvalue_int_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
const gpointer pObject, const GncSqlColumnTableEntry* table_row, GSList** pList )
{
- gint int_value;
+ gint int_value = 0;
IntAccessFunc i_getter;
GValue* value;
@@ -1099,13 +1110,16 @@
g_return_if_fail( pList != NULL );
value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
(void)g_value_init( value, G_TYPE_INT );
if( table_row->gobj_param_name != NULL ) {
g_object_get_property( pObject, table_row->gobj_param_name, value );
} else {
i_getter = (IntAccessFunc)gnc_sql_get_getter( obj_name, table_row );
- int_value = (*i_getter)( pObject );
+ if( i_getter != NULL ) {
+ int_value = (*i_getter)( pObject );
+ }
g_value_set_int( value, int_value );
}
@@ -1123,7 +1137,7 @@
static void
load_boolean( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -1144,8 +1158,9 @@
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, int_value, NULL );
} else {
+ g_return_if_fail( setter != NULL );
b_setter = (BooleanSetterFunc)setter;
- (*b_setter)( pObject, int_value ? TRUE : FALSE );
+ (*b_setter)( pObject, (int_value != 0) ? TRUE : FALSE );
}
}
@@ -1168,7 +1183,7 @@
add_gvalue_boolean_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
const gpointer pObject, const GncSqlColumnTableEntry* table_row, GSList** pList )
{
- gint int_value;
+ gint int_value = 0;
BooleanAccessFunc b_getter;
GValue* value;
@@ -1179,12 +1194,15 @@
g_return_if_fail( pList != NULL );
value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
if( table_row->gobj_param_name != NULL ) {
g_object_get( pObject, table_row->gobj_param_name, &int_value, NULL );
} else {
b_getter = (BooleanAccessFunc)gnc_sql_get_getter( obj_name, table_row );
- int_value = ((*b_getter)( pObject )) ? 1 : 0;
+ if( b_getter != NULL ) {
+ int_value = ((*b_getter)( pObject )) ? 1 : 0;
+ }
}
(void)g_value_init( value, G_TYPE_INT );
g_value_set_int( value, int_value );
@@ -1203,7 +1221,7 @@
static void
load_int64( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -1242,7 +1260,7 @@
add_gvalue_int64_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
const gpointer pObject, const GncSqlColumnTableEntry* table_row, GSList** pList )
{
- gint64 i64_value;
+ gint64 i64_value = 0;
Int64AccessFunc getter;
GValue* value;
@@ -1253,11 +1271,14 @@
g_return_if_fail( pList != NULL );
value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
if( table_row->gobj_param_name != NULL ) {
g_object_get( pObject, table_row->gobj_param_name, &i64_value, NULL );
} else {
getter = (Int64AccessFunc)gnc_sql_get_getter( obj_name, table_row );
- i64_value = (*getter)( pObject );
+ if( getter != NULL ) {
+ i64_value = (*getter)( pObject );
+ }
}
(void)g_value_init( value, G_TYPE_INT64 );
g_value_set_int64( value, i64_value );
@@ -1274,7 +1295,7 @@
static void
load_double( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -1282,6 +1303,7 @@
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
+ g_return_if_fail( setter != NULL );
g_return_if_fail( pObject != NULL );
g_return_if_fail( table_row != NULL );
@@ -1318,7 +1340,7 @@
const gpointer pObject, const GncSqlColumnTableEntry* table_row, GSList** pList )
{
QofAccessFunc getter;
- gdouble* pDouble;
+ gdouble* pDouble = NULL;
gdouble d_value;
GValue* value;
@@ -1328,8 +1350,11 @@
g_return_if_fail( table_row != NULL );
value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
getter = gnc_sql_get_getter( obj_name, table_row );
- pDouble = (*getter)( pObject, NULL );
+ if( getter != NULL ) {
+ pDouble = (*getter)( pObject, NULL );
+ }
if( pDouble != NULL ) {
d_value = *pDouble;
(void)g_value_init( value, G_TYPE_DOUBLE );
@@ -1351,7 +1376,7 @@
static void
load_guid( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -1367,13 +1392,16 @@
if( val == NULL ) {
pGuid = NULL;
} else {
- string_to_guid( g_value_get_string( val ), &guid );
+ (void)string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid;
}
- if( table_row->gobj_param_name != NULL ) {
- g_object_set( pObject, table_row->gobj_param_name, pGuid, NULL );
- } else {
- (*setter)( pObject, (const gpointer)pGuid );
+ if( pGuid != NULL ) {
+ if( table_row->gobj_param_name != NULL ) {
+ g_object_set( pObject, table_row->gobj_param_name, pGuid, NULL );
+ } else {
+ g_return_if_fail( setter != NULL );
+ (*setter)( pObject, (const gpointer)pGuid );
+ }
}
}
@@ -1397,7 +1425,7 @@
const gpointer pObject, const GncSqlColumnTableEntry* table_row, GSList** pList )
{
QofAccessFunc getter;
- const GUID* guid;
+ const GUID* guid = NULL;
gchar guid_buf[GUID_ENCODING_LENGTH+1];
GValue* value;
@@ -1407,11 +1435,14 @@
g_return_if_fail( table_row != NULL );
value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
if( table_row->gobj_param_name != NULL ) {
g_object_get( pObject, table_row->gobj_param_name, &guid, NULL );
} else {
getter = gnc_sql_get_getter( obj_name, table_row );
- guid = (*getter)( pObject, NULL );
+ if( getter != NULL ) {
+ guid = (*getter)( pObject, NULL );
+ }
}
(void)g_value_init( value, G_TYPE_STRING );
if( guid != NULL ) {
@@ -1436,7 +1467,7 @@
QofAccessFunc getter;
const GUID* guid = NULL;
gchar guid_buf[GUID_ENCODING_LENGTH+1];
- QofInstance* inst;
+ QofInstance* inst = NULL;
GValue* value;
g_return_if_fail( be != NULL );
@@ -1445,11 +1476,14 @@
g_return_if_fail( table_row != NULL );
value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
if( table_row->gobj_param_name != NULL ) {
g_object_get( pObject, table_row->gobj_param_name, &inst, NULL );
} else {
getter = gnc_sql_get_getter( obj_name, table_row );
- inst = (*getter)( pObject, NULL );
+ if( getter != NULL ) {
+ inst = (*getter)( pObject, NULL );
+ }
}
if( inst != NULL ) {
guid = qof_instance_get_guid( inst );
@@ -1480,7 +1514,7 @@
static void
load_timespec( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -1489,6 +1523,7 @@
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
+ g_return_if_fail( setter != NULL );
g_return_if_fail( pObject != NULL );
g_return_if_fail( table_row != NULL );
@@ -1550,8 +1585,8 @@
g_return_if_fail( table_row != NULL );
g_return_if_fail( pList != NULL );
- value = g_new0( GValue, 1 );
ts_getter = (TimespecAccessFunc)gnc_sql_get_getter( obj_name, table_row );
+ g_return_if_fail( ts_getter != NULL );
ts = (*ts_getter)( pObject );
time = timespecToTime_t( ts );
@@ -1562,6 +1597,8 @@
datebuf = g_strdup_printf( TIMESPEC_STR_FORMAT,
year, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec );
+ value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
(void)g_value_init( value, G_TYPE_STRING );
g_value_take_string( value, datebuf );
@@ -1578,7 +1615,7 @@
static void
load_date( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -1586,12 +1623,13 @@
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
+ g_return_if_fail( setter != NULL );
g_return_if_fail( pObject != NULL );
g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
if( val == NULL ) {
- date = g_date_new_dmy( 1, 1, 1970 );
+ date = g_date_new_dmy( (GDateDay)1, 1, 1970 );
(*setter)( pObject, date );
g_date_free( date );
} else {
@@ -1599,7 +1637,8 @@
// Format of date is YYYYMMDD
const gchar* s = g_value_get_string( val );
gchar buf[5];
- guint month, day;
+ GDateDay day;
+ guint month;
GDateYear year;
strncpy( buf, &s[0], 4 );
@@ -1608,9 +1647,9 @@
strncpy( buf, &s[4], 2 );
buf[2] = '\0';
month = (guint)atoi( buf );
- day = (guint)atoi( &s[6] );
+ day = (GDateDay)atoi( &s[6] );
- if( year != 0 || month != 0 || day != 0 ) {
+ if( year != 0 || month != 0 || day != (GDateDay)0 ) {
date = g_date_new_dmy( day, month, year );
(*setter)( pObject, date );
g_date_free( date );
@@ -1652,12 +1691,15 @@
g_return_if_fail( table_row != NULL );
value = g_new0( GValue, 1 );
+ g_assert( value != NULL );
getter = gnc_sql_get_getter( obj_name, table_row );
- date = (GDate*)(*getter)( pObject, NULL );
- buf = g_strdup_printf( "%04d%02d%02d",
+ if( getter != NULL ) {
+ date = (GDate*)(*getter)( pObject, NULL );
+ buf = g_strdup_printf( "%04d%02d%02d",
g_date_get_year( date ), g_date_get_month( date ), g_date_get_day( date ) );
- (void)g_value_init( value, G_TYPE_STRING );
- g_value_take_string( value, buf );
+ (void)g_value_init( value, G_TYPE_STRING );
+ g_value_take_string( value, buf );
+ }
(*pList) = g_slist_append( (*pList), value );
}
@@ -1673,16 +1715,16 @@
static const GncSqlColumnTableEntry numeric_col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "num", CT_INT64, 0, COL_NNUL, "guid" },
{ "denom", CT_INT64, 0, COL_NNUL, "guid" },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
static void
load_numeric( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
@@ -1694,6 +1736,7 @@
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
+ g_return_if_fail( setter != NULL );
g_return_if_fail( pObject != NULL );
g_return_if_fail( table_row != NULL );
@@ -1736,10 +1779,11 @@
for( subtable_row = numeric_col_table; subtable_row->col_name != NULL; subtable_row++ ) {
buf = g_strdup_printf( "%s_%s", table_row->col_name, subtable_row->col_name );
info = g_new0( GncSqlColumnInfo, 1 );
+ g_assert( info != NULL );
info->name = buf;
info->type = G_TYPE_INT64;
- info->is_primary_key = (table_row->flags & COL_PKEY) ? TRUE : FALSE;
- info->null_allowed = (table_row->flags & COL_NNUL) ? FALSE : TRUE;
+ info->is_primary_key = ((table_row->flags & COL_PKEY) != 0) ? TRUE : FALSE;
+ info->null_allowed = ((table_row->flags & COL_NNUL) != 0) ? FALSE : TRUE;
info->is_unicode = FALSE;
*pList = g_list_append( *pList, info );
}
@@ -1769,13 +1813,19 @@
// g_object_get( pObject, table_row->gobj_param_name, &s, NULL );
// } else {
getter = (NumericGetterFunc)gnc_sql_get_getter( obj_name, table_row );
- n = (*getter)( pObject );
+ if( getter != NULL ) {
+ n = (*getter)( pObject );
+ } else {
+ n = gnc_numeric_zero();
+ }
// }
num_value = g_new0( GValue, 1 );
+ g_assert( num_value != NULL );
(void)g_value_init( num_value, G_TYPE_INT64 );
g_value_set_int64( num_value, gnc_numeric_num( n ) );
denom_value = g_new0( GValue, 1 );
+ g_assert( denom_value != NULL );
(void)g_value_init( denom_value, G_TYPE_INT64 );
g_value_set_int64( denom_value, gnc_numeric_denom( n ) );
@@ -1790,7 +1840,7 @@
add_gvalue_numeric_to_slist };
/* ================================================================= */
-static GHashTable* g_columnTypeHash = NULL;
+static /*@ null @*//*@ only @*/ GHashTable* g_columnTypeHash = NULL;
void
gnc_sql_register_col_type_handler( const gchar* colType, const GncSqlColumnTypeHandler* handler )
@@ -1800,13 +1850,14 @@
if( g_columnTypeHash == NULL ) {
g_columnTypeHash = g_hash_table_new( g_str_hash, g_str_equal );
+ g_assert( g_columnTypeHash != NULL );
}
+ DEBUG( "Col type %s registered\n", colType );
g_hash_table_insert( g_columnTypeHash, (gpointer)colType, (gpointer)handler );
- DEBUG( "Col type %s registered\n", colType );
}
-static GncSqlColumnTypeHandler*
+/*@ dependent @*//*@ null @*/ static GncSqlColumnTypeHandler*
get_handler( const GncSqlColumnTableEntry* table_row )
{
GncSqlColumnTypeHandler* pHandler;
@@ -1814,10 +1865,12 @@
g_return_val_if_fail( table_row != NULL, NULL );
g_return_val_if_fail( table_row->col_type != NULL, NULL );
- pHandler = g_hash_table_lookup( g_columnTypeHash, table_row->col_type );
- if( pHandler == NULL ) {
- g_assert( FALSE );
- }
+ if( g_columnTypeHash != NULL ) {
+ pHandler = g_hash_table_lookup( g_columnTypeHash, table_row->col_type );
+ g_assert( pHandler != NULL );
+ } else {
+ pHandler = NULL;
+ }
return pHandler;
}
@@ -1837,7 +1890,7 @@
}
void
-_retrieve_guid_( gpointer pObject, gpointer pValue )
+_retrieve_guid_( gpointer pObject, /*@ null @*/ gpointer pValue )
{
GUID* pGuid = (GUID*)pObject;
GUID* guid = (GUID*)pValue;
@@ -1852,13 +1905,13 @@
// Table to retrieve just the guid
static GncSqlColumnTableEntry guid_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, 0, NULL, NULL, NULL, _retrieve_guid_ },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
-const GUID*
+/*@ null @*/ const GUID*
gnc_sql_load_guid( const GncSqlBackend* be, GncSqlRow* row )
{
static GUID guid;
@@ -1874,13 +1927,13 @@
// Table to retrieve just the guid
static GncSqlColumnTableEntry tx_guid_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "tx_guid", CT_GUID, 0, 0, NULL, NULL, NULL, _retrieve_guid_ },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
-const GUID*
+/*@ null @*//*@ dependent @*/ const GUID*
gnc_sql_load_tx_guid( const GncSqlBackend* be, GncSqlRow* row )
{
static GUID guid;
@@ -1895,7 +1948,7 @@
void
gnc_sql_load_object( const GncSqlBackend* be, GncSqlRow* row,
- QofIdTypeConst obj_name, gpointer pObject,
+ /*@ null @*/ QofIdTypeConst obj_name, gpointer pObject,
const GncSqlColumnTableEntry* table )
{
QofSetterFunc setter;
@@ -1911,47 +1964,55 @@
if( (table_row->flags & COL_AUTOINC) != 0 ) {
setter = set_autoinc_id;
} else if( table_row->qof_param_name != NULL ) {
+ g_assert( obj_name != NULL );
setter = qof_class_get_parameter_setter( obj_name,
table_row->qof_param_name );
} else {
setter = table_row->setter;
}
pHandler = get_handler( table_row );
+ g_assert( pHandler != NULL );
pHandler->load_fn( be, row, setter, pObject, table_row );
}
}
/* ================================================================= */
-GncSqlStatement*
+/*@ null @*/ GncSqlStatement*
gnc_sql_create_select_statement( GncSqlBackend* be, const gchar* table_name )
{
gchar* sql;
+ GncSqlStatement* stmt;
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( table_name != NULL, NULL );
sql = g_strdup_printf( "SELECT * FROM %s", table_name );
- return gnc_sql_create_statement_from_sql( be, sql );
+ stmt = gnc_sql_create_statement_from_sql( be, sql );
+ g_free( sql );
+ return stmt;
}
-static GncSqlStatement*
+/*@ null @*/ static GncSqlStatement*
create_single_col_select_statement( GncSqlBackend* be,
const gchar* table_name,
const GncSqlColumnTableEntry* table_row )
{
gchar* sql;
+ GncSqlStatement* stmt;
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( table_name != NULL, NULL );
g_return_val_if_fail( table_row != NULL, NULL );
sql = g_strdup_printf( "SELECT %s FROM %s", table_row->col_name, table_name );
- return gnc_sql_create_statement_from_sql( be, sql );
+ stmt = gnc_sql_create_statement_from_sql( be, sql );
+ g_free( sql );
+ return stmt;
}
/* ================================================================= */
-GncSqlResult*
+/*@ null @*/ GncSqlResult*
gnc_sql_execute_select_statement( GncSqlBackend* be, GncSqlStatement* stmt )
{
GncSqlResult* result;
@@ -1968,8 +2029,8 @@
return result;
}
-GncSqlStatement*
-gnc_sql_create_statement_from_sql( GncSqlBackend* be, gchar* sql )
+/*@ null @*/ GncSqlStatement*
+gnc_sql_create_statement_from_sql( GncSqlBackend* be, const gchar* sql )
{
GncSqlStatement* stmt;
@@ -1985,8 +2046,8 @@
return stmt;
}
-GncSqlResult*
-gnc_sql_execute_select_sql( GncSqlBackend* be, gchar* sql )
+/*@ null @*/ GncSqlResult*
+gnc_sql_execute_select_sql( GncSqlBackend* be, const gchar* sql )
{
GncSqlStatement* stmt;
GncSqlResult* result = NULL;
@@ -1999,6 +2060,7 @@
return NULL;
}
result = gnc_sql_connection_execute_select_statement( be->conn, stmt );
+ gnc_sql_statement_dispose( stmt );
if( result == NULL ) {
PERR( "SQL error: %s\n", sql );
qof_backend_set_error( &be->be, ERR_BACKEND_SERVER_ERR );
@@ -2008,7 +2070,7 @@
}
gint
-gnc_sql_execute_nonselect_sql( GncSqlBackend* be, gchar* sql )
+gnc_sql_execute_nonselect_sql( GncSqlBackend* be, const gchar* sql )
{
GncSqlStatement* stmt;
gint result;
@@ -2025,11 +2087,11 @@
return result;
}
-static int
+static guint
execute_statement_get_count( GncSqlBackend* be, GncSqlStatement* stmt )
{
GncSqlResult* result;
- int count = 0;
+ guint count = 0;
g_return_val_if_fail( be != NULL, 0 );
g_return_val_if_fail( stmt != NULL, 0 );
@@ -2077,7 +2139,7 @@
const GncSqlColumnTableEntry* table )
{
GncSqlStatement* sqlStmt;
- int count;
+ guint count;
GncSqlColumnTypeHandler* pHandler;
GSList* list = NULL;
@@ -2089,10 +2151,13 @@
/* SELECT * FROM */
sqlStmt = create_single_col_select_statement( be, table_name, table );
+ g_assert( sqlStmt != NULL );
/* WHERE */
pHandler = get_handler( table );
+ g_assert( pHandler != NULL );
pHandler->add_gvalue_to_slist_fn( be, obj_name, pObject, table, &list );
+ g_assert( list != NULL );
gnc_sql_statement_add_where_cond( sqlStmt, obj_name, pObject, &table[0], (GValue*)(list->data) );
count = execute_statement_get_count( be, sqlStmt );
@@ -2111,7 +2176,7 @@
QofIdTypeConst obj_name, gpointer pObject,
const GncSqlColumnTableEntry* table )
{
- GncSqlStatement* stmt;
+ GncSqlStatement* stmt = NULL;
gboolean ok = FALSE;
g_return_val_if_fail( be != NULL, FALSE );
@@ -2157,10 +2222,12 @@
for( table_row = table; table_row->col_name != NULL; table_row++ ) {
if(( table_row->flags & COL_AUTOINC ) == 0 ) {
pHandler = get_handler( table_row );
+ g_assert( pHandler != NULL );
pHandler->add_gvalue_to_slist_fn( be, obj_name, pObject, table_row, &list );
}
}
+ g_assert( list != NULL );
return list;
}
@@ -2194,8 +2261,10 @@
GValue* string;
gchar* str;
- string = g_value_init( g_new0( GValue, 1 ), G_TYPE_STRING );
- g_value_transform( value, string );
+ string = g_new0( GValue, 1 );
+ g_assert( string != NULL );
+ (void)g_value_init( string, G_TYPE_STRING );
+ (void)g_value_transform( value, string );
str = g_value_dup_string( string );
g_value_unset( string );
g_free( string );
@@ -2203,15 +2272,15 @@
return str;
} else {
PWARN( "not transformable, gtype = '%s'\n", g_type_name( type ) );
- return "$$$";
+ return g_strdup( "$$$" );
}
} else {
PWARN( "value is NULL or not G_IS_VALUE()\n" );
- return "";
+ return g_strdup( "" );
}
}
-static GncSqlStatement*
+/*@ null @*/ static GncSqlStatement*
build_insert_statement( GncSqlBackend* be,
const gchar* table_name,
QofIdTypeConst obj_name, gpointer pObject,
@@ -2249,10 +2318,12 @@
(void)g_string_append( sql, ")" );
stmt = gnc_sql_connection_create_statement_from_sql( be->conn, sql->str );
+ (void)g_string_free( sql, FALSE );
+
return stmt;
}
-static GncSqlStatement*
+/*@ null @*/ static GncSqlStatement*
build_update_statement( GncSqlBackend* be,
const gchar* table_name,
QofIdTypeConst obj_name, gpointer pObject,
@@ -2280,8 +2351,10 @@
// Add col names to the list
pHandler = get_handler( table_row );
+ g_assert( pHandler != NULL );
pHandler->add_colname_to_list_fn( table_row, &colnames );
}
+ g_assert( colnames != NULL );
values = create_gslist_from_values( be, obj_name, pObject, table );
// Create the SQL statement
@@ -2312,11 +2385,12 @@
stmt = gnc_sql_connection_create_statement_from_sql( be->conn, sql->str );
gnc_sql_statement_add_where_cond( stmt, obj_name, pObject, &table[0], (GValue*)(values->data) );
g_slist_free( values );
+ (void)g_string_free( sql, FALSE );
return stmt;
}
-static GncSqlStatement*
+/*@ null @*/ static GncSqlStatement*
build_delete_statement( GncSqlBackend* be,
const gchar* table_name,
QofIdTypeConst obj_name, gpointer pObject,
@@ -2338,10 +2412,13 @@
sql = g_string_new( sqlbuf );
g_free( sqlbuf );
stmt = gnc_sql_connection_create_statement_from_sql( be->conn, sql->str );
+ (void)g_string_free( sql, FALSE );
/* WHERE */
pHandler = get_handler( table );
+ g_assert( pHandler != NULL );
pHandler->add_gvalue_to_slist_fn( be, obj_name, pObject, table, &list );
+ g_assert( list != NULL );
gnc_sql_statement_add_where_cond( stmt, obj_name, pObject, &table[0], (GValue*)(list->data) );
return stmt;
@@ -2397,8 +2474,10 @@
GncSqlColumnTypeHandler* pHandler;
pHandler = get_handler( col_table );
+ g_assert( pHandler != NULL );
pHandler->add_col_info_to_list_fn( be, col_table, &col_info_list );
}
+ g_assert( col_info_list != NULL );
ok = gnc_sql_connection_create_table( be->conn, table_name, col_info_list );
return ok;
}
@@ -2484,16 +2563,19 @@
DEBUG( "Upgrading %s table\n", table_name );
temp_table_name = g_strdup_printf( "%s_new", table_name );
- gnc_sql_create_temp_table( be, temp_table_name, col_table );
+ (void)gnc_sql_create_temp_table( be, temp_table_name, col_table );
sql = g_strdup_printf( "INSERT INTO %s SELECT * FROM %s",
temp_table_name, table_name );
(void)gnc_sql_execute_nonselect_sql( be, sql );
+ g_free( sql );
sql = g_strdup_printf( "DROP TABLE %s", table_name );
(void)gnc_sql_execute_nonselect_sql( be, sql );
+ g_free( sql );
sql = g_strdup_printf( "ALTER TABLE %s RENAME TO %s", temp_table_name, table_name );
(void)gnc_sql_execute_nonselect_sql( be, sql );
+ g_free( sql );
g_free( temp_table_name );
}
@@ -2505,11 +2587,11 @@
static GncSqlColumnTableEntry version_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ TABLE_COL_NAME, CT_STRING, MAX_TABLE_NAME_LEN },
{ VERSION_COL_NAME, CT_INT },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/**
@@ -2523,6 +2605,9 @@
{
g_return_if_fail( be != NULL );
+ if( be->versions != NULL ) {
+ g_hash_table_destroy( be->versions );
+ }
be->versions = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, NULL );
if( gnc_sql_connection_does_table_exist( be->conn, VERSION_TABLE_NAME ) ) {
@@ -2531,6 +2616,7 @@
sql = g_strdup_printf( "SELECT * FROM %s", VERSION_TABLE_NAME );
result = gnc_sql_execute_select_sql( be, sql );
+ g_free( sql );
if( result != NULL ) {
const GValue* name;
const GValue* version;
@@ -2626,6 +2712,7 @@
PERR( "SQL error: %s\n", sql );
qof_backend_set_error( &be->be, ERR_BACKEND_SERVER_ERR );
}
+ g_free( sql );
}
g_hash_table_insert( be->versions, g_strdup( table_name ), GINT_TO_POINTER(version) );
Modified: gnucash/trunk/src/backend/sql/gnc-backend-sql.h
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-backend-sql.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-backend-sql.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -67,7 +67,7 @@
{
QofBackend be; /**< QOF backend */
GncSqlConnection* conn; /**< SQL connection */
- QofBook *primary_book; /**< The primary, main open book */
+ /*@ dependent @*/ QofBook *primary_book; /**< The primary, main open book */
gboolean loading; /**< We are performing an initial load */
gboolean in_query; /**< We are processing a query */
gboolean is_pristine_db; /**< Are we saving to a new pristine db? */
@@ -90,7 +90,7 @@
* @param be SQL backend
* @param book Book to be loaded
*/
-void gnc_sql_load( GncSqlBackend* be, QofBook *book, QofBackendLoadType loadType );
+void gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoadType loadType );
/**
* Save the contents of a book to an SQL database.
@@ -98,7 +98,7 @@
* @param be SQL backend
* @param book Book to be saved
*/
-void gnc_sql_sync_all( GncSqlBackend* be, QofBook *book );
+void gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book );
/**
* An object is about to be edited.
@@ -139,8 +139,8 @@
*/
struct GncSqlStatement
{
- void (*dispose)( GncSqlStatement* );
- gchar* (*toSql)( GncSqlStatement* );
+ void (*dispose)( /*@ only @*/ GncSqlStatement* );
+ /*@ dependent @*/ gchar* (*toSql)( GncSqlStatement* );
void (*addWhereCond)( GncSqlStatement*, QofIdTypeConst, gpointer, const GncSqlColumnTableEntry*, GValue* );
};
#define gnc_sql_statement_dispose(STMT) \
@@ -158,10 +158,10 @@
*/
struct GncSqlConnection
{
- void (*dispose)( GncSqlConnection* );
+ void (*dispose)( /*@ only @*/ GncSqlConnection* );
GncSqlResult* (*executeSelectStatement)( GncSqlConnection*, GncSqlStatement* ); /**< Returns NULL if error */
gint (*executeNonSelectStatement)( GncSqlConnection*, GncSqlStatement* ); /**< Returns -1 if error */
- GncSqlStatement* (*createStatementFromSql)( GncSqlConnection*, gchar* );
+ GncSqlStatement* (*createStatementFromSql)( /*@ observer @*/ GncSqlConnection*, const gchar* );
gboolean (*doesTableExist)( GncSqlConnection*, const gchar* );
gboolean (*beginTransaction)( GncSqlConnection* ); /**< Returns TRUE if successful, FALSE if error */
gboolean (*rollbackTransaction)( GncSqlConnection* ); /**< Returns TRUE if successful, FALSE if error */
@@ -204,7 +204,7 @@
struct GncSqlRow
{
const GValue* (*getValueAtColName)( GncSqlRow*, const gchar* );
- void (*dispose)( GncSqlRow* );
+ void (*dispose)( /*@ only @*/ GncSqlRow* );
};
#define gnc_sql_row_get_value_at_col_name(ROW,N) \
(ROW)->getValueAtColName(ROW,N)
@@ -219,10 +219,10 @@
*/
struct GncSqlResult
{
- gint (*getNumRows)( GncSqlResult* );
+ guint (*getNumRows)( GncSqlResult* );
GncSqlRow* (*getFirstRow)( GncSqlResult* );
GncSqlRow* (*getNextRow)( GncSqlResult* );
- void (*dispose)( GncSqlResult* );
+ void (*dispose)( /*@ only @*/ GncSqlResult* );
};
#define gnc_sql_result_get_num_rows(RESULT) \
(RESULT)->getNumRows(RESULT)
@@ -254,21 +254,21 @@
/** Commit an instance of this object to the database
* @return TRUE if successful, FALSE if error
*/
- gboolean (*commit)( GncSqlBackend* be, QofInstance* inst );
+ /*@ null @*/ gboolean (*commit)( GncSqlBackend* be, QofInstance* inst );
/** Load all objects of this type from the database */
- void (*initial_load)( GncSqlBackend* be );
+ /*@ null @*/ void (*initial_load)( GncSqlBackend* be );
/** Create database tables for this object */
- void (*create_tables)( GncSqlBackend* be );
+ /*@ null @*/ void (*create_tables)( GncSqlBackend* be );
/** Compile a query on these objects */
- gpointer (*compile_query)( GncSqlBackend* be, QofQuery* pQuery );
+ /*@ null @*/ gpointer (*compile_query)( GncSqlBackend* be, QofQuery* pQuery );
/** Run a query on these objects */
- void (*run_query)( GncSqlBackend* be, gpointer pQuery );
+ /*@ null @*/ void (*run_query)( GncSqlBackend* be, gpointer pQuery );
/** Free a query on these objects */
- void (*free_query)( GncSqlBackend* be, gpointer pQuery );
+ /*@ null @*/ void (*free_query)( GncSqlBackend* be, gpointer pQuery );
/** Write all objects of this type to the database
* @return TRUE if successful, FALSE if error
*/
- gboolean (*write)( GncSqlBackend* be );
+ /*@ null @*/ gboolean (*write)( GncSqlBackend* be );
} GncSqlObjectBackend;
#define GNC_SQL_BACKEND "gnc:sql:1"
#define GNC_SQL_BACKEND_VERSION 1
@@ -280,7 +280,7 @@
* a column in a table.
*/
typedef struct {
- const gchar* name; /**< Column name */
+ /*@ only @*/ const gchar* name; /**< Column name */
GType type; /**< Column basic type */
gint size; /**< Column size (string types) */
gboolean is_unicode; /**< Column is unicode (string types) */
@@ -322,7 +322,7 @@
* GncSqlColumnTableEntry objects, with a final member having col_name == NULL.
*/
struct GncSqlColumnTableEntry {
- const gchar* col_name; /**< Column name */
+ /*@ dependent @*/ const gchar* col_name; /**< Column name */
const gchar* col_type; /**< Column type */
gint size; /**< Column size in bytes, for string columns */
#define COL_PKEY 0x01 /**< The column is a primary key */
@@ -330,10 +330,10 @@
#define COL_UNIQUE 0x04 /**< The column must contain unique values */
#define COL_AUTOINC 0x08 /**< The column is an auto-incrementing int */
gint flags; /**< Column flags */
- const gchar* gobj_param_name; /**< If non-null, g_object param name */
- const gchar* qof_param_name; /**< If non-null, qof parameter name */
- QofAccessFunc getter; /**< General access function */
- QofSetterFunc setter; /**< General setter function */
+ /*@ null @*/ const gchar* gobj_param_name; /**< If non-null, g_object param name */
+ /*@ null @*/ const gchar* qof_param_name; /**< If non-null, qof parameter name */
+ /*@ null @*/ QofAccessFunc getter; /**< General access function */
+ /*@ null @*/ QofSetterFunc setter; /**< General setter function */
};
typedef enum {
@@ -344,7 +344,7 @@
typedef void (*GNC_SQL_LOAD_FN)( const GncSqlBackend* be,
GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table );
typedef void (*GNC_SQL_ADD_COL_INFO_TO_LIST_FN)( const GncSqlBackend* be,
const GncSqlColumnTableEntry* table_row,
@@ -392,7 +392,7 @@
* @param table_row DB table column
* @return Access function
*/
-QofAccessFunc gnc_sql_get_getter( QofIdTypeConst obj_name, const GncSqlColumnTableEntry* table_row );
+/*@ null @*/ QofAccessFunc gnc_sql_get_getter( QofIdTypeConst obj_name, const GncSqlColumnTableEntry* table_row );
/**
* Adds a column name to a list. If the column type spans multiple columns,
@@ -430,7 +430,7 @@
* @param statement Statement
* @return Results, or NULL if an error has occured
*/
-GncSqlResult* gnc_sql_execute_select_statement( GncSqlBackend* be, GncSqlStatement* statement );
+/*@ null @*/ GncSqlResult* gnc_sql_execute_select_statement( GncSqlBackend* be, GncSqlStatement* statement );
/**
* Executes an SQL SELECT statement from an SQL char string and returns the
@@ -441,7 +441,7 @@
* @param sql SQL SELECT string
* @return Results, or NULL if an error has occured
*/
-GncSqlResult* gnc_sql_execute_select_sql( GncSqlBackend* be, gchar* sql );
+/*@ null @*/ GncSqlResult* gnc_sql_execute_select_sql( GncSqlBackend* be, const gchar* sql );
/**
* Executes an SQL non-SELECT statement from an SQL char string.
@@ -450,7 +450,7 @@
* @param sql SQL non-SELECT string
* @returns Number of rows affected, or -1 if an error has occured
*/
-gint gnc_sql_execute_nonselect_sql( GncSqlBackend* be, gchar* sql );
+gint gnc_sql_execute_nonselect_sql( GncSqlBackend* be, const gchar* sql );
/**
* Creates a statement from an SQL char string.
@@ -459,7 +459,7 @@
* @param sql SQL char string
* @return Statement
*/
-GncSqlStatement* gnc_sql_create_statement_from_sql( GncSqlBackend* be, gchar* sql );
+/*@ null @*/ GncSqlStatement* gnc_sql_create_statement_from_sql( GncSqlBackend* be, const gchar* sql );
/**
* Loads a Gnucash object from the database.
@@ -471,7 +471,7 @@
* @param table DB table description
*/
void gnc_sql_load_object( const GncSqlBackend* be, GncSqlRow* row,
- QofIdTypeConst obj_name, gpointer pObject,
+ /*@ null @*/ QofIdTypeConst obj_name, gpointer pObject,
const GncSqlColumnTableEntry* table );
/**
@@ -557,7 +557,7 @@
* @param row Database row
* @return GUID
*/
-const GUID* gnc_sql_load_guid( const GncSqlBackend* be, GncSqlRow* row );
+/*@ dependent @*//*@ null @*/ const GUID* gnc_sql_load_guid( const GncSqlBackend* be, GncSqlRow* row );
/**
* Loads the transaction guid from a database row. The table must have a column
@@ -567,7 +567,7 @@
* @param row Database row
* @return GUID
*/
-const GUID* gnc_sql_load_tx_guid( const GncSqlBackend* be, GncSqlRow* row );
+/*@ dependent @*//*@ null @*/ const GUID* gnc_sql_load_tx_guid( const GncSqlBackend* be, GncSqlRow* row );
/**
* Creates a basic SELECT statement for a table.
@@ -576,7 +576,7 @@
* @param table_name Table name
* @return Statement
*/
-GncSqlStatement* gnc_sql_create_select_statement( GncSqlBackend* be,
+/*@ null @*/ GncSqlStatement* gnc_sql_create_select_statement( GncSqlBackend* be,
const gchar* table_name );
/**
@@ -691,14 +691,14 @@
void gnc_sql_upgrade_table( GncSqlBackend* be, const gchar* table_name,
const GncSqlColumnTableEntry* col_table );
-void _retrieve_guid_( gpointer pObject, gpointer pValue );
+void _retrieve_guid_( gpointer pObject, /*@ null @*/ gpointer pValue );
-gpointer gnc_sql_compile_query( QofBackend* pBEnd, QofQuery* pQuery );
+/*@ null @*/ gpointer gnc_sql_compile_query( QofBackend* pBEnd, QofQuery* pQuery );
void gnc_sql_free_query( QofBackend* pBEnd, gpointer pQuery );
void gnc_sql_run_query( QofBackend* pBEnd, gpointer pQuery );
typedef struct {
- GncSqlBackend* be;
+ /*@ dependent @*/ GncSqlBackend* be;
gboolean is_ok;
} write_objects_t;
Modified: gnucash/trunk/src/backend/sql/gnc-book-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-book-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-book-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -42,29 +42,35 @@
#include "SX-book.h"
#include "SX-book-p.h"
+#if defined( S_SPLINT_S )
+#include "splint-defs.h"
+#endif
+
#define BOOK_TABLE "books"
#define TABLE_VERSION 1
-static QofLogModule log_module = G_LOG_DOMAIN;
+/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
-static gpointer get_root_account_guid( gpointer pObject, const QofParam* );
-static void set_root_account_guid( gpointer pObject, gpointer pValue );
-static gpointer get_root_template_guid( gpointer pObject, const QofParam* );
-static void set_root_template_guid( gpointer pObject, gpointer pValue );
+static /*@ dependent @*//*@ null @*/ gpointer get_root_account_guid( gpointer pObject );
+static void set_root_account_guid( gpointer pObject, /*@ null @*/ gpointer pValue );
+static /*@ dependent @*//*@ null @*/ gpointer get_root_template_guid( gpointer pObject );
+static void set_root_template_guid( gpointer pObject, /*@ null @*/ gpointer pValue );
static const GncSqlColumnTableEntry col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
- { "root_account_guid", CT_GUID, 0, COL_NNUL, NULL, NULL, get_root_account_guid, set_root_account_guid },
- { "root_template_guid", CT_GUID, 0, COL_NNUL, NULL, NULL, get_root_template_guid, set_root_template_guid },
+ { "root_account_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
+ (QofAccessFunc)get_root_account_guid, set_root_account_guid },
+ { "root_template_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
+ (QofAccessFunc)get_root_template_guid, set_root_template_guid },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* ================================================================= */
-static gpointer
-get_root_account_guid( gpointer pObject, const QofParam* param )
+static /*@ dependent @*//*@ null @*/ gpointer
+get_root_account_guid( gpointer pObject )
{
GNCBook* book = QOF_BOOK(pObject);
const Account* root;
@@ -77,7 +83,7 @@
}
static void
-set_root_account_guid( gpointer pObject, gpointer pValue )
+set_root_account_guid( gpointer pObject, /*@ null @*/ gpointer pValue )
{
GNCBook* book = QOF_BOOK(pObject);
const Account* root;
@@ -91,8 +97,8 @@
qof_instance_set_guid( QOF_INSTANCE(root), guid );
}
-static gpointer
-get_root_template_guid( gpointer pObject, const QofParam* param )
+static /*@ dependent @*//*@ null @*/ gpointer
+get_root_template_guid( gpointer pObject )
{
const GNCBook* book = QOF_BOOK(pObject);
const Account* root;
@@ -105,7 +111,7 @@
}
static void
-set_root_template_guid( gpointer pObject, gpointer pValue )
+set_root_template_guid( gpointer pObject, /*@ null @*/ gpointer pValue )
{
GNCBook* book = QOF_BOOK(pObject);
GUID* guid = (GUID*)pValue;
@@ -131,14 +137,12 @@
load_single_book( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
- GUID book_guid;
GNCBook* pBook;
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
guid = gnc_sql_load_guid( be, row );
- book_guid = *guid;
pBook = be->primary_book;
if( pBook == NULL ) {
@@ -160,20 +164,22 @@
g_return_if_fail( be != NULL );
stmt = gnc_sql_create_select_statement( be, BOOK_TABLE );
- result = gnc_sql_execute_select_statement( be, stmt );
- gnc_sql_statement_dispose( stmt );
- if( result != NULL ) {
- GncSqlRow* row = gnc_sql_result_get_first_row( result );
+ if( stmt != NULL ) {
+ result = gnc_sql_execute_select_statement( be, stmt );
+ gnc_sql_statement_dispose( stmt );
+ if( result != NULL ) {
+ GncSqlRow* row = gnc_sql_result_get_first_row( result );
- // If there are no rows, try committing the book
- if( row == NULL ) {
- gnc_sql_save_book( be, QOF_INSTANCE(be->primary_book) );
- } else {
- // Otherwise, load the 1st book.
- load_single_book( be, row );
+ // If there are no rows, try committing the book
+ if( row == NULL ) {
+ (void)gnc_sql_save_book( be, QOF_INSTANCE(be->primary_book) );
+ } else {
+ // Otherwise, load the 1st book.
+ load_single_book( be, row );
+ }
+
+ gnc_sql_result_dispose( result );
}
-
- gnc_sql_result_dispose( result );
}
}
@@ -187,7 +193,7 @@
version = gnc_sql_get_table_version( be, BOOK_TABLE );
if( version == 0 ) {
- gnc_sql_create_table( be, BOOK_TABLE, TABLE_VERSION, col_table );
+ (void)gnc_sql_create_table( be, BOOK_TABLE, TABLE_VERSION, col_table );
}
}
Modified: gnucash/trunk/src/backend/sql/gnc-budget-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-budget-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-budget-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -42,51 +42,55 @@
#include "gnc-budget.h"
+#if defined( S_SPLINT_S )
+#include "splint-defs.h"
+#endif
+
#define BUDGET_TABLE "budgets"
#define TABLE_VERSION 1
-static QofLogModule log_module = G_LOG_DOMAIN;
+/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
#define BUDGET_MAX_NAME_LEN 2048
#define BUDGET_MAX_DESCRIPTION_LEN 2048
static const GncSqlColumnTableEntry col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "name", CT_STRING, BUDGET_MAX_NAME_LEN, COL_NNUL, "name" },
{ "description", CT_STRING, BUDGET_MAX_DESCRIPTION_LEN, 0, "description" },
{ "num_periods", CT_INT, 0, COL_NNUL, "num_periods" },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* ================================================================= */
-static GncBudget*
+static /*@ dependent @*//*@ null @*/ GncBudget*
load_single_budget( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
- GUID budget_guid;
- GncBudget* pBudget;
+ GncBudget* pBudget = NULL;
Recurrence* r;
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( row != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
- budget_guid = *guid;
-
- pBudget = gnc_budget_lookup( &budget_guid, be->primary_book );
+ if( guid != NULL ) {
+ pBudget = gnc_budget_lookup( guid, be->primary_book );
+ }
if( pBudget == NULL ) {
pBudget = gnc_budget_new( be->primary_book );
}
gnc_budget_begin_edit( pBudget );
gnc_sql_load_object( be, row, GNC_ID_BUDGET, pBudget, col_table );
- r = g_new0( Recurrence, 1 );
- gnc_sql_recurrence_load( be, gnc_budget_get_guid( pBudget ), r );
- gnc_budget_set_recurrence( pBudget, r );
- g_free( r );
+ r = gnc_sql_recurrence_load( be, gnc_budget_get_guid( pBudget ) );
+ if( r != NULL ) {
+ gnc_budget_set_recurrence( pBudget, r );
+ g_free( r );
+ }
gnc_budget_commit_edit( pBudget );
return pBudget;
@@ -102,23 +106,26 @@
g_return_if_fail( be != NULL );
stmt = gnc_sql_create_select_statement( be, BUDGET_TABLE );
- result = gnc_sql_execute_select_statement( be, stmt );
- gnc_sql_statement_dispose( stmt );
- if( result != NULL ) {
- GncSqlRow* row = gnc_sql_result_get_first_row( result );
- GncBudget* b;
+ if( stmt != NULL ) {
+ result = gnc_sql_execute_select_statement( be, stmt );
+ gnc_sql_statement_dispose( stmt );
+ if( result != NULL ) {
+ GncSqlRow* row = gnc_sql_result_get_first_row( result );
+ GncBudget* b;
- while( row != NULL ) {
- b = load_single_budget( be, row );
- if( b != NULL ) {
- list = g_list_append( list, b );
+ while( row != NULL ) {
+ b = load_single_budget( be, row );
+ if( b != NULL ) {
+ list = g_list_append( list, b );
+ }
+ row = gnc_sql_result_get_next_row( result );
+ }
+ gnc_sql_result_dispose( result );
+
+ if( list != NULL ) {
+ gnc_sql_slots_load_for_list( be, list );
+ g_list_free( list );
}
- row = gnc_sql_result_get_next_row( result );
- }
- gnc_sql_result_dispose( result );
-
- if( list != NULL ) {
- gnc_sql_slots_load_for_list( be, list );
}
}
}
@@ -133,7 +140,7 @@
version = gnc_sql_get_table_version( be, BUDGET_TABLE );
if( version == 0 ) {
- gnc_sql_create_table( be, BUDGET_TABLE, TABLE_VERSION, col_table );
+ (void)gnc_sql_create_table( be, BUDGET_TABLE, TABLE_VERSION, col_table );
}
}
@@ -172,7 +179,7 @@
} else {
is_ok = gnc_sql_recurrence_delete( be, guid );
if( is_ok ) {
- gnc_sql_slots_delete( be, guid );
+ (void)gnc_sql_slots_delete( be, guid );
}
}
}
@@ -222,6 +229,6 @@
write_budgets /* write */
};
- qof_object_register_backend( GNC_ID_BUDGET, GNC_SQL_BACKEND, &be_data );
+ (void)qof_object_register_backend( GNC_ID_BUDGET, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */
Modified: gnucash/trunk/src/backend/sql/gnc-commodity-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-commodity-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-commodity-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -38,11 +38,15 @@
#include "gnc-commodity-sql.h"
#include "gnc-slots-sql.h"
-static QofLogModule log_module = G_LOG_DOMAIN;
+#if defined( S_SPLINT_S )
+#include "splint-defs.h"
+#endif
-static gpointer get_quote_source_name( gpointer pObject, const QofParam* );
-static void set_quote_source_name( gpointer pObject, gpointer pValue );
+/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
+static /*@ dependent @*//*@ null @*/ gpointer get_quote_source_name( gpointer pObject );
+static void set_quote_source_name( gpointer pObject, /*@ null @*/ gpointer pValue );
+
#define COMMODITIES_TABLE "commodities"
#define TABLE_VERSION 1
@@ -54,7 +58,7 @@
#define COMMODITY_MAX_QUOTE_TZ_LEN 2048
static const GncSqlColumnTableEntry col_table[] = {
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "namespace", CT_STRING, COMMODITY_MAX_NAMESPACE_LEN, COL_NNUL, NULL, NULL,
(QofAccessFunc)gnc_commodity_get_namespace,
@@ -65,22 +69,23 @@
{ "fraction", CT_INT, 0, COL_NNUL, "fraction" },
{ "quote_flag", CT_BOOLEAN, 0, COL_NNUL, "quote_flag" },
{ "quote_source", CT_STRING, COMMODITY_MAX_QUOTESOURCE_LEN, 0, NULL, NULL,
- get_quote_source_name, set_quote_source_name },
+ (QofAccessFunc)get_quote_source_name, set_quote_source_name },
{ "quote_tz", CT_STRING, COMMODITY_MAX_QUOTE_TZ_LEN, 0, "quote-tz" },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* ================================================================= */
-static gpointer
-get_quote_source_name( gpointer pObject, const QofParam* param )
+static /*@ dependent @*//*@ null @*/ gpointer
+get_quote_source_name( gpointer pObject )
{
- const gnc_commodity* pCommodity = GNC_COMMODITY(pObject);
+ const gnc_commodity* pCommodity;
g_return_val_if_fail( pObject != NULL, NULL );
g_return_val_if_fail( GNC_IS_COMMODITY(pObject), NULL );
+ pCommodity = GNC_COMMODITY(pObject);
return (gpointer)gnc_quote_source_get_internal_name(
gnc_commodity_get_quote_source(pCommodity));
}
@@ -88,7 +93,7 @@
static void
set_quote_source_name( gpointer pObject, gpointer pValue )
{
- gnc_commodity* pCommodity = GNC_COMMODITY(pObject);
+ gnc_commodity* pCommodity;
const gchar* quote_source_name = (const gchar*)pValue;
gnc_quote_source* quote_source;
@@ -97,11 +102,12 @@
if( pValue == NULL ) return;
+ pCommodity = GNC_COMMODITY(pObject);
quote_source = gnc_quote_source_lookup_by_internal( quote_source_name );
gnc_commodity_set_quote_source( pCommodity, quote_source );
}
-static gnc_commodity*
+static /*@ dependent @*/ gnc_commodity*
load_single_commodity( GncSqlBackend* be, GncSqlRow* row )
{
QofBook* pBook = be->primary_book;
@@ -124,6 +130,7 @@
pTable = gnc_commodity_table_get_table( be->primary_book );
stmt = gnc_sql_create_select_statement( be, COMMODITIES_TABLE );
+ if( stmt == NULL ) return;
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -148,6 +155,7 @@
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
+ g_list_free( list );
}
}
}
@@ -161,7 +169,7 @@
version = gnc_sql_get_table_version( be, COMMODITIES_TABLE );
if( version == 0 ) {
- gnc_sql_create_table( be, COMMODITIES_TABLE, TABLE_VERSION, col_table );
+ (void)gnc_sql_create_table( be, COMMODITIES_TABLE, TABLE_VERSION, col_table );
}
}
@@ -205,12 +213,11 @@
static void
load_commodity_guid( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
GUID guid;
- const GUID* pGuid;
gnc_commodity* commodity = NULL;
g_return_if_fail( be != NULL );
@@ -219,18 +226,12 @@
g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
- if( val == NULL ) {
- pGuid = NULL;
- } else {
- string_to_guid( g_value_get_string( val ), &guid );
- pGuid = &guid;
- }
- if( pGuid != NULL ) {
- commodity = gnc_commodity_find_commodity_by_guid( pGuid, be->primary_book );
- }
+ g_assert( val != NULL );
+ (void)string_to_guid( g_value_get_string( val ), &guid );
+ commodity = gnc_commodity_find_commodity_by_guid( &guid, be->primary_book );
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, commodity, NULL );
- } else {
+ } else if( setter != NULL ) {
(*setter)( pObject, (const gpointer)commodity );
}
}
@@ -257,7 +258,7 @@
NULL /* write */
};
- qof_object_register_backend( GNC_ID_COMMODITY, GNC_SQL_BACKEND, &be_data );
+ (void)qof_object_register_backend( GNC_ID_COMMODITY, GNC_SQL_BACKEND, &be_data );
gnc_sql_register_col_type_handler( CT_COMMODITYREF, &commodity_guid_handler );
}
Modified: gnucash/trunk/src/backend/sql/gnc-lots-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-lots-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-lots-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -38,44 +38,50 @@
#include "gnc-lots-sql.h"
-static QofLogModule log_module = G_LOG_DOMAIN;
+#if defined( S_SPLINT_S )
+#include "splint-defs.h"
+#endif
+/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
+
#define TABLE_NAME "lots"
#define TABLE_VERSION 2
-static gpointer get_lot_account( gpointer pObject, const QofParam* param );
-static void set_lot_account( gpointer pObject, gpointer pValue );
+static /*@ dependent @*//*@ null @*/ gpointer get_lot_account( gpointer pObject );
+static void set_lot_account( gpointer pObject, /*@ null @*/ gpointer pValue );
static void set_lot_is_closed( gpointer pObject, gboolean value );
static const GncSqlColumnTableEntry col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
- { "account_guid", CT_GUID, 0, 0, NULL, NULL, get_lot_account, set_lot_account },
+ { "account_guid", CT_GUID, 0, 0, NULL, NULL,
+ (QofAccessFunc)get_lot_account, set_lot_account },
{ "is_closed", CT_BOOLEAN, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)gnc_lot_is_closed, (QofSetterFunc)set_lot_is_closed },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* ================================================================= */
-static gpointer
-get_lot_account( gpointer pObject, const QofParam* param )
+static /*@ dependent @*//*@ null @*/ gpointer
+get_lot_account( gpointer pObject )
{
- const GNCLot* lot = GNC_LOT(pObject);
+ const GNCLot* lot;
const Account* pAccount;
g_return_val_if_fail( pObject != NULL, NULL );
g_return_val_if_fail( GNC_IS_LOT(pObject), NULL );
+ lot = GNC_LOT(pObject);
pAccount = gnc_lot_get_account( lot );
return (gpointer)qof_instance_get_guid( QOF_INSTANCE(pAccount) );
}
static void
-set_lot_account( gpointer pObject, gpointer pValue )
+set_lot_account( gpointer pObject, /*@ null @*/ gpointer pValue )
{
- GNCLot* lot = GNC_LOT(pObject);
+ GNCLot* lot;
QofBook* pBook;
GUID* guid = (GUID*)pValue;
Account* pAccount;
@@ -84,6 +90,7 @@
g_return_if_fail( GNC_IS_LOT(pObject) );
g_return_if_fail( pValue != NULL );
+ lot = GNC_LOT(pObject);
pBook = qof_instance_get_book( QOF_INSTANCE(lot) );
pAccount = xaccAccountLookup( guid, pBook );
if( pAccount != NULL ) {
@@ -94,15 +101,16 @@
static void
set_lot_is_closed( gpointer pObject, gboolean closed )
{
- GNCLot* lot = GNC_LOT(pObject);
+ GNCLot* lot;
g_return_if_fail( pObject != NULL );
g_return_if_fail( GNC_IS_LOT(pObject) );
- lot->is_closed = closed;
+ lot = GNC_LOT(pObject);
+ lot->is_closed = (char)closed;
}
-static GNCLot*
+static /*@ dependent @*//*@ null @*/ GNCLot*
load_single_lot( GncSqlBackend* be, GncSqlRow* row )
{
GNCLot* lot;
@@ -128,26 +136,29 @@
g_return_if_fail( be != NULL );
stmt = gnc_sql_create_select_statement( be, TABLE_NAME );
- result = gnc_sql_execute_select_statement( be, stmt );
- gnc_sql_statement_dispose( stmt );
- if( result != NULL ) {
- GList* list = NULL;
- GncSqlRow* row = gnc_sql_result_get_first_row( result );
- GNCLot* lot;
+ if( stmt != NULL ) {
+ result = gnc_sql_execute_select_statement( be, stmt );
+ gnc_sql_statement_dispose( stmt );
+ if( result != NULL ) {
+ GList* list = NULL;
+ GncSqlRow* row = gnc_sql_result_get_first_row( result );
+ GNCLot* lot;
- while( row != NULL ) {
- lot = load_single_lot( be, row );
- if( lot != NULL ) {
- list = g_list_append( list, lot );
+ while( row != NULL ) {
+ lot = load_single_lot( be, row );
+ if( lot != NULL ) {
+ list = g_list_append( list, lot );
+ }
+ row = gnc_sql_result_get_next_row( result );
+ }
+ gnc_sql_result_dispose( result );
+
+ if( list != NULL ) {
+ gnc_sql_slots_load_for_list( be, list );
+ g_list_free( list );
}
- row = gnc_sql_result_get_next_row( result );
- }
- gnc_sql_result_dispose( result );
-
- if( list != NULL ) {
- gnc_sql_slots_load_for_list( be, list );
- }
- }
+ }
+ }
}
/* ================================================================= */
@@ -161,7 +172,7 @@
version = gnc_sql_get_table_version( be, TABLE_NAME );
if( version == 0 ) {
/* The table doesn't exist, so create it */
- gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
+ (void)gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
} else if( version == 1 ) {
/* Version 1 -> 2 removes the 'NOT NULL' constraint on the account_guid
field.
@@ -170,7 +181,7 @@
old table, then rename the new one. */
gnc_sql_upgrade_table( be, TABLE_NAME, col_table );
- gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
+ (void)gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
}
}
@@ -213,13 +224,12 @@
/* ================================================================= */
static void
load_lot_guid( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
GUID guid;
- const GUID* pGuid;
- GNCLot* lot = NULL;
+ GNCLot* lot;
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
@@ -227,18 +237,15 @@
g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
- if( val == NULL ) {
- pGuid = NULL;
- } else {
- string_to_guid( g_value_get_string( val ), &guid );
- pGuid = &guid;
- }
- if( pGuid != NULL ) {
- lot = gnc_lot_lookup( pGuid, be->primary_book );
- }
+
+ g_return_if_fail( val != NULL );
+
+ (void)string_to_guid( g_value_get_string( val ), &guid );
+ lot = gnc_lot_lookup( &guid, be->primary_book );
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, lot, NULL );
} else {
+ g_return_if_fail( setter != NULL );
(*setter)( pObject, (const gpointer)lot );
}
}
@@ -263,7 +270,7 @@
write_lots /* save all */
};
- qof_object_register_backend( GNC_ID_LOT, GNC_SQL_BACKEND, &be_data );
+ (void)qof_object_register_backend( GNC_ID_LOT, GNC_SQL_BACKEND, &be_data );
gnc_sql_register_col_type_handler( CT_LOTREF, &lot_guid_handler );
}
Modified: gnucash/trunk/src/backend/sql/gnc-price-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-price-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-price-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -39,8 +39,12 @@
#include "gnc-price-sql.h"
#include "gnc-slots-sql.h"
-static QofLogModule log_module = G_LOG_DOMAIN;
+#if defined( S_SPLINT_S )
+#include "splint-defs.h"
+#endif
+/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
+
#define TABLE_NAME "prices"
#define TABLE_VERSION 2
@@ -49,7 +53,7 @@
static const GncSqlColumnTableEntry col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "commodity_guid", CT_COMMODITYREF, 0, COL_NNUL, NULL, PRICE_COMMODITY },
{ "currency_guid", CT_COMMODITYREF, 0, COL_NNUL, NULL, PRICE_CURRENCY },
@@ -58,12 +62,12 @@
{ "type", CT_STRING, PRICE_MAX_TYPE_LEN, 0, NULL, PRICE_TYPE },
{ "value", CT_NUMERIC, 0, COL_NNUL, NULL, PRICE_VALUE },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* ================================================================= */
-static GNCPrice*
+static /*@ null @*//*@ dependent @*/ GNCPrice*
load_single_price( GncSqlBackend* be, GncSqlRow* row )
{
GNCPrice* pPrice;
@@ -93,26 +97,29 @@
pBook = be->primary_book;
pPriceDB = gnc_book_get_pricedb( pBook );
stmt = gnc_sql_create_select_statement( be, TABLE_NAME );
- result = gnc_sql_execute_select_statement( be, stmt );
- gnc_sql_statement_dispose( stmt );
- if( result != NULL ) {
- GNCPrice* pPrice;
- GList* list = NULL;
- GncSqlRow* row = gnc_sql_result_get_first_row( result );
+ if( stmt != NULL ) {
+ result = gnc_sql_execute_select_statement( be, stmt );
+ gnc_sql_statement_dispose( stmt );
+ if( result != NULL ) {
+ GNCPrice* pPrice;
+ GList* list = NULL;
+ GncSqlRow* row = gnc_sql_result_get_first_row( result );
- while( row != NULL ) {
- pPrice = load_single_price( be, row );
+ while( row != NULL ) {
+ pPrice = load_single_price( be, row );
- if( pPrice != NULL ) {
- list = g_list_append( list, pPrice );
- gnc_pricedb_add_price( pPriceDB, pPrice );
- }
- row = gnc_sql_result_get_next_row( result );
- }
- gnc_sql_result_dispose( result );
+ if( pPrice != NULL ) {
+ list = g_list_append( list, pPrice );
+ (void)gnc_pricedb_add_price( pPriceDB, pPrice );
+ }
+ row = gnc_sql_result_get_next_row( result );
+ }
+ gnc_sql_result_dispose( result );
- if( list != NULL ) {
- gnc_sql_slots_load_for_list( be, list );
+ if( list != NULL ) {
+ gnc_sql_slots_load_for_list( be, list );
+ g_list_free( list );
+ }
}
}
}
@@ -127,11 +134,11 @@
version = gnc_sql_get_table_version( be, TABLE_NAME );
if( version == 0 ) {
- gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
+ (void)gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
} else if( version == 1 ) {
/* Upgrade 64 bit int handling */
gnc_sql_upgrade_table( be, TABLE_NAME, col_table );
- gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
+ (void)gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
}
}
@@ -160,7 +167,7 @@
if( op != OP_DB_DELETE ) {
/* Ensure commodity and currency are in the db */
- gnc_sql_save_commodity( be, gnc_price_get_commodity( pPrice ) );
+ (void)gnc_sql_save_commodity( be, gnc_price_get_commodity( pPrice ) );
is_ok = gnc_sql_save_commodity( be, gnc_price_get_currency( pPrice ) );
}
@@ -216,7 +223,7 @@
write_prices /* write */
};
- qof_object_register_backend( GNC_ID_PRICE, GNC_SQL_BACKEND, &be_data );
+ (void)qof_object_register_backend( GNC_ID_PRICE, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */
Modified: gnucash/trunk/src/backend/sql/gnc-recurrence-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-recurrence-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-recurrence-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -38,57 +38,62 @@
#include "gnc-recurrence-sql.h"
-static QofLogModule log_module = G_LOG_DOMAIN;
+#if defined( S_SPLINT_S )
+#include "splint-defs.h"
+#endif
+/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
+
#define TABLE_NAME "recurrences"
#define TABLE_VERSION 1
#define BUDGET_MAX_RECURRENCE_PERIOD_TYPE_LEN 2048
typedef struct {
- GncSqlBackend* be;
- const GUID* guid;
- Recurrence* pRecurrence;
+ /*@ dependent @*/ GncSqlBackend* be;
+ /*@ dependent @*/ const GUID* guid;
+ /*@ dependent @*/ Recurrence* pRecurrence;
} recurrence_info_t;
-static gpointer get_obj_guid( gpointer pObject, const QofParam* param );
-static void set_obj_guid( gpointer pObject, gpointer pValue );
+static /*@ null @*/ gpointer get_obj_guid( gpointer pObject );
+static void set_obj_guid( void );
static gint get_recurrence_mult( gpointer pObject );
static void set_recurrence_mult( gpointer pObject, gint value );
-static gpointer get_recurrence_period_type( gpointer pObject, const QofParam* );
-static void set_recurrence_period_type( gpointer pObject, gpointer pValue );
-static gpointer get_recurrence_period_start( gpointer pObject, const QofParam* );
-static void set_recurrence_period_start( gpointer pObject, gpointer pValue );
+static /*@ null @*/ gpointer get_recurrence_period_type( gpointer pObject );
+static void set_recurrence_period_type( gpointer pObject, /*@ null @*/ gpointer pValue );
+static /*@ dependent @*//*@ null @*/ gpointer get_recurrence_period_start( gpointer pObject );
+static void set_recurrence_period_start( gpointer pObject, /*@ null @*/ gpointer pValue );
static const GncSqlColumnTableEntry col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "obj_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
- get_obj_guid, set_obj_guid },
+ (QofAccessFunc)get_obj_guid, (QofSetterFunc)set_obj_guid },
{ "recurrence_mult", CT_INT, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)get_recurrence_mult, (QofSetterFunc)set_recurrence_mult },
{ "recurrence_period_type", CT_STRING, BUDGET_MAX_RECURRENCE_PERIOD_TYPE_LEN, COL_NNUL, NULL, NULL,
- get_recurrence_period_type, set_recurrence_period_type },
+ (QofAccessFunc)get_recurrence_period_type, set_recurrence_period_type },
{ "recurrence_period_start", CT_GDATE, 0, COL_NNUL, NULL, NULL,
- get_recurrence_period_start, set_recurrence_period_start },
+ (QofAccessFunc)get_recurrence_period_start, set_recurrence_period_start },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* Special column table because we need to be able to access the table by
a column other than the primary key */
static const GncSqlColumnTableEntry guid_col_table[] =
{
- /*# -fullinitblock */
- { "obj_guid", CT_GUID, 0, 0, NULL, NULL, get_obj_guid, set_obj_guid },
+ /*@ -full_init_block @*/
+ { "obj_guid", CT_GUID, 0, 0, NULL, NULL,
+ (QofAccessFunc)get_obj_guid, (QofSetterFunc)set_obj_guid },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* ================================================================= */
-static gpointer
-get_obj_guid( gpointer pObject, const QofParam* param )
+static /*@ null @*/ gpointer
+get_obj_guid( gpointer pObject )
{
recurrence_info_t* pInfo = (recurrence_info_t*)pObject;
@@ -98,7 +103,7 @@
}
static void
-set_obj_guid( gpointer pObject, gpointer pValue )
+set_obj_guid( void )
{
// Nowhere to put the GUID
}
@@ -125,8 +130,8 @@
pInfo->pRecurrence->mult = (guint16)value;
}
-static gpointer
-get_recurrence_period_type( gpointer pObject, const QofParam* param )
+static /*@ null @*/ gpointer
+get_recurrence_period_type( gpointer pObject )
{
recurrence_info_t* pInfo = (recurrence_info_t*)pObject;
@@ -149,8 +154,8 @@
pInfo->pRecurrence->ptype = recurrencePeriodTypeFromString( (gchar*)pValue );
}
-static gpointer
-get_recurrence_period_start( gpointer pObject, const QofParam* param )
+static /*@ dependent @*//*@ null @*/ gpointer
+get_recurrence_period_start( gpointer pObject )
{
recurrence_info_t* pInfo = (recurrence_info_t*)pObject;
static GDate date;
@@ -186,7 +191,7 @@
g_return_val_if_fail( guid != NULL, FALSE );
g_return_val_if_fail( r != NULL, FALSE );
- gnc_sql_recurrence_delete( be, guid );
+ (void)gnc_sql_recurrence_delete( be, guid );
recurrence_info.be = be;
recurrence_info.guid = guid;
@@ -204,7 +209,7 @@
g_return_if_fail( be != NULL );
g_return_if_fail( guid != NULL );
- gnc_sql_recurrence_delete( be, guid );
+ (void)gnc_sql_recurrence_delete( be, guid );
recurrence_info.be = be;
recurrence_info.guid = guid;
@@ -230,7 +235,7 @@
}
static void
-load_recurrence( GncSqlBackend* be, GncSqlRow* row, Recurrence* r )
+load_recurrence( GncSqlBackend* be, GncSqlRow* row, /*@ out @*/ Recurrence* r )
{
recurrence_info_t recurrence_info;
@@ -244,7 +249,7 @@
gnc_sql_load_object( be, row, TABLE_NAME, &recurrence_info, col_table );
}
-static GncSqlResult*
+static /*@ null @*/ GncSqlResult*
gnc_sql_set_recurrences_from_db( GncSqlBackend* be, const GUID* guid )
{
gchar* buf;
@@ -258,45 +263,49 @@
(void)guid_to_string_buff( guid, guid_buf );
buf = g_strdup_printf( "SELECT * FROM %s WHERE obj_guid='%s'", TABLE_NAME, guid_buf );
stmt = gnc_sql_connection_create_statement_from_sql( be->conn, buf );
+ g_free( buf );
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
return result;
}
-void
-gnc_sql_recurrence_load( GncSqlBackend* be, const GUID* guid, Recurrence* pRecurrence )
+/*@ null @*/ Recurrence*
+gnc_sql_recurrence_load( GncSqlBackend* be, const GUID* guid )
{
GncSqlResult* result;
+ Recurrence* r = NULL;
- g_return_if_fail( be != NULL );
- g_return_if_fail( guid != NULL );
- g_return_if_fail( pRecurrence != NULL );
+ g_return_val_if_fail( be != NULL, NULL );
+ g_return_val_if_fail( guid != NULL, NULL );
result = gnc_sql_set_recurrences_from_db( be, guid );
if( result != NULL ) {
- int numRows = gnc_sql_result_get_num_rows( result );
+ guint numRows = gnc_sql_result_get_num_rows( result );
if( numRows > 0 ) {
if( numRows > 1 ) {
g_warning( "More than 1 recurrence found: first one used" );
}
- load_recurrence( be, gnc_sql_result_get_first_row( result ),
- pRecurrence );
+ r = g_new0( Recurrence, 1 );
+ g_assert( r != NULL );
+ load_recurrence( be, gnc_sql_result_get_first_row( result ), r );
} else {
g_warning( "No recurrences found" );
}
gnc_sql_result_dispose( result );
}
+
+ return r;
}
-void
-gnc_sql_recurrence_load_list( GncSqlBackend* be, const GUID* guid, GList** pSchedule )
+/*@ null @*/ GList*
+gnc_sql_recurrence_load_list( GncSqlBackend* be, const GUID* guid )
{
GncSqlResult* result;
+ GList* list = NULL;
- g_return_if_fail( be != NULL );
- g_return_if_fail( guid != NULL );
- g_return_if_fail( pSchedule != NULL );
+ g_return_val_if_fail( be != NULL, NULL );
+ g_return_val_if_fail( guid != NULL, NULL );
result = gnc_sql_set_recurrences_from_db( be, guid );
if( result != NULL ) {
@@ -304,12 +313,15 @@
while( row != NULL ) {
Recurrence* pRecurrence = g_new0( Recurrence, 1 );
+ g_assert( pRecurrence != NULL );
load_recurrence( be, row, pRecurrence );
- *pSchedule = g_list_append( *pSchedule, pRecurrence );
+ list = g_list_append( list, pRecurrence );
row = gnc_sql_result_get_next_row( result );
}
gnc_sql_result_dispose( result );
}
+
+ return list;
}
/* ================================================================= */
@@ -322,7 +334,7 @@
version = gnc_sql_get_table_version( be, TABLE_NAME );
if( version == 0 ) {
- gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
+ (void)gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
}
}
@@ -343,6 +355,6 @@
NULL /* write */
};
- qof_object_register_backend( TABLE_NAME, GNC_SQL_BACKEND, &be_data );
+ (void)qof_object_register_backend( TABLE_NAME, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */
Modified: gnucash/trunk/src/backend/sql/gnc-recurrence-sql.h
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-recurrence-sql.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-recurrence-sql.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -35,8 +35,8 @@
gboolean gnc_sql_recurrence_save( GncSqlBackend* be, const GUID* guid, const Recurrence* pRecurrence );
void gnc_sql_recurrence_save_list( GncSqlBackend* be, const GUID* guid, GList* schedule );
gboolean gnc_sql_recurrence_delete( GncSqlBackend* be, const GUID* guid );
-void gnc_sql_recurrence_load( GncSqlBackend* be, const GUID* guid, Recurrence* pRecurrence );
-void gnc_sql_recurrence_load_list( GncSqlBackend* be, const GUID* guid, GList** pSchedule );
+/*@ null @*/ Recurrence* gnc_sql_recurrence_load( GncSqlBackend* be, const GUID* guid );
+/*@ null @*/ GList* gnc_sql_recurrence_load_list( GncSqlBackend* be, const GUID* guid );
void gnc_sql_init_recurrence_handler( void );
Modified: gnucash/trunk/src/backend/sql/gnc-schedxaction-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-schedxaction-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-schedxaction-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -44,10 +44,14 @@
#include "gnc-recurrence-sql.h"
#include "gnc-transaction-sql.h"
+#ifdef S_SPLINT_S
+#include "splint-defs.h"
+#endif
+
#define SCHEDXACTION_TABLE "schedxactions"
#define TABLE_VERSION 1
-static QofLogModule log_module = G_LOG_DOMAIN;
+/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
#define SX_MAX_NAME_LEN 2048
@@ -56,12 +60,12 @@
static gboolean get_autonotify( gpointer pObject );
static void set_autonotify( gpointer pObject, gboolean value );
static gint get_instance_count( gpointer pObject );
-static gpointer get_template_act_guid( gpointer pObject, const QofParam* param );
-static void set_template_act_guid( gpointer pObject, gpointer pValue );
+static /*@ null @*/ gpointer get_template_act_guid( gpointer pObject );
+static void set_template_act_guid( gpointer pObject, /*@ null @*/ gpointer pValue );
static const GncSqlColumnTableEntry col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "name", CT_STRING, SX_MAX_NAME_LEN, 0, NULL, GNC_SX_NAME },
{ "enabled", CT_BOOLEAN, 0, COL_NNUL, NULL, NULL,
@@ -83,9 +87,9 @@
{ "instance_count", CT_INT, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)get_instance_count, (QofSetterFunc)gnc_sx_set_instance_count },
{ "template_act_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
- get_template_act_guid, set_template_act_guid },
+ (QofAccessFunc)get_template_act_guid, set_template_act_guid },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* ================================================================= */
@@ -93,13 +97,14 @@
static gboolean
get_autocreate( gpointer pObject )
{
- const SchedXaction* pSx = GNC_SX(pObject);
+ const SchedXaction* pSx;
gboolean autoCreate;
gboolean autoNotify;
g_return_val_if_fail( pObject != NULL, FALSE );
g_return_val_if_fail( GNC_IS_SX(pObject), FALSE );
+ pSx = GNC_SX(pObject);
xaccSchedXactionGetAutoCreate( pSx, &autoCreate, &autoNotify );
return autoCreate;
}
@@ -107,13 +112,14 @@
static void
set_autocreate( gpointer pObject, gboolean value )
{
- SchedXaction* pSx = GNC_SX(pObject);
+ SchedXaction* pSx;
gboolean autoNotify;
gboolean dummy;
g_return_if_fail( pObject != NULL );
g_return_if_fail( GNC_IS_SX(pObject) );
+ pSx = GNC_SX(pObject);
xaccSchedXactionGetAutoCreate( pSx, &dummy, &autoNotify );
xaccSchedXactionSetAutoCreate( pSx, value, autoNotify );
}
@@ -121,13 +127,14 @@
static gboolean
get_autonotify( gpointer pObject )
{
- const SchedXaction* pSx = GNC_SX(pObject);
+ const SchedXaction* pSx;
gboolean autoCreate;
gboolean autoNotify;
g_return_val_if_fail( pObject != NULL, FALSE );
g_return_val_if_fail( GNC_IS_SX(pObject), FALSE );
+ pSx = GNC_SX(pObject);
xaccSchedXactionGetAutoCreate( pSx, &autoCreate, &autoNotify );
return autoNotify;
}
@@ -135,13 +142,14 @@
static void
set_autonotify( gpointer pObject, gboolean value )
{
- SchedXaction* pSx = GNC_SX(pObject);
+ SchedXaction* pSx;
gboolean autoCreate;
gboolean dummy;
g_return_if_fail( pObject != NULL );
g_return_if_fail( GNC_IS_SX(pObject) );
+ pSx = GNC_SX(pObject);
xaccSchedXactionGetAutoCreate( pSx, &autoCreate, &dummy );
xaccSchedXactionSetAutoCreate( pSx, autoCreate, value );
}
@@ -149,29 +157,28 @@
static gint
get_instance_count( gpointer pObject )
{
- const SchedXaction* pSx = GNC_SX(pObject);
-
g_return_val_if_fail( pObject != NULL, FALSE );
g_return_val_if_fail( GNC_IS_SX(pObject), FALSE );
- return gnc_sx_get_instance_count( pSx, NULL );
+ return gnc_sx_get_instance_count( GNC_SX(pObject), NULL );
}
static gpointer
-get_template_act_guid( gpointer pObject, const QofParam* param )
+get_template_act_guid( gpointer pObject )
{
- const SchedXaction* pSx = GNC_SX(pObject);
+ const SchedXaction* pSx;
g_return_val_if_fail( pObject != NULL, NULL );
g_return_val_if_fail( GNC_IS_SX(pObject), NULL );
+ pSx = GNC_SX(pObject);
return (gpointer)xaccAccountGetGUID( pSx->template_acct );
}
static void
set_template_act_guid( gpointer pObject, gpointer pValue )
{
- SchedXaction* pSx = GNC_SX(pObject);
+ SchedXaction* pSx;
QofBook* pBook;
GUID* guid = (GUID*)pValue;
Account* pAcct;
@@ -180,31 +187,30 @@
g_return_if_fail( GNC_IS_SX(pObject) );
g_return_if_fail( pValue != NULL );
+ pSx = GNC_SX(pObject);
pBook = qof_instance_get_book( QOF_INSTANCE(pSx) );
pAcct = xaccAccountLookup( guid, pBook );
sx_set_template_account( pSx, pAcct );
}
/* ================================================================= */
-static SchedXaction*
+static /*@ null @*/ SchedXaction*
load_single_sx( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
- GUID sx_guid;
SchedXaction* pSx;
- GList* schedule = NULL;
+ GList* schedule;
g_return_val_if_fail( be != NULL, NULL );
g_return_val_if_fail( row != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
- sx_guid = *guid;
-
+ g_assert( guid != NULL );
pSx = xaccSchedXactionMalloc( be->primary_book );
gnc_sx_begin_edit( pSx );
gnc_sql_load_object( be, row, GNC_SX_ID, pSx, col_table );
- gnc_sql_recurrence_load_list( be, guid, &schedule );
+ schedule = gnc_sql_recurrence_load_list( be, guid );
gnc_sx_set_schedule( pSx, schedule );
gnc_sx_commit_edit( pSx );
gnc_sql_transaction_load_tx_for_account( be, pSx->template_acct );
@@ -221,6 +227,7 @@
g_return_if_fail( be != NULL );
stmt = gnc_sql_create_select_statement( be, SCHEDXACTION_TABLE );
+ if( stmt == NULL ) return;
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -244,6 +251,7 @@
if( list != NULL ) {
gnc_sql_slots_load_for_list( be, list );
+ g_list_free( list );
}
}
}
@@ -258,7 +266,7 @@
version = gnc_sql_get_table_version( be, SCHEDXACTION_TABLE );
if( version == 0 ) {
- gnc_sql_create_table( be, SCHEDXACTION_TABLE, TABLE_VERSION, col_table );
+ (void)gnc_sql_create_table( be, SCHEDXACTION_TABLE, TABLE_VERSION, col_table );
}
}
@@ -319,6 +327,6 @@
NULL /* write */
};
- qof_object_register_backend( GNC_ID_SCHEDXACTION, GNC_SQL_BACKEND, &be_data );
+ (void)qof_object_register_backend( GNC_ID_SCHEDXACTION, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */
Modified: gnucash/trunk/src/backend/sql/gnc-slots-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-slots-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-slots-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -37,38 +37,42 @@
#include "gnc-slots-sql.h"
-static QofLogModule log_module = G_LOG_DOMAIN;
+#ifdef S_SPLINT_S
+#include "splint-defs.h"
+#endif
+/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
+
#define TABLE_NAME "slots"
#define TABLE_VERSION 2
typedef struct {
- GncSqlBackend* be;
- const GUID* guid;
+ /*@ dependent @*/ GncSqlBackend* be;
+ /*@ dependent @*/ const GUID* guid;
gboolean is_ok;
- KvpFrame* pKvpFrame;
+ /*@ dependent @*/ KvpFrame* pKvpFrame;
KvpValueType value_type;
- KvpValue* pKvpValue;
+ /*@ dependent @*/ KvpValue* pKvpValue;
GString* path;
} slot_info_t;
-static gpointer get_obj_guid( gpointer pObject, const QofParam* param );
-static void set_obj_guid( gpointer pObject, gpointer pValue );
-static gpointer get_path( gpointer pObject, const QofParam* param );
-static void set_path( gpointer pObject, gpointer pValue );
-static gpointer get_slot_type( gpointer pObject, const QofParam* param );
-static void set_slot_type( gpointer pObject, gpointer pValue );
-static gint64 get_int64_val( gpointer pObject, const QofParam* param );
+static /*@ null @*/ gpointer get_obj_guid( gpointer pObject );
+static void set_obj_guid( void );
+static /*@ null @*/ gpointer get_path( gpointer pObject );
+static void set_path( gpointer pObject, /*@ null @*/ gpointer pValue );
+static /*@ null @*/ gpointer get_slot_type( gpointer pObject );
+static void set_slot_type( gpointer pObject, /*@ null @*/ gpointer pValue );
+static gint64 get_int64_val( gpointer pObject );
static void set_int64_val( gpointer pObject, gint64 pValue );
-static gpointer get_string_val( gpointer pObject, const QofParam* param );
-static void set_string_val( gpointer pObject, gpointer pValue );
-static gpointer get_double_val( gpointer pObject, const QofParam* param );
-static void set_double_val( gpointer pObject, gpointer pValue );
-static Timespec get_timespec_val( gpointer pObject, const QofParam* param );
+static /*@ null @*/ gpointer get_string_val( gpointer pObject );
+static void set_string_val( gpointer pObject, /*@ null @*/ gpointer pValue );
+static /*@ dependent @*//*@ null @*/ gpointer get_double_val( gpointer pObject );
+static void set_double_val( gpointer pObject, /*@ null @*/ gpointer pValue );
+static Timespec get_timespec_val( gpointer pObject );
static void set_timespec_val( gpointer pObject, Timespec ts );
-static gpointer get_guid_val( gpointer pObject, const QofParam* param );
-static void set_guid_val( gpointer pObject, gpointer pValue );
-static gnc_numeric get_numeric_val( gpointer pObject, const QofParam* param );
+static /*@ null @*/ gpointer get_guid_val( gpointer pObject );
+static void set_guid_val( gpointer pObject, /*@ null @*/ gpointer pValue );
+static gnc_numeric get_numeric_val( gpointer pObject );
static void set_numeric_val( gpointer pObject, gnc_numeric value );
#define SLOT_MAX_PATHNAME_LEN 4096
@@ -76,43 +80,43 @@
static const GncSqlColumnTableEntry col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "obj_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
- get_obj_guid, set_obj_guid },
+ (QofAccessFunc)get_obj_guid, (QofSetterFunc)set_obj_guid },
{ "name", CT_STRING, SLOT_MAX_PATHNAME_LEN, COL_NNUL, NULL, NULL,
- get_path, set_path },
+ (QofAccessFunc)get_path, set_path },
{ "slot_type", CT_INT, 0, COL_NNUL, NULL, NULL,
- get_slot_type, set_slot_type, },
+ (QofAccessFunc)get_slot_type, set_slot_type, },
{ "int64_val", CT_INT64, 0, 0, NULL, NULL,
(QofAccessFunc)get_int64_val, (QofSetterFunc)set_int64_val },
{ "string_val", CT_STRING, SLOT_MAX_PATHNAME_LEN, 0, NULL, NULL,
- get_string_val, set_string_val },
+ (QofAccessFunc)get_string_val, set_string_val },
{ "double_val", CT_DOUBLE, 0, 0, NULL, NULL,
- get_double_val, set_double_val },
+ (QofAccessFunc)get_double_val, set_double_val },
{ "timespec_val", CT_TIMESPEC, 0, 0, NULL, NULL,
(QofAccessFunc)get_timespec_val, (QofSetterFunc)set_timespec_val },
{ "guid_val", CT_GUID, 0, 0, NULL, NULL,
- get_guid_val, set_guid_val },
+ (QofAccessFunc)get_guid_val, set_guid_val },
{ "numeric_val", CT_NUMERIC, 0, 0, NULL, NULL,
(QofAccessFunc)get_numeric_val, (QofSetterFunc)set_numeric_val },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* Special column table because we need to be able to access the table by
a column other than the primary key */
static const GncSqlColumnTableEntry obj_guid_col_table[] =
{
- /*# -fullinitblock */
- { "obj_guid", CT_GUID, 0, 0, NULL, NULL, get_obj_guid, _retrieve_guid_ },
+ /*@ -full_init_block @*/
+ { "obj_guid", CT_GUID, 0, 0, NULL, NULL, (QofAccessFunc)get_obj_guid, _retrieve_guid_ },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
/* ================================================================= */
-static gpointer
-get_obj_guid( gpointer pObject, const QofParam* param )
+static /*@ null @*/ gpointer
+get_obj_guid( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -122,13 +126,13 @@
}
static void
-set_obj_guid( gpointer pObject, gpointer pValue )
+set_obj_guid( void )
{
// Nowhere to put the GUID
}
-static gpointer
-get_path( gpointer pObject, const QofParam* param )
+static /*@ null @*/ gpointer
+get_path( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -138,18 +142,21 @@
}
static void
-set_path( gpointer pObject, gpointer pValue )
+set_path( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
g_return_if_fail( pObject != NULL );
g_return_if_fail( pValue != NULL );
+ if( pInfo->path != NULL ) {
+ (void)g_string_free( pInfo->path, TRUE );
+ }
pInfo->path = g_string_new( (gchar*)pValue );
}
-static gpointer
-get_slot_type( gpointer pObject, const QofParam* param )
+static /*@ null @*/ gpointer
+get_slot_type( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -159,7 +166,7 @@
}
static void
-set_slot_type( gpointer pObject, gpointer pValue )
+set_slot_type( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -170,7 +177,7 @@
}
static gint64
-get_int64_val( gpointer pObject, const QofParam* param )
+get_int64_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -195,8 +202,8 @@
}
}
-static gpointer
-get_string_val( gpointer pObject, const QofParam* param )
+static /*@ null @*/ gpointer
+get_string_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -210,7 +217,7 @@
}
static void
-set_string_val( gpointer pObject, gpointer pValue )
+set_string_val( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -221,8 +228,8 @@
}
}
-static gpointer
-get_double_val( gpointer pObject, const QofParam* param )
+static /*@ dependent @*//*@ null @*/ gpointer
+get_double_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
static double d_val;
@@ -238,7 +245,7 @@
}
static void
-set_double_val( gpointer pObject, gpointer pValue )
+set_double_val( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -250,7 +257,7 @@
}
static Timespec
-get_timespec_val( gpointer pObject, const QofParam* param )
+get_timespec_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -272,8 +279,8 @@
}
}
-static gpointer
-get_guid_val( gpointer pObject, const QofParam* param )
+static /*@ null @*/ gpointer
+get_guid_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -287,7 +294,7 @@
}
static void
-set_guid_val( gpointer pObject, gpointer pValue )
+set_guid_val( gpointer pObject, /*@ null @*/ gpointer pValue )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -299,7 +306,7 @@
}
static gnc_numeric
-get_numeric_val( gpointer pObject, const QofParam* param )
+get_numeric_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
@@ -370,7 +377,7 @@
// If this is not saving into a new db, clear out the old saved slots first
if( !be->is_pristine_db && !is_infant ) {
- gnc_sql_slots_delete( be, guid );
+ (void)gnc_sql_slots_delete( be, guid );
}
slot_info.be = be;
@@ -443,20 +450,23 @@
buf = g_strdup_printf( "SELECT * FROM %s WHERE obj_guid='%s'", TABLE_NAME, guid_buf );
stmt = gnc_sql_create_statement_from_sql( be, buf );
- result = gnc_sql_execute_select_statement( be, stmt );
- gnc_sql_statement_dispose( stmt );
- if( result != NULL ) {
- GncSqlRow* row = gnc_sql_result_get_first_row( result );
+ g_free( buf );
+ if( stmt != NULL ) {
+ result = gnc_sql_execute_select_statement( be, stmt );
+ gnc_sql_statement_dispose( stmt );
+ if( result != NULL ) {
+ GncSqlRow* row = gnc_sql_result_get_first_row( result );
- while( row != NULL ) {
- load_slot( be, row, pFrame );
- row = gnc_sql_result_get_next_row( result );
- }
- gnc_sql_result_dispose( result );
- }
+ while( row != NULL ) {
+ load_slot( be, row, pFrame );
+ row = gnc_sql_result_get_next_row( result );
+ }
+ gnc_sql_result_dispose( result );
+ }
+ }
}
-static const GUID*
+static /*@ dependent @*//*@ null @*/ const GUID*
load_obj_guid( const GncSqlBackend* be, GncSqlRow* row )
{
static GUID guid;
@@ -481,6 +491,7 @@
g_return_if_fail( coll != NULL );
guid = load_obj_guid( be, row );
+ g_assert( guid != NULL );
inst = qof_collection_lookup_entity( coll, guid );
slot_info.be = be;
@@ -527,6 +538,7 @@
// Execute the query and load the slots
stmt = gnc_sql_create_statement_from_sql( be, sql->str );
+ g_assert( stmt != NULL );
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -545,14 +557,13 @@
static void
create_slots_tables( GncSqlBackend* be )
{
- gboolean ok;
gint version;
g_return_if_fail( be != NULL );
version = gnc_sql_get_table_version( be, TABLE_NAME );
if( version == 0 ) {
- gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
+ (void)gnc_sql_create_table( be, TABLE_NAME, TABLE_VERSION, col_table );
#if 0
// FIXME: Create index
ok = gnc_sql_create_index( be, "slots_guid_index", TABLE_NAME, obj_guid_col_table, &error );
@@ -563,7 +574,7 @@
} else if( version == 1 ) {
/* Upgrade 64-bit int values to proper definition */
gnc_sql_upgrade_table( be, TABLE_NAME, col_table );
- gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
+ (void)gnc_sql_set_table_version( be, TABLE_NAME, TABLE_VERSION );
}
}
@@ -584,6 +595,6 @@
NULL /* write */
};
- qof_object_register_backend( TABLE_NAME, GNC_SQL_BACKEND, &be_data );
+ (void)qof_object_register_backend( TABLE_NAME, GNC_SQL_BACKEND, &be_data );
}
/* ========================== END OF FILE ===================== */
Modified: gnucash/trunk/src/backend/sql/gnc-transaction-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-transaction-sql.c 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-transaction-sql.c 2009-03-09 17:17:57 UTC (rev 17983)
@@ -47,16 +47,20 @@
#include "gnc-engine.h"
-static QofLogModule log_module = G_LOG_DOMAIN;
+#ifdef S_SPLINT_S
+#include "splint-defs.h"
+#endif
+/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
+
#define TRANSACTION_TABLE "transactions"
#define TX_TABLE_VERSION 2
#define SPLIT_TABLE "splits"
#define SPLIT_TABLE_VERSION 2
typedef struct {
- GncSqlBackend* be;
- const GUID* guid;
+ /*@ dependent @*/ GncSqlBackend* be;
+ /*@ dependent @*/ const GUID* guid;
gboolean is_ok;
} split_info_t;
@@ -65,7 +69,7 @@
static const GncSqlColumnTableEntry tx_col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "currency_guid", CT_COMMODITYREF, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)xaccTransGetCurrency, (QofSetterFunc)xaccTransSetCurrency },
@@ -78,27 +82,27 @@
{ "description", CT_STRING, TX_MAX_DESCRIPTION_LEN, 0, NULL, NULL,
(QofAccessFunc)xaccTransGetDescription, (QofSetterFunc)xaccTransSetDescription },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
-static gpointer get_split_reconcile_state( gpointer pObject, const QofParam* param );
-static void set_split_reconcile_state( gpointer pObject, gpointer pValue );
+static /*@ dependent @*//*@ null @*/ gpointer get_split_reconcile_state( gpointer pObject );
+static void set_split_reconcile_state( gpointer pObject, /*@ null @*/ gpointer pValue );
static void set_split_reconcile_date( gpointer pObject, Timespec ts );
-static void set_split_lot( gpointer pObject, gpointer pLot );
+static void set_split_lot( gpointer pObject, /*@ null @*/ gpointer pLot );
#define SPLIT_MAX_MEMO_LEN 2048
#define SPLIT_MAX_ACTION_LEN 2048
static const GncSqlColumnTableEntry split_col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
{ "tx_guid", CT_TXREF, 0, COL_NNUL, NULL, SPLIT_TRANS },
{ "account_guid", CT_ACCOUNTREF, 0, COL_NNUL, NULL, SPLIT_ACCOUNT },
{ "memo", CT_STRING, SPLIT_MAX_MEMO_LEN, COL_NNUL, NULL, SPLIT_MEMO },
{ "action", CT_STRING, SPLIT_MAX_ACTION_LEN, COL_NNUL, NULL, SPLIT_ACTION },
{ "reconcile_state", CT_STRING, 1, COL_NNUL, NULL, NULL,
- get_split_reconcile_state, set_split_reconcile_state },
+ (QofAccessFunc)get_split_reconcile_state, set_split_reconcile_state },
{ "reconcile_date", CT_TIMESPEC, 0, COL_NNUL, NULL, NULL,
(QofAccessFunc)xaccSplitRetDateReconciledTS, (QofSetterFunc)set_split_reconcile_date },
{ "value", CT_NUMERIC, 0, COL_NNUL, NULL, SPLIT_VALUE },
@@ -106,46 +110,42 @@
{ "lot_guid", CT_LOTREF, 0, 0, NULL, NULL,
(QofAccessFunc)xaccSplitGetLot, set_split_lot },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
static const GncSqlColumnTableEntry guid_col_table[] =
{
- /*# -fullinitblock */
+ /*@ -full_init_block @*/
{ "tx_guid", CT_GUID, 0, 0, "guid" },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
-static void retrieve_numeric_value( gpointer pObject, gnc_numeric value );
-
/* ================================================================= */
-static gpointer
-get_split_reconcile_state( gpointer pObject, const QofParam* param )
+static /*@ dependent @*//*@ null @*/ gpointer
+get_split_reconcile_state( gpointer pObject )
{
- const Split* pSplit = GNC_SPLIT(pObject);
static gchar c[2];
g_return_val_if_fail( pObject != NULL, NULL );
g_return_val_if_fail( GNC_IS_SPLIT(pObject), NULL );
- c[0] = xaccSplitGetReconcile( pSplit );
+ c[0] = xaccSplitGetReconcile( GNC_SPLIT(pObject) );
c[1] = '\0';
return (gpointer)c;
}
static void
-set_split_reconcile_state( gpointer pObject, gpointer pValue )
+set_split_reconcile_state( gpointer pObject, /*@ null @*/ gpointer pValue )
{
- Split* pSplit = GNC_SPLIT(pObject);
const gchar* s = (const gchar*)pValue;
g_return_if_fail( pObject != NULL );
g_return_if_fail( GNC_IS_SPLIT(pObject) );
g_return_if_fail( pValue != NULL );
- xaccSplitSetReconcile( pSplit, s[0] );
+ xaccSplitSetReconcile( GNC_SPLIT(pObject), s[0] );
}
static void
@@ -157,18 +157,8 @@
xaccSplitSetDateReconciledTS( GNC_SPLIT(pObject), &ts );
}
-static void
-retrieve_numeric_value( gpointer pObject, gnc_numeric value )
-{
- gnc_numeric* pResult = (gnc_numeric*)pObject;
-
- g_return_if_fail( pObject != NULL );
-
- *pResult = value;
-}
-
static void
-set_split_lot( gpointer pObject, gpointer pLot )
+set_split_lot( gpointer pObject, /*@ null @*/ gpointer pLot )
{
GNCLot* lot;
Split* split;
@@ -185,18 +175,7 @@
gnc_lot_add_split( lot, split );
}
-#if 0
-// Table to retrieve just the quantity
-static GncSqlColumnTableEntry quantity_table[] =
-{
- /*# -fullinitblock */
- { "quantity", CT_NUMERIC, 0, COL_NNUL, NULL, NULL, NULL, (QofSetterFunc)retrieve_numeric_value },
- { NULL }
- /*# +fullinitblock */
-};
-#endif
-
-static Split*
+static /*@ null @*/ Split*
load_single_split( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
@@ -207,6 +186,7 @@
g_return_val_if_fail( row != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
+ if( guid == NULL ) return NULL;
split_guid = *guid;
pSplit = xaccSplitLookup( &split_guid, be->primary_book );
@@ -242,7 +222,7 @@
// Execute the query and load the splits
result = gnc_sql_execute_select_sql( be, sql->str );
if( result != NULL ) {
- GList* list = NULL;
+ GList* split_list = NULL;
GncSqlRow* row;
row = gnc_sql_result_get_first_row( result );
@@ -250,13 +230,14 @@
Split* s;
s = load_single_split( be, row );
if( s != NULL ) {
- list = g_list_append( list, s );
+ split_list = g_list_append( split_list, s );
}
row = gnc_sql_result_get_next_row( result );
}
- if( list != NULL ) {
- gnc_sql_slots_load_for_list( be, list );
+ if( split_list != NULL ) {
+ gnc_sql_slots_load_for_list( be, split_list );
+ g_list_free( split_list );
}
gnc_sql_result_dispose( result );
@@ -264,7 +245,7 @@
(void)g_string_free( sql, FALSE );
}
-static Transaction*
+static /*@ null @*/ Transaction*
load_single_tx( GncSqlBackend* be, GncSqlRow* row )
{
const GUID* guid;
@@ -275,6 +256,7 @@
g_return_val_if_fail( row != NULL, NULL );
guid = gnc_sql_load_guid( be, row );
+ if( guid == NULL ) return NULL;
tx_guid = *guid;
// Don't overwrite the transaction if it's already been loaded (and possibly modified).
@@ -299,7 +281,7 @@
* are unchanged.
*/
typedef struct {
- Account* acc;
+ /*@ dependent @*/ Account* acc;
gnc_numeric start_bal;
gnc_numeric end_bal;
gnc_numeric start_cleared_bal;
@@ -324,6 +306,8 @@
gnc_numeric* pend_r;
newbal = g_malloc( (gsize)sizeof( full_acct_balances_t ) );
+ g_assert( newbal != NULL );
+
newbal->acc = acc;
g_object_get( acc,
"start-balance", &pstart,
@@ -436,7 +420,9 @@
}
xaccAccountRecomputeBalance( balns->acc );
}
- g_slist_free( bal_list );
+ if( bal_list != NULL ) {
+ g_slist_free( bal_list );
+ }
xaccAccountCommitEdit( root );
qof_event_resume();
@@ -453,20 +439,20 @@
version = gnc_sql_get_table_version( be, TRANSACTION_TABLE );
if( version == 0 ) {
- gnc_sql_create_table( be, TRANSACTION_TABLE, TX_TABLE_VERSION, tx_col_table );
+ (void)gnc_sql_create_table( be, TRANSACTION_TABLE, TX_TABLE_VERSION, tx_col_table );
} else if( version == 1 ) {
/* Upgrade 64 bit int handling */
gnc_sql_upgrade_table( be, TRANSACTION_TABLE, tx_col_table );
- gnc_sql_set_table_version( be, TRANSACTION_TABLE, TX_TABLE_VERSION );
+ (void)gnc_sql_set_table_version( be, TRANSACTION_TABLE, TX_TABLE_VERSION );
}
version = gnc_sql_get_table_version( be, SPLIT_TABLE );
if( version == 0 ) {
- gnc_sql_create_table( be, SPLIT_TABLE, SPLIT_TABLE_VERSION, split_col_table );
+ (void)gnc_sql_create_table( be, SPLIT_TABLE, SPLIT_TABLE_VERSION, split_col_table );
} else if( version == 1 ) {
/* Upgrade 64 bit int handling */
gnc_sql_upgrade_table( be, SPLIT_TABLE, split_col_table );
- gnc_sql_set_table_version( be, SPLIT_TABLE, SPLIT_TABLE_VERSION );
+ (void)gnc_sql_set_table_version( be, SPLIT_TABLE, SPLIT_TABLE_VERSION );
}
}
/* ================================================================= */
@@ -638,7 +624,7 @@
}
/* ================================================================= */
-static const GUID*
+static /*@ dependent @*//*@ null @*/ const GUID*
get_guid_from_query( QofQuery* pQuery )
{
GList* pOrTerms;
@@ -689,8 +675,11 @@
query_sql = g_strdup_printf( "SELECT * FROM %s WHERE guid IN (%s)", TRANSACTION_TABLE, subquery_sql );
g_free( subquery_sql );
stmt = gnc_sql_create_statement_from_sql( be, query_sql );
- query_transactions( be, stmt );
- gnc_sql_statement_dispose( stmt );
+ g_free( query_sql );
+ if( stmt != NULL ) {
+ query_transactions( be, stmt );
+ gnc_sql_statement_dispose( stmt );
+ }
}
/**
@@ -708,8 +697,11 @@
query_sql = g_strdup_printf( "SELECT * FROM %s", TRANSACTION_TABLE );
stmt = gnc_sql_create_statement_from_sql( be, query_sql );
- query_transactions( be, stmt );
- gnc_sql_statement_dispose( stmt );
+ g_free( query_sql );
+ if( stmt != NULL ) {
+ query_transactions( be, stmt );
+ gnc_sql_statement_dispose( stmt );
+ }
}
typedef struct {
@@ -718,12 +710,12 @@
gboolean has_been_run;
} split_query_info_t;
-static gpointer
+static /*@ null @*/ gpointer
compile_split_query( GncSqlBackend* be, QofQuery* pQuery )
{
const GUID* acct_guid;
gchar guid_buf[GUID_ENCODING_LENGTH+1];
- split_query_info_t* query_info;
+ split_query_info_t* query_info = NULL;
gchar* subquery_sql;
gchar* query_sql;
@@ -731,17 +723,22 @@
g_return_val_if_fail( pQuery != NULL, NULL );
acct_guid = get_guid_from_query( pQuery );
- (void)guid_to_string_buff( acct_guid, guid_buf );
- subquery_sql = g_strdup_printf( "SELECT DISTINCT tx_guid FROM %s WHERE account_guid='%s'", SPLIT_TABLE, guid_buf );
- query_sql = g_strdup_printf( "SELECT * FROM %s WHERE guid IN (%s)", TRANSACTION_TABLE, subquery_sql );
+ if( acct_guid != NULL ) {
+ (void)guid_to_string_buff( acct_guid, guid_buf );
+ subquery_sql = g_strdup_printf( "SELECT DISTINCT tx_guid FROM %s WHERE account_guid='%s'", SPLIT_TABLE, guid_buf );
+ query_sql = g_strdup_printf( "SELECT * FROM %s WHERE guid IN (%s)", TRANSACTION_TABLE, subquery_sql );
- query_info = g_malloc( (gsize)sizeof(split_query_info_t) );
- query_info->stmt = gnc_sql_create_statement_from_sql( be, query_sql );
- query_info->has_been_run = FALSE;
- query_info->acct = xaccAccountLookup( acct_guid, be->primary_book );
+ query_info = g_malloc( (gsize)sizeof(split_query_info_t) );
+ g_assert( query_info != NULL );
- g_free( subquery_sql );
+ query_info->stmt = gnc_sql_create_statement_from_sql( be, query_sql );
+ g_free( query_sql );
+ query_info->has_been_run = FALSE;
+ query_info->acct = xaccAccountLookup( acct_guid, be->primary_book );
+ g_free( subquery_sql );
+ }
+
return query_info;
}
@@ -775,8 +772,8 @@
/* ----------------------------------------------------------------- */
typedef struct {
- const GncSqlBackend* be;
- Account* acct;
+ /*@ dependent @*/ const GncSqlBackend* be;
+ /*@ dependent @*/ Account* acct;
char reconcile_state;
gnc_numeric balance;
} single_acct_balance_t;
@@ -817,15 +814,15 @@
static const GncSqlColumnTableEntry acct_balances_col_table[] =
{
- /*# -fullinitblock */
- { "account_guid", CT_GUID, 0, 0, NULL, NULL, NULL, set_acct_bal_account_from_guid },
- { "reconcile_state", CT_STRING, 1, 0, NULL, NULL, NULL, set_acct_bal_reconcile_state },
+ /*@ -full_init_block @*/
+ { "account_guid", CT_GUID, 0, 0, NULL, NULL, NULL, (QofSetterFunc)set_acct_bal_account_from_guid },
+ { "reconcile_state", CT_STRING, 1, 0, NULL, NULL, NULL, (QofSetterFunc)set_acct_bal_reconcile_state },
{ "quantity", CT_NUMERIC, 0, 0, NULL, NULL, NULL, (QofSetterFunc)set_acct_bal_balance },
{ NULL }
- /*# +fullinitblock */
+ /*@ +full_init_block @*/
};
-static single_acct_balance_t*
+static /*@ null @*/ single_acct_balance_t*
load_single_acct_balances( const GncSqlBackend* be, GncSqlRow* row )
{
single_acct_balance_t* bal = NULL;
@@ -834,13 +831,15 @@
g_return_val_if_fail( row != NULL, NULL );
bal = g_malloc( (gsize)sizeof(single_acct_balance_t) );
+ g_assert( bal != NULL );
+
bal->be = be;
gnc_sql_load_object( be, row, NULL, bal, acct_balances_col_table );
return bal;
}
-GSList*
+/*@ null @*/ GSList*
gnc_sql_get_account_balances_slist( GncSqlBackend* be )
{
GncSqlResult* result;
@@ -853,7 +852,8 @@
buf = g_strdup_printf( "SELECT account_guid, reconcile_state, sum(quantity_num) as quantity_num, quantity_denom FROM %s GROUP BY account_guid, reconcile_state, quantity_denom",
SPLIT_TABLE );
stmt = gnc_sql_create_statement_from_sql( be, buf );
-
+ g_assert( stmt != NULL );
+ g_free( buf );
result = gnc_sql_execute_select_statement( be, stmt );
gnc_sql_statement_dispose( stmt );
if( result != NULL ) {
@@ -877,6 +877,8 @@
}
if( bal == NULL ) {
bal = g_malloc( (gsize)sizeof(acct_balances_t) );
+ g_assert( bal != NULL );
+
bal->acct = single_bal->acct;
bal->balance = gnc_numeric_zero();
bal->cleared_balance = gnc_numeric_zero();
@@ -892,6 +894,7 @@
bal->reconciled_balance = gnc_numeric_add( bal->reconciled_balance, single_bal->balance,
GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD );
}
+ g_free( single_bal );
}
row = gnc_sql_result_get_next_row( result );
}
@@ -913,13 +916,12 @@
/* ----------------------------------------------------------------- */
static void
load_tx_guid( const GncSqlBackend* be, GncSqlRow* row,
- QofSetterFunc setter, gpointer pObject,
+ /*@ null @*/ QofSetterFunc setter, gpointer pObject,
const GncSqlColumnTableEntry* table_row )
{
const GValue* val;
GUID guid;
- const GUID* pGuid;
- Transaction* tx = NULL;
+ Transaction* tx;
g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL );
@@ -927,18 +929,13 @@
g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
- if( val == NULL ) {
- pGuid = NULL;
- } else {
- string_to_guid( g_value_get_string( val ), &guid );
- pGuid = &guid;
- }
- if( pGuid != NULL ) {
- tx = xaccTransLookup( pGuid, be->primary_book );
- }
+ g_assert( val != NULL );
+ (void)string_to_guid( g_value_get_string( val ), &guid );
+ tx = xaccTransLookup( &guid, be->primary_book );
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, tx, NULL );
} else {
+ g_return_if_fail( setter != NULL );
(*setter)( pObject, (const gpointer)tx );
}
}
@@ -977,8 +974,8 @@
NULL /* write */
};
- qof_object_register_backend( GNC_ID_TRANS, GNC_SQL_BACKEND, &be_data_tx );
- qof_object_register_backend( GNC_ID_SPLIT, GNC_SQL_BACKEND, &be_data_split );
+ (void)qof_object_register_backend( GNC_ID_TRANS, GNC_SQL_BACKEND, &be_data_tx );
+ (void)qof_object_register_backend( GNC_ID_SPLIT, GNC_SQL_BACKEND, &be_data_split );
gnc_sql_register_col_type_handler( CT_TXREF, &tx_guid_handler );
}
Modified: gnucash/trunk/src/backend/sql/gnc-transaction-sql.h
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-transaction-sql.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/backend/sql/gnc-transaction-sql.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -80,6 +80,6 @@
* @param be SQL backend
* @return GSList of acct_balances_t structures
*/
-GSList* gnc_sql_get_account_balances_slist( GncSqlBackend* be );
+/*@ null @*/ GSList* gnc_sql_get_account_balances_slist( GncSqlBackend* be );
#endif /* GNC_TRANSACTION_SQL_H_ */
Modified: gnucash/trunk/src/core-utils/gnc-gconf-utils.h
===================================================================
--- gnucash/trunk/src/core-utils/gnc-gconf-utils.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/core-utils/gnc-gconf-utils.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -274,8 +274,8 @@
* returned by GConf.
*/
gboolean gnc_gconf_get_bool (const gchar *section,
- const gchar *name,
- GError **error);
+ /*@ null @*/ const gchar *name,
+ /*@ null @*/ GError **error);
/** Get a boolean value from GConf with no error argument.
*
Modified: gnucash/trunk/src/engine/Account.h
===================================================================
--- gnucash/trunk/src/engine/Account.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/engine/Account.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -228,7 +228,7 @@
gunichar gnc_get_account_separator (void);
void gnc_set_account_separator (const gchar *separator);
-Account *gnc_book_get_root_account(QofBook *book);
+/*@ dependent @*/ Account *gnc_book_get_root_account(QofBook *book);
void gnc_book_set_root_account(QofBook *book, Account *root);
/** @deprecated */
@@ -238,7 +238,7 @@
/** The xaccAccountLookup() subroutine will return the
* account associated with the given id, or NULL
* if there is no such account. */
-Account * xaccAccountLookup (const GUID *guid, QofBook *book);
+/*@ dependent @*/ Account * xaccAccountLookup (const GUID *guid, QofBook *book);
#define xaccAccountLookupDirect(g,b) xaccAccountLookup(&(g),b)
/** @} */
@@ -475,7 +475,7 @@
#define DxaccAccountSetSecurity xaccAccountSetCommodity
/** Get the account's commodity */
-gnc_commodity * xaccAccountGetCommodity (const Account *account);
+/*@ dependent @*/ gnc_commodity * xaccAccountGetCommodity (const Account *account);
/** @deprecated do not use */
#define DxaccAccountGetSecurity xaccAccountGetCommodity
@@ -627,7 +627,7 @@
*
* @return A pointer to the parent account node, or NULL if there is
* no parent account. */
-Account * gnc_account_get_parent (const Account *account);
+/*@ dependent @*/ Account * gnc_account_get_parent (const Account *account);
/** This routine returns the root account of the account tree that the
* specified account belongs to. It is the equivalent of repeatedly
@@ -773,7 +773,7 @@
*
* @param user_data This data will be passed to each call of func. */
void gnc_account_foreach_child (const Account *account,
- AccountCb func, gpointer user_data);
+ AccountCb func, /*@ null @*/ gpointer user_data);
/** This method will traverse the immediate children of this accounts,
* calling 'func' on each account. Traversal will stop when func
@@ -791,7 +791,7 @@
*
* @param user_data This data will be passed to each call of func. */
gpointer gnc_account_foreach_child_until (const Account *account,
- AccountCb2 func, gpointer user_data);
+ AccountCb2 func, /*@ null @*/ gpointer user_data);
/** This method will traverse all children of this accounts and their
@@ -808,7 +808,7 @@
*
* @param user_data This data will be passed to each call of func. */
void gnc_account_foreach_descendant (const Account *account,
- AccountCb func, gpointer user_data);
+ AccountCb func, /*@ null @*/ gpointer user_data);
/** This method will traverse all children of this accounts and their
* descendants, calling 'func' on each account. Traversal will stop
@@ -826,7 +826,7 @@
*
* @param user_data This data will be passed to each call of func. */
gpointer gnc_account_foreach_descendant_until (const Account *account,
- AccountCb2 func, gpointer user_data);
+ AccountCb2 func, /*@ null @*/ gpointer user_data);
/** @} */
@@ -1056,7 +1056,7 @@
*/
gpointer xaccAccountForEachLot(
const Account *acc,
- gpointer (*proc)(GNCLot *lot, gpointer user_data), gpointer user_data);
+ gpointer (*proc)(GNCLot *lot, gpointer user_data), /*@ null @*/ gpointer user_data);
/** Find a list of open lots that match the match_func. Sort according
@@ -1067,7 +1067,7 @@
LotList * xaccAccountFindOpenLots (const Account *acc,
gboolean (*match_func)(GNCLot *lot,
gpointer user_data),
- gpointer user_data, GCompareFunc sort_func);
+ /*@ null @*/ gpointer user_data, GCompareFunc sort_func);
/** @} */
/* ------------------ */
Modified: gnucash/trunk/src/engine/SX-book.h
===================================================================
--- gnucash/trunk/src/engine/SX-book.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/engine/SX-book.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -74,13 +74,13 @@
#define GNC_IS_SXES(obj) GNC_IS_SCHEDXACTIONS(obj)
#define GNC_SXES(obj) GNC_SCHEDXACTIONS(obj)
-SchedXactions* gnc_book_get_schedxactions(QofBook* book);
+/*@ dependent @*/ SchedXactions* gnc_book_get_schedxactions(QofBook* book);
void gnc_sxes_add_sx(SchedXactions* sxes, SchedXaction* sx);
void gnc_sxes_del_sx(SchedXactions* sxes, SchedXaction* sx);
/** Returns the template group from the book. **/
-Account *gnc_book_get_template_root(const QofBook *book);
+/*@ dependent @*/ Account *gnc_book_get_template_root(const QofBook *book);
/** @return The list of SXes which reference the given Account. Caller should free this list. **/
GList* gnc_sx_get_sxes_referencing_account(QofBook *book, Account *acct);
Modified: gnucash/trunk/src/engine/SchedXaction.h
===================================================================
--- gnucash/trunk/src/engine/SchedXaction.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/engine/SchedXaction.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -148,9 +148,9 @@
void gnc_sx_commit_edit (SchedXaction *sx);
/** @return GList<Recurrence*> **/
-GList* gnc_sx_get_schedule(const SchedXaction *sx);
+/*@ dependent @*/ GList* gnc_sx_get_schedule(const SchedXaction *sx);
/** @param[in] schedule A GList<Recurrence*> **/
-void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule);
+void gnc_sx_set_schedule(SchedXaction *sx, /*@ null @*//*@ only @*/ GList *schedule);
gchar *xaccSchedXactionGetName( const SchedXaction *sx );
/**
@@ -196,7 +196,7 @@
* @param sx The instance whose state should be retrieved.
* @param stateData may be NULL.
*/
-gint gnc_sx_get_instance_count( const SchedXaction *sx, void *stateData );
+gint gnc_sx_get_instance_count( const SchedXaction *sx, /*@ null @*/ void *stateData );
/**
* Sets the instance count to something other than the default. As the
* default is the incorrect value '0', callers should DTRT here.
@@ -210,8 +210,8 @@
void xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled );
void xaccSchedXactionGetAutoCreate( const SchedXaction *sx,
- gboolean *outAutoCreate,
- gboolean *outNotify );
+ /*@ out @*/ gboolean *outAutoCreate,
+ /*@ out @*/ gboolean *outNotify );
void xaccSchedXactionSetAutoCreate( SchedXaction *sx,
gboolean newAutoCreate,
gboolean newNotify );
Modified: gnucash/trunk/src/engine/Transaction.h
===================================================================
--- gnucash/trunk/src/engine/Transaction.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/engine/Transaction.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -215,7 +215,7 @@
/** The xaccTransLookup() subroutine will return the
transaction associated with the given id, or NULL
if there is no such transaction. */
-Transaction * xaccTransLookup (const GUID *guid, QofBook *book);
+/*@ dependent @*//*@ null @*/ Transaction * xaccTransLookup (const GUID *guid, QofBook *book);
#define xaccTransLookupDirect(g,b) xaccTransLookup(&(g),b)
Split * xaccTransFindSplitByAccount(const Transaction *trans,
@@ -303,7 +303,7 @@
in a transaction.
@return The list of splits. This list must NOT be modified. Do *NOT* free
this list when you are done with it. */
-SplitList * xaccTransGetSplitList (const Transaction *trans);
+/*@ dependent @*/ SplitList * xaccTransGetSplitList (const Transaction *trans);
gboolean xaccTransStillHasSplit(const Transaction *trans, const Split *s);
@@ -337,7 +337,7 @@
* The total value of the transaction must be zero when all splits
* are valued in this currency.
* @note What happens if the Currency isn't set? Ans: bad things. */
-gnc_commodity * xaccTransGetCurrency (const Transaction *trans);
+/*@ dependent @*/ gnc_commodity * xaccTransGetCurrency (const Transaction *trans);
/** Set the commodity of this transaction. */
void xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr);
Modified: gnucash/trunk/src/engine/gnc-budget.h
===================================================================
--- gnucash/trunk/src/engine/gnc-budget.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/engine/gnc-budget.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -95,7 +95,7 @@
/**
* Creates and initializes a Budget.
**/
-GncBudget *gnc_budget_new(QofBook *book);
+/*@ dependent @*/ GncBudget *gnc_budget_new(QofBook *book);
/** Deletes the given budget object.*/
void gnc_budget_destroy(GncBudget* budget);
@@ -103,24 +103,24 @@
void gnc_budget_begin_edit(GncBudget *bgt);
void gnc_budget_commit_edit(GncBudget *bgt);
-const GUID* gnc_budget_get_guid(GncBudget* budget);
+/*@ dependent @*/ const GUID* gnc_budget_get_guid(GncBudget* budget);
#define gnc_budget_return_guid(X) \
(X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
/** Set/Get the name of the Budget */
void gnc_budget_set_name(GncBudget* budget, const gchar* name);
-const gchar* gnc_budget_get_name(GncBudget* budget);
+/*@ dependent @*/ const gchar* gnc_budget_get_name(GncBudget* budget);
/** Set/Get the description of the Budget */
void gnc_budget_set_description(GncBudget* budget, const gchar* description);
-const gchar* gnc_budget_get_description(GncBudget* budget);
+/*@ dependent @*/ const gchar* gnc_budget_get_description(GncBudget* budget);
/** Set/Get the number of periods in the Budget */
void gnc_budget_set_num_periods(GncBudget* budget, guint num_periods);
guint gnc_budget_get_num_periods(GncBudget* budget);
void gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r);
-const Recurrence * gnc_budget_get_recurrence(GncBudget *budget);
+/*@ dependent @*/ const Recurrence * gnc_budget_get_recurrence(GncBudget *budget);
/** Set/Get the starting date of the Budget */
Timespec gnc_budget_get_period_start_date(GncBudget* budget, guint period_num);
@@ -146,7 +146,7 @@
GncBudget* gnc_budget_get_default(QofBook *book);
/* Get the budget associated with the given GUID from the given book. */
-GncBudget* gnc_budget_lookup (const GUID *guid, QofBook *book);
+/*@ dependent @*/ GncBudget* gnc_budget_lookup (const GUID *guid, QofBook *book);
#define gnc_budget_lookup_direct(g,b) gnc_budget_lookup(&(g),(b))
#endif // __BUDGET_H__
Modified: gnucash/trunk/src/engine/gnc-commodity.h
===================================================================
--- gnucash/trunk/src/engine/gnc-commodity.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/engine/gnc-commodity.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -180,7 +180,7 @@
* @return A pointer to the price quote source that has the specified
* internal name.
*/
-gnc_quote_source *gnc_quote_source_lookup_by_internal(const char * internal_name);
+/*@ dependent @*/ gnc_quote_source *gnc_quote_source_lookup_by_internal(const char * internal_name);
/** Given the type/index of a quote source, find the data structure
* identified by this pair.
@@ -230,7 +230,7 @@
*
* @return The user friendly name.
*/
-const char *gnc_quote_source_get_user_name (const gnc_quote_source *source);
+/*@ dependent @*/ const char *gnc_quote_source_get_user_name (const gnc_quote_source *source);
/** Given a gnc_quote_source data structure, return the internal name
* of this quote source. This is the name used by both gnucash and
@@ -240,7 +240,7 @@
*
* @return The internal name.
*/
-const char *gnc_quote_source_get_internal_name (const gnc_quote_source *source);
+/*@ dependent @*/ const char *gnc_quote_source_get_internal_name (const gnc_quote_source *source);
/** Given a gnc_quote_source data structure, return the internal name
* of this quote source. This is the name used by both gnucash and
@@ -294,11 +294,11 @@
*
* @return A pointer to the new commodity.
*/
-gnc_commodity * gnc_commodity_new(QofBook *book,
- const char * fullname,
- const char * namespace,
- const char * mnemonic,
- const char * cusip,
+/*@ dependent @*/ gnc_commodity * gnc_commodity_new(QofBook *book,
+ /*@ null @*/ const char * fullname,
+ /*@ null @*/ const char * namespace,
+ /*@ null @*/ const char * mnemonic,
+ /*@ null @*/ const char * cusip,
int fraction);
/** Destroy a commodity. Release all memory attached to this data structure.
@@ -461,8 +461,8 @@
*
* @return A pointer to the price quote source for this commodity.
*/
-gnc_quote_source* gnc_commodity_get_quote_source(const gnc_commodity *cm);
-gnc_quote_source* gnc_commodity_get_default_quote_source(const gnc_commodity *cm);
+/*@ dependent @*/ gnc_quote_source* gnc_commodity_get_quote_source(const gnc_commodity *cm);
+/*@ dependent @*/ gnc_quote_source* gnc_commodity_get_default_quote_source(const gnc_commodity *cm);
/** Retrieve the automatic price quote timezone for the specified
* commodity. This will be a pointer to a null terminated string of
@@ -697,7 +697,7 @@
/** Returns the commodity table assoicated with a book.
*/
-gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book);
+/*@ dependent @*/ gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book);
/* XXX backwards compat function; remove me someday */
#define gnc_book_get_commodity_table gnc_commodity_table_get_table
@@ -725,7 +725,7 @@
const char * namespace,
const char * fullname);
-gnc_commodity * gnc_commodity_find_commodity_by_guid(const GUID *guid, QofBook *book);
+/*@ dependent @*/ gnc_commodity * gnc_commodity_find_commodity_by_guid(const GUID *guid, QofBook *book);
gnc_commodity_namespace * gnc_commodity_find_namespace_by_guid(const GUID *guid, QofBook *book);
/** @} */
@@ -749,7 +749,7 @@
* @note The commodity pointer passed to this function should not be
* used after its return, as it may have been destroyed. Use the
* return value which is guaranteed to be valid. */
-gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table,
+/*@ dependent @*/ gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table,
gnc_commodity * comm);
/** Remove a commodity from the commodity table. If the commodity to
Modified: gnucash/trunk/src/engine/gnc-lot.h
===================================================================
--- gnucash/trunk/src/engine/gnc-lot.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/engine/gnc-lot.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -79,10 +79,10 @@
GType gnc_lot_get_type(void);
-GNCLot * gnc_lot_new (QofBook *);
+/*@ dependent @*/ GNCLot * gnc_lot_new (QofBook *);
void gnc_lot_destroy (GNCLot *);
-GNCLot * gnc_lot_lookup (const GUID *guid, QofBook *book);
+/*@ dependent @*/ GNCLot * gnc_lot_lookup (const GUID *guid, QofBook *book);
QofBook * gnc_lot_get_book (GNCLot *);
void gnc_lot_begin_edit (GNCLot *lot);
@@ -110,7 +110,7 @@
/** The gnc_lot_get_account() routine returns the account with which
* this lot is associated. */
-Account * gnc_lot_get_account (const GNCLot *);
+/*@ dependent @*/ Account * gnc_lot_get_account (const GNCLot *);
/** The gnc_lot_get_balance() routine returns the balance of the lot.
* The commodity in which this balance is expressed is the commodity
Modified: gnucash/trunk/src/engine/gnc-pricedb.h
===================================================================
--- gnucash/trunk/src/engine/gnc-pricedb.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/engine/gnc-pricedb.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -166,7 +166,7 @@
/** gnc_price_create - returns a newly allocated and initialized price
with a reference count of 1. */
-GNCPrice *gnc_price_create(QofBook *book);
+/*@ dependent @*/ GNCPrice *gnc_price_create(QofBook *book);
/** gnc_price_clone - returns a newly allocated price that's a
content-wise duplicate of the given price, p. The returned clone
@@ -219,8 +219,8 @@
/** As mentioned above all of the getters return data that's internal
to the GNCPrice, not copies, so don't free these values. */
GNCPrice * gnc_price_lookup (const GUID *guid, QofBook *book);
-gnc_commodity * gnc_price_get_commodity(const GNCPrice *p);
-gnc_commodity * gnc_price_get_currency(const GNCPrice *p);
+/*@ dependent @*/ gnc_commodity * gnc_price_get_commodity(const GNCPrice *p);
+/*@ dependent @*/ gnc_commodity * gnc_price_get_currency(const GNCPrice *p);
Timespec gnc_price_get_time(const GNCPrice *p);
const char * gnc_price_get_source(const GNCPrice *p);
const char * gnc_price_get_typestr(const GNCPrice *p);
@@ -281,7 +281,7 @@
#define gnc_book_get_pricedb gnc_pricedb_get_db
/** return the pricedb associated with the book */
-GNCPriceDB * gnc_pricedb_get_db(QofBook *book);
+/*@ dependent @*/ GNCPriceDB * gnc_pricedb_get_db(QofBook *book);
GNCPriceDB * gnc_collection_get_pricedb(QofCollection *col);
/** gnc_pricedb_destroy - destroy the given pricedb and unref all of
Modified: gnucash/trunk/src/gnc-module/gnc-module.h
===================================================================
--- gnucash/trunk/src/gnc-module/gnc-module.h 2009-03-08 19:14:41 UTC (rev 17982)
+++ gnucash/trunk/src/gnc-module/gnc-module.h 2009-03-09 17:17:57 UTC (rev 17983)
@@ -25,7 +25,7 @@
* module_name is not a const gchar?! It certainly should be const
* (because of passing string literals), and from a quick glance it is
* also only used in a const way. */
-GNCModule gnc_module_load(gchar * module_name, gint iface);
+/*@ dependent @*/ GNCModule gnc_module_load(gchar * module_name, gint iface);
GNCModule gnc_module_load_optional(gchar * module_name, gint iface);
int gnc_module_unload(GNCModule mod);
More information about the gnucash-changes
mailing list