Skip to content

Commit

Permalink
Remove some unused variables - and the initialization
Browse files Browse the repository at this point in the history
- checked that any side effects were irrelevant
  • Loading branch information
richardcohen committed Feb 6, 2023
1 parent c819b03 commit 78ec205
Show file tree
Hide file tree
Showing 21 changed files with 14 additions and 61 deletions.
12 changes: 0 additions & 12 deletions bindings/guile/gnc-optiondb.i
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,6 @@ scm_to_value<const QofInstance*>(SCM new_value)
if (new_value == SCM_BOOL_F)
return nullptr;

auto info = SWIG_PointerType(new_value);

static const std::array<swig_type_info*, 10> types{
SWIGTYPE_p_QofInstance_s, SWIGTYPE_p_gnc_commodity,
SWIGTYPE_p_budget_s, SWIGTYPE_p__gncInvoice,
Expand Down Expand Up @@ -468,7 +466,6 @@ scm_to_value<GncOptionAccountList>(SCM new_value)
GncOptionAccountList retval{};
if (scm_is_false(scm_list_p(new_value)) || scm_is_null(new_value))
return retval;
auto book{get_current_book()};
auto next{new_value};
while (!scm_is_null(next) && scm_car(next))
{
Expand Down Expand Up @@ -524,7 +521,6 @@ void gnc_option_test_book_destroy(QofBook*);
QofBook*
gnc_option_test_book_new()
{
auto session = gnc_get_current_session();
return get_current_book();
}

Expand Down Expand Up @@ -896,11 +892,6 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
assert(reldate_index >= static_cast<int>(RelativeDatePeriod::ABSOLUTE) && reldate_index < static_cast<int>(relative_date_periods - 1));
return static_cast<RelativeDatePeriod>(reldate_index);
}
const char* reldate_str;
if (scm_is_symbol(reldate_scm))
reldate_str = scm_to_utf8_string(scm_symbol_to_string(reldate_scm));
else
reldate_str = scm_to_utf8_string(reldate_scm);

auto date_iter =
std::find_if(reldate_values.begin(), reldate_values.end(),
Expand All @@ -925,7 +916,6 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
if (scm_is_symbol(scm_car(date)))
{
auto car{scm_to_utf8_string(scm_symbol_to_string(scm_car(date)))};
auto cdr{scm_cdr(date)};
if (strcmp(car, "relative") == 0)
return false;
if (strcmp(car, "absolute") == 0)
Expand Down Expand Up @@ -1212,7 +1202,6 @@ inline SCM return_scm_value(ValueType value)
}
if constexpr (is_QofInstanceValue_v<decltype(option)>)
{
auto uitype{$self->get_ui_type()};
auto serial{option.serialize()};
if (serial.empty())
return no_value;
Expand Down Expand Up @@ -1769,7 +1758,6 @@ gnc_register_multichoice_callback_option(GncOptionDBPtr& db,
value)}};
return retval;
}
auto value{scm_relative_date_get_period(default_val)};
auto retval{new GncOption{GncOptionDateValue(section, name, key,
doc_string, ui_type,
period_set)}};
Expand Down
1 change: 0 additions & 1 deletion gnucash/gnome-utils/dialog-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ GncOptionsDialog::build_contents(GncOptionDB *odb, bool show_dialog)

m_option_db = odb;

auto num_sections = odb->num_sections();
auto default_section = odb->get_default_section();

