Commit Graph

209 Commits

Author SHA1 Message Date
Richard Cohen
9c6ad222a9 [-Wunused-function] - remove 2023-02-16 09:20:59 +00:00
Richard Cohen
0f3813e0fd [-Wunused-private-field] (clang) - remove
In file included from gnucash/gnome-utils/dialog-options.cpp:34:
gnucash/gnome-utils/dialog-options.hpp:55:10: warning: private field 'toplevel' is not used [-Wunused-private-field]
    bool toplevel;
         ^

In file included from gnucash/import-export/csv-imp/gnc-imp-props-price.cpp:42:
gnucash/import-export/csv-imp/gnc-imp-props-price.hpp:113:10: warning: private field 'created' is not used [-Wunused-private-field]
    bool created = false;
         ^

libgnucash/backend/dbi/gnc-dbisqlconnection.cpp:53:29: warning: private field 'm_conn' is not used [-Wunused-private-field]
    const GncSqlConnection* m_conn = nullptr;
                            ^
libgnucash/backend/sql/test/utest-gnc-backend-sql.cpp:81:33: warning: private field 'm_conn' is not used [-Wunused-private-field]
    const GncMockSqlConnection* m_conn;
                                ^
2023-02-16 09:20:18 +00:00
Richard Cohen
0798bce2a6 [-Wunused-value] - remove
borrowed/jenny/jenny.c: In function ‘next_builder’:
borrowed/jenny/jenny.c:1164:5: warning: statement with no effect [-Wunused-value]
 1164 |     for (i; i<n-1; ++i) {            /* reset all less significant positions */
      |     ^~~
borrowed/jenny/jenny.c:1172:5: warning: statement with no effect [-Wunused-value]
 1172 |     for (i; i<n-1; ++i) {            /* reset all less significant positions */
      |     ^~~
borrowed/jenny/jenny.c: In function ‘confirm’:
borrowed/jenny/jenny.c:1797:7: warning: statement with no effect [-Wunused-value]
 1797 |       for (i; i<n-1; ++i) {          /* reset all less significant positions */
      |       ^~~
borrowed/jenny/jenny.c:1805:7: warning: statement with no effect [-Wunused-value]
 1805 |       for (i; i<n-1; ++i) {          /* reset all less significant positions */
      |       ^~~

libgnucash/backend/xml/io-gncxml-v2.cpp: In function ‘gboolean qof_session_load_from_xml_file_v2_full(GncXmlBackend*, QofBook*, sixtp_push_handler, gpointer, QofBookFileType)’:
libgnucash/backend/xml/io-gncxml-v2.cpp:806:40: warning: value computed is not used [-Wunused-value]
  806 |                 g_thread_join (thread) != nullptr;
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~

libgnucash/engine/Account.cpp: In function ‘void xaccFreeAccount(Account*)’:
libgnucash/engine/Account.cpp:1428:17: warning: statement has no effect [-Wunused-value]
 1428 |     priv->color == nullptr;
      |     ~~~~~~~~~~~~^~~~~~~~~~
libgnucash/engine/Account.cpp:1429:22: warning: statement has no effect [-Wunused-value]
 1429 |     priv->sort_order == nullptr;
      |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~
libgnucash/engine/Account.cpp:1430:17: warning: statement has no effect [-Wunused-value]
 1430 |     priv->notes == nullptr;
      |     ~~~~~~~~~~~~^~~~~~~~~~
libgnucash/engine/Account.cpp:1431:18: warning: statement has no effect [-Wunused-value]
 1431 |     priv->filter == nullptr;
      |     ~~~~~~~~~~~~~^~~~~~~~~~

libgnucash/engine/gnc-int128.cpp: In function ‘void decimal_from_binary(uint64_t*, uint64_t, uint64_t)’:
libgnucash/engine/gnc-int128.cpp:898:36: warning: right operand of comma operator has no effect [-Wunused-value]
  898 |     d[3] = (hi >> 32) & bin_mask, 0;
      |                                    ^
2023-02-16 09:19:19 +00:00
Richard Cohen
1c6679720b Use some unused variables 2023-02-06 14:20:31 +00:00
Richard Cohen
78ec20515b Remove some unused variables - and the initialization
- checked that any side effects were irrelevant
2023-02-06 14:20:28 +00:00
Richard Cohen
ea2d3be217 Remove some unused variables with obviously no side effects 2023-02-06 14:19:22 +00:00
Richard Cohen
4e25bbfc43 Mark some QofLogModules as potentially unused
- __attribute__((unused)) for C
- [[maybe_unused]] for cpp
2023-02-06 14:12:31 +00:00
Richard Cohen
d8f45f2443 Use const references for for-loops to avoid unnecessary copies
Found by clazy - clazy-range-loop-reference
2023-01-31 14:44:57 +00:00
Richard Cohen
846e75146a Fix some typos so that the correct tests are run
- test_gnc_txn_to_float_txn_cut_semantics
- test_dbi_business_store_and_reload
2023-01-26 15:42:13 +00:00
John Ralls
f6919e60a7 Merge Richard Cohen's 'cleanup' into master. 2023-01-24 12:05:47 -08:00
John Ralls
046e4a156e Silence Clang deprecation warnings about sprintf. 2023-01-23 12:54:25 -08:00
Richard Cohen
1cec0cb3f3 Use internal extern "C" { ... } for C++
- removes warnings compiling swig engine
...
[ 10%] Generating swig-engine.cpp
.../libgnucash/engine/engine-helpers.h:31: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gnc-date.h:83: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/qofquery.h:90: Warning 302: Identifier 'QofQuery' redefined (ignored),
.../libgnucash/engine/gnc-option.hpp:55: Warning 302: previous definition of 'QofQuery'.
.../libgnucash/engine/gnc-commodity.h:56: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncBusiness.h:40: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncEntry.h:37: Warning 313: Unrecognized extern type "C++".
2023-01-23 18:40:01 +00:00
Richard Cohen
19bbde7000 Fix some typos 2023-01-23 15:01:46 +00:00
Geert Janssens
734f90bd36 Replace string literal 'gnucash' with PROJECT_NAME parameter where it makes sense
The idea behind this is to not assume the project is always built
as "gnucash" exactly.
One example where it can be useful to use a different project name
would be when building multiple development versions of the project
on the same system and don't want these different versions share
the same settings in GSettings or the same stored passwords.
2022-12-19 22:18:12 +01:00
John Ralls
f24c2c8bdd Instrument failure to set the account when creating a split. 2022-10-11 14:05:45 -07:00
luz paz
ba94730a23 Fix various typos
Found via `codespell`
2022-09-06 10:44:29 -04:00
luz paz
cfc6e9d7e0 Fix source typo begining->beginning 2022-06-27 07:16:54 -04:00
luz paz
8adedc2248 Fix various typos
Found via `codespell -q 3 -S *.po,./po,*.min.js,./ChangeLog*,./NEWS,./borrowed,./doc/README*,./AUTHORS,./libgnucash/tax/us/txf-de*,./data/accounts -L ans,ba,cas,dragable,gae,iff,iif,mut,nd,numer,parm,parms,startd,stoll`
2022-04-08 14:12:50 -04:00
Christopher Lam
4a75baa4c6 [gnc-xml-backend.cpp] gchar* must be freed after use.
It is used as a constructor for std::string which makes a copy but
doesn't take ownership.
2022-03-21 07:26:45 +08:00
John Ralls
916caa25f2 Integrate Windows gzopen differences so that only one ifdef is needed.
Clarifies code.
2022-03-05 16:20:08 -08:00
John Ralls
250b4ed733 Remove stray line left from earlier refactoring. 2022-03-04 14:53:02 -08:00
Robert Fewell
7e299cb2b0 Remove print statement left in commit c3f8daa 2022-03-04 10:16:14 +00:00
John Ralls
8ef8d3807c Silence spurious conditional uninitialized warning in gnc-owner-sql.cpp. 2022-03-03 13:21:51 -08:00
John Ralls
93f5e23cf5 Open gzfile if thread creation fails. 2022-03-03 13:20:41 -08:00
John Ralls
81b9a02235 Bug 798458 - Build failure with gcc 12
Refactor try_gz_open to return a std::pair<FILE*, thread>. That removes
the need for the threads hash-table and wait_for_gzip().

The cause of the gcc12 error was that we were using the thread's pipe's
FILE* as the key to the hash-table and had to close it before calling
wait_for_gzip(file) to remove the thread from the hash-table. gcc12
considers that a use-after-free. It happens to be wrong, but removing the
need for it results in a cleaner implementation as well as silencing the
warning.
2022-03-01 12:49:12 -08:00
John Ralls
67e8c317da [xml backend] Extract functions to make gz_trhead_func more readable. 2022-03-01 12:49:12 -08:00
John Ralls
74d0630867 Bug 798237 - Logging during XML file loading degrades performance...
significantly

Modify the DEBUG and PINFO macros to return unless qof_log_check is
true. Replace almost all direct calls to g_debug and g_message with
DEBUG and PINFO respectively.

Track the highest logging level sent to qof_log_set_level to provide a
short-circuit return in qof_log_check. Remove setting GNC_MOD_TESTS to
QOF_LOG_DEBUG so that the short-circuit threshold isn't defeated by
always being DEBUG.

Net result: 33% improvement in xml load times.
2021-09-14 15:15:11 -07:00
John Ralls
574f567b62 Refactor GncXmlBackend::get_file_lock.
Moving all of the error-handling to it for better clarity and
simplicity. Drop the unnecessary stat call, open will fail with
EEXIST if there's already a lock file. Provide specific messages
for file system failures.
2021-09-14 09:32:12 -07:00
John Ralls
d7eae0664f [gz_open] Use compress and write consistent with calling functions. 2021-09-14 08:29:11 -07:00
John Ralls
c3f8daaf7d Bug 798250 - Gnucash permanent hang on save while loading report
Prevent WebKit's fork from getting a copy of the pipe's file descriptors
and so keeping the pipe from closing.

Thanks to Simon Arlott for recognizing the FD duplication.
2021-09-13 13:18:10 -07:00
John Ralls
901fea158f Merge Simon Arlott's 'xml-locking-fixes' into maint. 2021-09-06 15:22:49 -07:00
John Ralls
38cd06e54a Remove the lock-file-link-count test from the XML backend.
This was an effort of somewhat dubious value to detect if a process
on another ocmputer had a hsrd-link to a lockfile on an NFS share.
NFS is rarely used now and SMB doesn't support hard links so this check
adds complexity with no real value.
2021-09-06 15:18:34 -07:00
Simon Arlott
0665208299
xml-backend: Lock file is deleted even if the lock is not acquired
The lock file is set in m_lockfile and then unlinked in session_end even if
the lock was not acquired.

Clear m_lockfile if locking was not successful.
2021-08-24 09:29:47 +01:00
Simon Arlott
e4619fdae6
xml-backend: Don't try to close m_lockfd if it's not open
m_lockfd is not initialised. If the file is locked then it will not be set
before session_end and close() will be called on an uninitialised int.

Initialise it to -1 in the class definition.
Consistently use -1 instead of "< 0" or "< 1" as the definition of invalid.
Always set it to -1 after closing it.
2021-08-24 09:29:45 +01:00
Christopher Lam
c9db551693 g_free qof_print_date which returns a new char* 2021-08-05 09:23:28 +08:00
John Ralls
d099d39afd Merge Simon Arlott's 'commit-root-on-load' into maint. 2021-08-04 15:52:51 -07:00
John Ralls
fd56512cf7 Merge Simon Arlott's 'load-test-xml' into maint. 2021-08-04 15:48:42 -07:00
Christopher Lam
23bd716451 g_free gnc-path's gchar* intermediate strings 2021-08-03 12:14:12 +08:00
Simon Arlott
bf8fe1123c
Commit root accounts after loading from XML
The root accounts start with a non-zero editlevel because BeginEdit is
called for them during loading but not committed after loading.

If the book is then closed without performing any further edits that would
require a commit, the Account book_end process does nothing because the
root account is still being edited and so none of the accounts are freed.
2021-07-11 15:04:57 +01:00
Simon Arlott
f15402a9a6
Load test data from XML properly
If qof_session_new() is called without a book then qof_session_load()
won't do anything.

Set up a book for it to use.
2021-07-11 14:56:56 +01:00
Christopher Lam
e653c30193 [gnc-xml-backend] g_free char* 2021-06-22 18:57:55 +08:00
Christopher Lam
f37fa85705 build dom_tree_to_list_kvp_value more efficiently
seems to be unused however
2021-05-30 11:09:39 +08:00
Christopher Lam
59386b4081 gchar* dom_tree_to_text must be g_freed 2021-05-30 08:10:19 +08:00
Christopher Lam
c1cb29df53 GncGUIDs should be freed with guid_free instead of g_free 2021-05-17 21:00:59 +08:00
John Ralls
bbb4113a5a Bug 798156 - glib 2.68.0 breaks gnucash
Move all of the #include <glib> to before the extern "C" blocks
so that the include guards will protect against headers inside
the extern "C" block also including glib.h.
2021-04-20 11:03:23 -07:00
John Ralls
170502c6c5 Bug 797906 - GnuCash data file is locked after a "save-as"...
to mysql database.

It's more general, any save-as to a different backend type, i.e.
xml->sql or sql->xml, left the previous book locked.

Ensure that the session is ended and the book unlocked in the
backend's destructor. This also fixes a memory leak in the SQL
backend because the GncSqlConnection wasn't being deleted.
2021-03-23 11:27:37 -07:00
John Ralls
c49b45d8f1 Finish the glib 2.67 fixes for CI tests. 2021-03-22 14:02:37 -07:00
Frank H. Ellenberger
93e2829ee5 Merge PR #899 into maint 2021-03-02 01:17:26 +01:00
luz paz
16b4976381 Fix typos in libgnucash/
Found via `codespell -q 3 -L ans,ba,parm,parms,numer`
2021-03-02 01:15:32 +01:00
John Ralls
7a7c26f87e Move glib and gtk includes out of extern C for tests.
Needed to compile with glib 2.67 and later.
2021-02-16 13:23:48 -08:00