PINFO("Default Section name is %s",
Expand Down
1 change: 0 additions & 1 deletion gnucash/gnome-utils/gnc-amount-edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ static void
gnc_amount_edit_class_init (GNCAmountEditClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);

object_class->dispose = gnc_amount_edit_dispose;
object_class->finalize = gnc_amount_edit_finalize;
Expand Down
1 change: 0 additions & 1 deletion gnucash/gnome-utils/gnc-cell-renderer-text-flag.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ static void
gnc_cell_renderer_text_flag_init(GncCellRendererTextFlag *celltext)
{
GncCellRendererTextFlagPrivate *priv;
GtkCellRendererText *cell = GTK_CELL_RENDERER_TEXT(celltext);

celltext->priv =
gnc_cell_renderer_text_flag_get_instance_private(celltext);
Expand Down
1 change: 0 additions & 1 deletion gnucash/gnome-utils/gnc-cell-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ static void
gnc_cell_view_class_init (GncCellViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);

gobject_class->dispose = gnc_cell_view_dispose;

Expand Down
2 changes: 0 additions & 2 deletions gnucash/gnome-utils/gnc-main-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3980,7 +3980,6 @@ gnc_main_window_edit_menu_hide_cb (GtkWidget *menu,
static void
gnc_main_window_init_menu_updaters (GncMainWindow *window)
{
GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
GtkWidget *edit_menu_item, *edit_menu;

edit_menu_item = gnc_main_window_menu_find_menu_item (window, "EditAction");
Expand Down Expand Up @@ -4310,7 +4309,6 @@ gnc_quartz_set_menu (GncMainWindow* window)
static gboolean
gnc_main_window_show_summarybar (GncMainWindow *window, GAction *action)
{
GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
GVariant *state;
gboolean visible;

Expand Down
2 changes: 0 additions & 2 deletions gnucash/gnome/assistant-hierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ region_combo_changed_cb (GtkComboBox *widget, hierarchy_data *data)
if (gtk_combo_box_get_active_iter (widget, &filter_iter))
{
GtkListStore *cat_list = GTK_LIST_STORE(gtk_tree_view_get_model (data->categories_tree));
GtkTreeModel *cat_model = gtk_tree_view_get_model (data->categories_tree);
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(data->categories_tree));
GSList *list;
GtkTreePath *path;
Expand Down Expand Up @@ -394,7 +393,6 @@ region_combo_change_filter_cb (GtkComboBox *widget, hierarchy_data *data)
{
GtkTreeModel *sort_model = gtk_combo_box_get_model (GTK_COMBO_BOX(data->language_combo));
GtkTreeModel *language_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT(sort_model));
GtkListStore *cat_list = GTK_LIST_STORE(gtk_tree_view_get_model (data->categories_tree));
GtkTreeIter *iter = nullptr;
gchar *language = nullptr;
gint count = 0;
Expand Down
1 change: 0 additions & 1 deletion gnucash/gnome/dialog-price-edit-db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data)
{
time64 last;
GDate fiscal_end_date = get_fiscal_end_date ();
PriceRemoveSourceFlags source = PRICE_REMOVE_SOURCE_FQ;
PriceRemoveKeepOptions keep = PRICE_REMOVE_KEEP_NONE;

// disconnect the model to the price treeview
Expand Down
1 change: 0 additions & 1 deletion gnucash/gnome/gnc-plugin-page-budget.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,6 @@ gnc_plugin_page_budget_cmd_edit_tax_options (GSimpleAction *simple,
if (gtk_tree_selection_count_selected_rows (selection) == 1)
{
GList *acc_list = gnc_budget_view_get_selected_accounts (priv->budget_view);
GList *node = g_list_first (acc_list);
account = acc_list->data;
g_list_free (acc_list);
}
Expand Down
4 changes: 0 additions & 4 deletions gnucash/gnome/gnc-plugin-page-sx-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ static void
treeview_popup (GtkTreeView *treeview, GdkEvent *event, GncPluginPageSxList *page)
{
GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE (page);
GtkTreeView *tree_view = GTK_TREE_VIEW (priv->tree_view);
GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);
gint count_selection = gtk_tree_selection_count_selected_rows (selection);
GtkWidget *menu, *menuitem;
gchar *full_action_name;
const gchar *group_name = gnc_plugin_page_get_simple_action_group_name (GNC_PLUGIN_PAGE(page));
Expand Down Expand Up @@ -428,7 +425,6 @@ treeview_button_press (GtkTreeView *treeview, GdkEvent *event,
{
GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE (page);
GtkTreeView *tree_view = GTK_TREE_VIEW (priv->tree_view);
GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);

if (event->type == GDK_BUTTON_PRESS)
{
Expand Down
5 changes: 1 addition & 4 deletions gnucash/html/gnc-html-webkit2.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
#include "gnc-html-webkit.h"
#include "gnc-html-history.h"
#include "print-session.h"
#include "gnc-state.h"
#include "print-session.h"


G_DEFINE_TYPE(GncHtmlWebkit, gnc_html_webkit, GNC_TYPE_HTML )
Expand Down Expand Up @@ -1127,8 +1125,7 @@ impl_webkit_print (GncHtml* self,const gchar* jobname)
gchar *export_dirname = NULL;
gchar *export_filename = NULL;
gchar* basename = NULL;
GKeyFile *state_file = gnc_state_get_current();


g_return_if_fail (self != NULL);
g_return_if_fail (GNC_IS_HTML_WEBKIT (self));
priv = GNC_HTML_WEBKIT_GET_PRIVATE (self);
Expand Down
2 changes: 0 additions & 2 deletions gnucash/import-export/test/gtest-import-account-matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class ImportMatcherTest : public ::testing::Test
};
auto assets = create_account(m_root, ACCT_TYPE_ASSET,
"Assets", nullptr);
auto liabilities = create_account(m_root, ACCT_TYPE_LIABILITY,
"Liabilities", nullptr);
auto expenses = create_account(m_root, ACCT_TYPE_EXPENSE,
"Expenses", nullptr);
create_account(assets, ACCT_TYPE_BANK, "Bank", "Bank");
Expand Down
2 changes: 0 additions & 2 deletions libgnucash/app-utils/test/gtest-gnc-quotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ TEST_F(GncQuotesTest, no_currency)
StrVec err_vec;
auto commtable{gnc_commodity_table_get_table(m_book)};
auto hpe{gnc_commodity_table_lookup(commtable, "NYSE", "HPE")};
auto usd{gnc_commodity_table_lookup(commtable, "ISO4217", "USD")};
GncQuotesImpl quotes(m_book, std::make_unique<GncMockQuoteSource>(std::move(quote_vec), std::move(err_vec)));
quotes.fetch(hpe);
auto failures{quotes.failures()};
Expand All @@ -331,7 +330,6 @@ TEST_F(GncQuotesTest, bad_currency)
StrVec err_vec;
auto commtable{gnc_commodity_table_get_table(m_book)};
auto hpe{gnc_commodity_table_lookup(commtable, "NYSE", "HPE")};
auto usd{gnc_commodity_table_lookup(commtable, "ISO4217", "USD")};
GncQuotesImpl quotes(m_book, std::make_unique<GncMockQuoteSource>(std::move(quote_vec), std::move(err_vec)));
quotes.fetch(hpe);
auto failures{quotes.failures()};
Expand Down
2 changes: 0 additions & 2 deletions libgnucash/backend/sql/gnc-sql-column-table-entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,6 @@ gnc_sql_load_object (const GncSqlBackend* sql_be, GncSqlRow& row,
QofIdTypeConst obj_name, gpointer pObject,
const EntryVec& table)
{
QofSetterFunc setter;

g_return_if_fail (sql_be != NULL);
g_return_if_fail (pObject != NULL);

Expand Down
1 change: 0 additions & 1 deletion libgnucash/engine/Scrub.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ get_trading_split (Transaction *trans, Account *base,
Account *ns_account;
Account *account;
Account* root = gnc_book_get_root_account (xaccTransGetBook (trans));
gnc_commodity *root_currency = find_root_currency ();

trading_account = xaccScrubUtilityGetOrMakeAccount (root,
NULL,
Expand Down
1 change: 0 additions & 1 deletion libgnucash/engine/gnc-option-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ GncOptionAccountListValue::get_default_value() const
if (!account_list)
return retval;

auto book{get_current_book()};
for (auto node = account_list; node; node = g_list_next (node))
{
if (std::find(m_allowed.begin(), m_allowed.end(),
Expand Down
2 changes: 0 additions & 2 deletions libgnucash/engine/qofbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ enum
PROP_OPT_DEFAULT_BUDGET, /* KVP */
PROP_OPT_FY_END, /* KVP */
PROP_AB_TEMPLATES, /* KVP */
N_PROPERTIES /* Just a counter */
};

static void
Expand All @@ -93,7 +92,6 @@ G_DEFINE_TYPE(QofBook, qof_book, QOF_TYPE_INSTANCE)
QOF_GOBJECT_DISPOSE(qof_book);
QOF_GOBJECT_FINALIZE(qof_book);

static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
#undef G_PARAM_READWRITE
#define G_PARAM_READWRITE static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)
/* ====================================================================== */
Expand Down
29 changes: 13 additions & 16 deletions libgnucash/engine/test/gtest-gnc-int128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <gtest/gtest.h>
#include "../gnc-int128.hpp"

static constexpr uint64_t UPPER_MAX{2305843009213693951};

TEST(GncInt128_constructors, test_default_constructor)
{
GncInt128 value {};
Expand Down Expand Up @@ -194,42 +192,42 @@ TEST(GncInt128_functions, test_int_functions)
});

GncInt128 value2 (UINT64_C(0), uarg);
EXPECT_THROW (auto v = static_cast<int64_t>(value2), std::overflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<int64_t>(value2), std::overflow_error);
EXPECT_EQ (uarg, static_cast<uint64_t>(value2));

GncInt128 value3 (UINT64_C(0), uarg, GncInt128::neg);
EXPECT_THROW (auto v = static_cast<int64_t>(value3), std::underflow_error);
EXPECT_THROW (auto v = static_cast<uint64_t>(value3), std::underflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<int64_t>(value3), std::underflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<uint64_t>(value3), std::underflow_error);

GncInt128 value4 (UINT64_C(0), uarg, GncInt128::overflow);
EXPECT_THROW (auto v = static_cast<int64_t>(value4), std::overflow_error);
EXPECT_THROW (auto v = static_cast<uint64_t>(value4), std::overflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<int64_t>(value4), std::overflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<uint64_t>(value4), std::overflow_error);

GncInt128 value5 (UINT64_C(0), uarg, GncInt128::NaN);
EXPECT_THROW (auto v = static_cast<int64_t>(value5), std::overflow_error);
EXPECT_THROW (auto v = static_cast<uint64_t>(value5), std::overflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<int64_t>(value5), std::overflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<uint64_t>(value5), std::overflow_error);

GncInt128 value6 (INT64_C(1), arg);
EXPECT_THROW (auto v = static_cast<int64_t>(value6), std::overflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<int64_t>(value6), std::overflow_error);
EXPECT_EQ (arg + (UINT64_C(0x1) << 63), static_cast<uint64_t>(value6));

GncInt128 value7 (INT64_C(-1), arg);
EXPECT_EQ (-static_cast<int64_t>((UINT64_C(0x1) << 63) - arg),
static_cast<int64_t>(value7));
EXPECT_THROW (auto v = static_cast<uint64_t>(value7), std::underflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<uint64_t>(value7), std::underflow_error);

GncInt128 value8 (INT64_C(0), narg);
EXPECT_EQ (narg, static_cast<int64_t>(value8));
EXPECT_THROW (auto v = static_cast<uint64_t>(value8), std::underflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<uint64_t>(value8), std::underflow_error);

GncInt128 value9 (INT64_C(1), narg);
EXPECT_EQ (static_cast<int64_t>((UINT64_C(0x1) << 63) + narg),
static_cast<int64_t>(value9));
EXPECT_EQ ((UINT64_C(0x1) << 63) + narg, static_cast<uint64_t>(value9));

GncInt128 value10 (INT64_C(-2), arg);
EXPECT_THROW (auto v = static_cast<int64_t>(value10), std::underflow_error);
EXPECT_THROW (auto v = static_cast<uint64_t>(value10),
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<int64_t>(value10), std::underflow_error);
EXPECT_THROW (auto v GTEST_ATTRIBUTE_UNUSED_ = static_cast<uint64_t>(value10),
std::underflow_error);

}
Expand Down Expand Up @@ -563,7 +561,6 @@ TEST(GncInt128_functions, GCD)
int64_t barg {INT64_C(4878849681579065407)};
int64_t marg {INT64_C(4344522355275710400)};
int64_t sarg {INT64_C(267163663151677502)};
uint64_t uarg {UINT64_C(13567894392130486208)};

GncInt128 one (INT64_C(1));
GncInt128 smallest (sarg);
Expand Down Expand Up @@ -596,7 +593,7 @@ TEST(GncInt128_functions, pow)
EXPECT_EQ (GncInt128(1), little.pow(0));
EXPECT_EQ (GncInt128(0), GncInt128(0).pow(123));
auto really_big = big * big;
EXPECT_EQ (big * big, big.pow(2));
EXPECT_EQ (really_big, big.pow(2));
EXPECT_EQ (GncInt128(UINT64_C(66326033898754),
UINT64_C(10251549987585143605)), little.pow(7));
EXPECT_EQ (GncInt128(UINT64_C(66326033898754),
Expand Down
1 change: 0 additions & 1 deletion libgnucash/engine/test/gtest-import-map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ TEST_F(ImapBayesTest, AddAccountBayes)
TEST_F(ImapBayesTest, ConvertBayesData)
{
auto root = qof_instance_get_slots(QOF_INSTANCE(t_bank_account));
auto book = qof_instance_get_slots(QOF_INSTANCE(gnc_account_get_book(this->t_acc)));
auto acct1_guid = guid_to_string (xaccAccountGetGUID(t_expense_account1)); //Food
auto acct2_guid = guid_to_string (xaccAccountGetGUID(t_expense_account2)); //Drink
auto acct3_guid = guid_to_string (xaccAccountGetGUID(t_asset_account2)); //Asset-Bank
Expand Down
1 change: 0 additions & 1 deletion libgnucash/engine/test/gtest-qofevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ static void
compound_handler (QofInstance *ent, QofEventId event_type,
gpointer handler_data, gpointer event_data)
{
QofInstance entity;
int *data = static_cast<int*>(handler_data);
int increment = GPOINTER_TO_INT(event_data);

Expand Down
3 changes: 0 additions & 3 deletions libgnucash/engine/test/utest-Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,6 @@ static void
test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
{

QofBook *book = qof_instance_get_book (QOF_INSTANCE (fixture->txn));
QofBook *book2 = qof_book_new ();
Transaction *txn0 = fixture->txn;
Transaction *clone = xaccTransClone (txn0);
Expand Down Expand Up @@ -1248,7 +1247,6 @@ test_xaccTransGetAccountBalance (Fixture *fixture, gconstpointer pData)
#undef _func
auto loglevel = static_cast<GLogLevelFlags>(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL);
auto check = test_error_struct_new ("gnc.engine", loglevel, msg1);
auto split1 = xaccTransFindSplitByAccount(fixture->txn, fixture->acc1);
gnc_numeric rate;

fixture->hdlrs = test_log_set_fatal_handler (fixture->hdlrs, check,
Expand Down Expand Up @@ -1410,7 +1408,6 @@ test_do_destroy (GainsFixture *fixture, gconstpointer pData)
{
Fixture *base = &(fixture->base);
auto base_split = static_cast<Split*>(g_list_nth_data (base->txn->splits, 1));
QofBook *book = qof_instance_get_book (base->txn);
TestSignal sig = test_signal_new (QOF_INSTANCE (base->txn),
QOF_EVENT_DESTROY, NULL);
g_object_add_weak_pointer (G_OBJECT (base->txn->splits->data),
Expand Down

0 comments on commit 78ec205

Please sign in to comment.