From: Ben Pfaff Date: Thu, 4 May 2023 14:57:46 +0000 (-0700) Subject: gui: Fix warnings from g_string_free(..., FALSE). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df9604551fcf614623efa9e4cd3b131a60d64e89;p=pspp gui: Fix warnings from g_string_free(..., FALSE). This construct now causes a warning about an unused return value, so this commit replaces it in each case with g_string_free_and_steal(), which also leads to clearer code. --- diff --git a/src/ui/gui/psppire-dialog-action-1sks.c b/src/ui/gui/psppire-dialog-action-1sks.c index f0654c6b71..13b04c6da6 100644 --- a/src/ui/gui/psppire-dialog-action-1sks.c +++ b/src/ui/gui/psppire-dialog-action-1sks.c @@ -55,7 +55,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogAction1sks *rd = PSPPIRE_DIALOG_ACTION_1SKS (act); - gchar *text; GString *string = g_string_new ("NPAR TEST"); @@ -73,11 +72,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-aggregate.c b/src/ui/gui/psppire-dialog-action-aggregate.c index a95c8c6516..bd78d4ecda 100644 --- a/src/ui/gui/psppire-dialog-action-aggregate.c +++ b/src/ui/gui/psppire-dialog-action-aggregate.c @@ -99,8 +99,6 @@ generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionAggregate *agg = PSPPIRE_DIALOG_ACTION_AGGREGATE (act); - gchar *text; - GString *string = g_string_new ("AGGREGATE OUTFILE="); append_destination_filename (agg, string); @@ -116,11 +114,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-autorecode.c b/src/ui/gui/psppire-dialog-action-autorecode.c index 2f1bdcbecb..0789272557 100644 --- a/src/ui/gui/psppire-dialog-action-autorecode.c +++ b/src/ui/gui/psppire-dialog-action-autorecode.c @@ -119,7 +119,6 @@ generate_syntax (const PsppireDialogAction *act) GHashTableIter iter; gpointer key, value; - gchar *text; GString *string = g_string_new ("AUTORECODE"); @@ -154,11 +153,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static void diff --git a/src/ui/gui/psppire-dialog-action-barchart.c b/src/ui/gui/psppire-dialog-action-barchart.c index b46ba1b7dd..576ed18a5a 100644 --- a/src/ui/gui/psppire-dialog-action-barchart.c +++ b/src/ui/gui/psppire-dialog-action-barchart.c @@ -154,7 +154,6 @@ static char * generate_syntax (const PsppireDialogAction *a) { PsppireDialogActionBarchart *rd = PSPPIRE_DIALOG_ACTION_BARCHART (a); - gchar *text; const gchar *var_name_xaxis = gtk_entry_get_text (GTK_ENTRY (rd->variable_xaxis)); const gchar *var_name_cluster = gtk_entry_get_text (GTK_ENTRY (rd->variable_cluster)); @@ -214,11 +213,7 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static void diff --git a/src/ui/gui/psppire-dialog-action-comments.c b/src/ui/gui/psppire-dialog-action-comments.c index eeb512d949..9a423c720d 100644 --- a/src/ui/gui/psppire-dialog-action-comments.c +++ b/src/ui/gui/psppire-dialog-action-comments.c @@ -42,7 +42,6 @@ generate_syntax (const PsppireDialogAction *pda) gint i; GString *str; - gchar *text; GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (cd->textview)); str = g_string_new ("\n* Data File Comments.\n\n"); @@ -82,11 +81,7 @@ generate_syntax (const PsppireDialogAction *pda) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->check))) g_string_append (str, "DISPLAY DOCUMENTS.\n"); - text = str->str; - - g_string_free (str, FALSE); - - return text; + return g_string_free_and_steal (str); } diff --git a/src/ui/gui/psppire-dialog-action-compute.c b/src/ui/gui/psppire-dialog-action-compute.c index 23c0108406..78a036d88a 100644 --- a/src/ui/gui/psppire-dialog-action-compute.c +++ b/src/ui/gui/psppire-dialog-action-compute.c @@ -38,7 +38,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionCompute *cd = PSPPIRE_DIALOG_ACTION_COMPUTE (act); - gchar *text; GString *string; const gchar *target_name ; @@ -88,11 +87,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, "EXECUTE.\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-correlation.c b/src/ui/gui/psppire-dialog-action-correlation.c index 18cba1c09a..1653def0f0 100644 --- a/src/ui/gui/psppire-dialog-action-correlation.c +++ b/src/ui/gui/psppire-dialog-action-correlation.c @@ -33,7 +33,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionCorrelation *rd = PSPPIRE_DIALOG_ACTION_CORRELATION (act); - gchar *text; GString *string = g_string_new ("CORRELATION"); g_string_append (string, "\n\t/VARIABLES = "); @@ -56,11 +55,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-crosstabs.c b/src/ui/gui/psppire-dialog-action-crosstabs.c index 3c2bd59579..6b26775d71 100644 --- a/src/ui/gui/psppire-dialog-action-crosstabs.c +++ b/src/ui/gui/psppire-dialog-action-crosstabs.c @@ -271,7 +271,6 @@ static char * generate_syntax (const PsppireDialogAction *a) { PsppireDialogActionCrosstabs *cd = PSPPIRE_DIALOG_ACTION_CROSSTABS (a); - gchar *text = NULL; int i, n; guint selected; GString *string = g_string_new ("CROSSTABS "); @@ -358,11 +357,7 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static void diff --git a/src/ui/gui/psppire-dialog-action-descriptives.c b/src/ui/gui/psppire-dialog-action-descriptives.c index a2a554a471..38f63b02f5 100644 --- a/src/ui/gui/psppire-dialog-action-descriptives.c +++ b/src/ui/gui/psppire-dialog-action-descriptives.c @@ -77,7 +77,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionDescriptives *scd = PSPPIRE_DIALOG_ACTION_DESCRIPTIVES (act); - gchar *text; GString *string; GtkTreeIter iter; unsigned int selected; @@ -149,11 +148,7 @@ generate_syntax (const PsppireDialogAction *act) if (gtk_toggle_button_get_active (scd->save_z_scores)) g_string_append (string, "\nEXECUTE."); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static gboolean diff --git a/src/ui/gui/psppire-dialog-action-examine.c b/src/ui/gui/psppire-dialog-action-examine.c index b81a2429d5..36e8505ffb 100644 --- a/src/ui/gui/psppire-dialog-action-examine.c +++ b/src/ui/gui/psppire-dialog-action-examine.c @@ -218,7 +218,6 @@ generate_syntax (const PsppireDialogAction *act) PsppireDialogActionExamine *ed = PSPPIRE_DIALOG_ACTION_EXAMINE (act); const char *label; - gchar *text = NULL; GString *str = g_string_new ("EXAMINE "); bool show_stats = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->display_stats_button)); bool show_plots = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->display_plots_button)); @@ -334,11 +333,8 @@ generate_syntax (const PsppireDialogAction *act) }; g_string_append (str, "."); - text = str->str; - g_string_free (str, FALSE); - - return text; + return g_string_free_and_steal (str); } static gboolean diff --git a/src/ui/gui/psppire-dialog-action-flip.c b/src/ui/gui/psppire-dialog-action-flip.c index 07863ec155..b5c39a9409 100644 --- a/src/ui/gui/psppire-dialog-action-flip.c +++ b/src/ui/gui/psppire-dialog-action-flip.c @@ -40,7 +40,6 @@ generate_syntax (const PsppireDialogAction *act) PsppireDialogActionFlip *rd = PSPPIRE_DIALOG_ACTION_FLIP (act); GString *string = g_string_new ("FLIP"); - gchar *syntax ; g_string_append (string, " /VARIABLES = "); @@ -53,11 +52,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - syntax = string->str; - - g_string_free (string, FALSE); - - return syntax; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-histogram.c b/src/ui/gui/psppire-dialog-action-histogram.c index f99000ac28..99b07b2846 100644 --- a/src/ui/gui/psppire-dialog-action-histogram.c +++ b/src/ui/gui/psppire-dialog-action-histogram.c @@ -89,7 +89,6 @@ static char * generate_syntax (const PsppireDialogAction *a) { PsppireDialogActionHistogram *rd = PSPPIRE_DIALOG_ACTION_HISTOGRAM (a); - gchar *text; const gchar *var_name = gtk_entry_get_text (GTK_ENTRY (rd->variable)); GString *string = g_string_new ("GRAPH /HISTOGRAM "); @@ -103,11 +102,7 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static void diff --git a/src/ui/gui/psppire-dialog-action-indep-samps.c b/src/ui/gui/psppire-dialog-action-indep-samps.c index 974c1e97f9..c52976e3ae 100644 --- a/src/ui/gui/psppire-dialog-action-indep-samps.c +++ b/src/ui/gui/psppire-dialog-action-indep-samps.c @@ -362,7 +362,6 @@ static char * generate_syntax (const PsppireDialogAction *a) { PsppireDialogActionIndepSamps *act = PSPPIRE_DIALOG_ACTION_INDEP_SAMPS (a); - gchar *text; GString *str = g_string_new ("T-TEST /VARIABLES="); @@ -415,11 +414,7 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (str, ".\n"); - text = str->str; - - g_string_free (str, FALSE); - - return text; + return g_string_free_and_steal (str); } static void diff --git a/src/ui/gui/psppire-dialog-action-k-independent.c b/src/ui/gui/psppire-dialog-action-k-independent.c index e959a09327..e3c0487b7d 100644 --- a/src/ui/gui/psppire-dialog-action-k-independent.c +++ b/src/ui/gui/psppire-dialog-action-k-independent.c @@ -48,7 +48,6 @@ static const char *keyword[n_KIDS] = static char * generate_syntax (const PsppireDialogAction *act) { - gchar *text; PsppireDialogActionKIndependent *kid = PSPPIRE_DIALOG_ACTION_K_INDEPENDENT (act); GString *string = g_string_new ("NPAR TEST"); @@ -77,11 +76,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-k-related.c b/src/ui/gui/psppire-dialog-action-k-related.c index a9ef4cbfb2..d3107d386c 100644 --- a/src/ui/gui/psppire-dialog-action-k-related.c +++ b/src/ui/gui/psppire-dialog-action-k-related.c @@ -33,7 +33,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionKRelated *krd = PSPPIRE_DIALOG_ACTION_K_RELATED (act); - gchar *text; GString *string = g_string_new ("NPAR TEST"); @@ -57,11 +56,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-kmeans.c b/src/ui/gui/psppire-dialog-action-kmeans.c index 0e22be6e05..9279890eec 100644 --- a/src/ui/gui/psppire-dialog-action-kmeans.c +++ b/src/ui/gui/psppire-dialog-action-kmeans.c @@ -34,7 +34,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionKmeans *km = PSPPIRE_DIALOG_ACTION_KMEANS (act); - gchar *text; GString *string = g_string_new ("QUICK CLUSTER "); @@ -45,11 +44,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static gboolean diff --git a/src/ui/gui/psppire-dialog-action-logistic.c b/src/ui/gui/psppire-dialog-action-logistic.c index 252bf9797a..962a0d5469 100644 --- a/src/ui/gui/psppire-dialog-action-logistic.c +++ b/src/ui/gui/psppire-dialog-action-logistic.c @@ -148,7 +148,6 @@ static char * generate_syntax (const PsppireDialogAction *a) { PsppireDialogActionLogistic *rd = PSPPIRE_DIALOG_ACTION_LOGISTIC (a); - gchar *text = NULL; const gchar *dep = gtk_entry_get_text (GTK_ENTRY (rd->dep_var)); @@ -211,11 +210,7 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (strx, ".\n"); - text = strx->str; - - g_string_free (strx, FALSE); - - return text; + return g_string_free_and_steal (strx); } static void diff --git a/src/ui/gui/psppire-dialog-action-means.c b/src/ui/gui/psppire-dialog-action-means.c index c9b7eb8f65..c37d978a4a 100644 --- a/src/ui/gui/psppire-dialog-action-means.c +++ b/src/ui/gui/psppire-dialog-action-means.c @@ -40,7 +40,6 @@ generate_syntax (const PsppireDialogAction *act) { gint l; PsppireDialogActionMeans *scd = PSPPIRE_DIALOG_ACTION_MEANS (act); - gchar *text; GString *string = g_string_new ("MEANS TABLES = "); PsppireMeansLayer *layer = PSPPIRE_MEANS_LAYER (scd->layer); psppire_var_view_append_names (PSPPIRE_VAR_VIEW (scd->variables), 0, string); @@ -62,11 +61,8 @@ generate_syntax (const PsppireDialogAction *act) } g_string_append (string, ".\n"); - text = string->str; - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static gboolean diff --git a/src/ui/gui/psppire-dialog-action-paired.c b/src/ui/gui/psppire-dialog-action-paired.c index 4d2fbb3aee..f7b33dfb21 100644 --- a/src/ui/gui/psppire-dialog-action-paired.c +++ b/src/ui/gui/psppire-dialog-action-paired.c @@ -127,7 +127,6 @@ static gchar * generate_syntax (const PsppireDialogAction *pda) { PsppireDialogActionPaired *d = PSPPIRE_DIALOG_ACTION_PAIRED (pda); - gchar *text = NULL; GString *str = g_string_new ("T-TEST \n\tPAIRS = "); psppire_var_view_append_names (PSPPIRE_VAR_VIEW (d->pairs_treeview), 0, str); @@ -143,10 +142,7 @@ generate_syntax (const PsppireDialogAction *pda) g_string_append (str, ".\n"); - text = str->str; - g_string_free (str, FALSE); - - return text; + return g_string_free_and_steal (str); } static GtkBuilder * diff --git a/src/ui/gui/psppire-dialog-action-rank.c b/src/ui/gui/psppire-dialog-action-rank.c index c0454d10f3..dcb045a3ef 100644 --- a/src/ui/gui/psppire-dialog-action-rank.c +++ b/src/ui/gui/psppire-dialog-action-rank.c @@ -40,7 +40,6 @@ generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionRank *rd = PSPPIRE_DIALOG_ACTION_RANK (act); - gchar *text = NULL; GtkTreeModel *gs = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->group_vars)); GtkTreeIter notused; @@ -116,11 +115,8 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (str, "."); - text = str->str; - g_string_free (str, FALSE); - - return text; + return g_string_free_and_steal (str); } static gboolean diff --git a/src/ui/gui/psppire-dialog-action-regression.c b/src/ui/gui/psppire-dialog-action-regression.c index c3f2234c1c..7c16cbfade 100644 --- a/src/ui/gui/psppire-dialog-action-regression.c +++ b/src/ui/gui/psppire-dialog-action-regression.c @@ -189,7 +189,6 @@ static char * generate_syntax (const PsppireDialogAction *a) { PsppireDialogActionRegression *rd = PSPPIRE_DIALOG_ACTION_REGRESSION (a); - gchar *text = NULL; guint selected; GtkTreeIter iter; @@ -241,11 +240,7 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static void diff --git a/src/ui/gui/psppire-dialog-action-reliability.c b/src/ui/gui/psppire-dialog-action-reliability.c index 4bb78f9e1e..e3570c8849 100644 --- a/src/ui/gui/psppire-dialog-action-reliability.c +++ b/src/ui/gui/psppire-dialog-action-reliability.c @@ -39,7 +39,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionReliability *rd = PSPPIRE_DIALOG_ACTION_RELIABILITY (act); - gchar *text; GString *string = g_string_new ("RELIABILITY"); g_string_append (string, "\n\t/VARIABLES="); @@ -60,11 +59,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-roc.c b/src/ui/gui/psppire-dialog-action-roc.c index 2a8deedd53..2d19459656 100644 --- a/src/ui/gui/psppire-dialog-action-roc.c +++ b/src/ui/gui/psppire-dialog-action-roc.c @@ -159,7 +159,6 @@ static char * generate_syntax (const PsppireDialogAction *a) { PsppireDialogActionRoc *rd = PSPPIRE_DIALOG_ACTION_ROC (a); - gchar *text; const gchar *var_name = gtk_entry_get_text (GTK_ENTRY (rd->state_variable)); GString *string = g_string_new ("ROC"); @@ -225,11 +224,7 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (string, ".\n"); - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static void diff --git a/src/ui/gui/psppire-dialog-action-runs.c b/src/ui/gui/psppire-dialog-action-runs.c index 3a073e227b..0d06c89f31 100644 --- a/src/ui/gui/psppire-dialog-action-runs.c +++ b/src/ui/gui/psppire-dialog-action-runs.c @@ -54,7 +54,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionRuns *rd = PSPPIRE_DIALOG_ACTION_RUNS (act); - gchar *str; GString *string = g_string_new ("NPAR TEST"); @@ -75,11 +74,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, ".\n"); - str = string->str; - - g_string_free (string, FALSE); - - return str; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-sort.c b/src/ui/gui/psppire-dialog-action-sort.c index 7dfb0b278c..b34322614d 100644 --- a/src/ui/gui/psppire-dialog-action-sort.c +++ b/src/ui/gui/psppire-dialog-action-sort.c @@ -33,7 +33,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionSort *scd = PSPPIRE_DIALOG_ACTION_SORT (act); - gchar *text; GString *string = g_string_new ("SORT CASES BY "); PsppireVarView *var_view = PSPPIRE_VAR_VIEW (scd->variables); @@ -52,11 +51,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, "."); } - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } static void diff --git a/src/ui/gui/psppire-dialog-action-split.c b/src/ui/gui/psppire-dialog-action-split.c index 65a322c14c..634e27a7e1 100644 --- a/src/ui/gui/psppire-dialog-action-split.c +++ b/src/ui/gui/psppire-dialog-action-split.c @@ -39,7 +39,6 @@ static char * generate_syntax (const PsppireDialogAction *pda) { PsppireDialogActionSplit *act = PSPPIRE_DIALOG_ACTION_SPLIT (pda); - gchar *text; GString *string = g_string_new ("SPLIT FILE OFF."); @@ -73,11 +72,7 @@ generate_syntax (const PsppireDialogAction *pda) g_string_free (varlist, TRUE); } - text = string->str; - - g_string_free (string, FALSE); - - return text; + return g_string_free_and_steal (string); } diff --git a/src/ui/gui/psppire-dialog-action-tt1s.c b/src/ui/gui/psppire-dialog-action-tt1s.c index 5dd36a65dc..1937a75f0c 100644 --- a/src/ui/gui/psppire-dialog-action-tt1s.c +++ b/src/ui/gui/psppire-dialog-action-tt1s.c @@ -35,7 +35,6 @@ static char * generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionTt1s *d = PSPPIRE_DIALOG_ACTION_TT1S (act); - gchar *text; GString *str = g_string_new ("T-TEST "); @@ -50,11 +49,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (str, ".\n"); - text = str->str; - - g_string_free (str, FALSE); - - return text; + return g_string_free_and_steal (str); } diff --git a/src/ui/gui/psppire-dialog-action-two-sample.c b/src/ui/gui/psppire-dialog-action-two-sample.c index 0a2908f944..7d8c0916ef 100644 --- a/src/ui/gui/psppire-dialog-action-two-sample.c +++ b/src/ui/gui/psppire-dialog-action-two-sample.c @@ -139,7 +139,6 @@ generate_syntax (const PsppireDialogAction *pda) gint i; PsppireDialogActionTwoSample *d = PSPPIRE_DIALOG_ACTION_TWO_SAMPLE (pda); - gchar *text = NULL; GString *str = g_string_new ("NPAR TEST"); @@ -162,10 +161,7 @@ generate_syntax (const PsppireDialogAction *pda) g_string_append (str, ".\n"); - text = str->str; - g_string_free (str, FALSE); - - return text; + return g_string_free_and_steal (str); } static GtkBuilder * diff --git a/src/ui/gui/psppire-dialog-action-univariate.c b/src/ui/gui/psppire-dialog-action-univariate.c index 3d81c7a140..6d6c310a62 100644 --- a/src/ui/gui/psppire-dialog-action-univariate.c +++ b/src/ui/gui/psppire-dialog-action-univariate.c @@ -34,7 +34,6 @@ generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionUnivariate *uvd = PSPPIRE_DIALOG_ACTION_UNIVARIATE (act); - gchar *text = NULL; GString *str = g_string_new ("GLM "); g_string_append (str, gtk_entry_get_text (GTK_ENTRY (uvd->dep_entry))); @@ -45,11 +44,7 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (str, ".\n"); - text = str->str; - - g_string_free (str, FALSE); - - return text; + return g_string_free_and_steal (str); } diff --git a/src/ui/gui/psppire-dialog-action-var-info.c b/src/ui/gui/psppire-dialog-action-var-info.c index 570ce4ada6..b4ee58125c 100644 --- a/src/ui/gui/psppire-dialog-action-var-info.c +++ b/src/ui/gui/psppire-dialog-action-var-info.c @@ -62,7 +62,6 @@ generate_syntax__ (const PsppireDialogAction *act, const char *prefix) size_t n_vars; size_t line_len; GString *s; - char *str; size_t i; psppire_dict_view_get_selected_variables (PSPPIRE_DICT_VIEW (act->source), @@ -95,9 +94,7 @@ generate_syntax__ (const PsppireDialogAction *act, const char *prefix) g_free (vars); - str = s->str; - g_string_free (s, FALSE); - return str; + return g_string_free_and_steal (s); } static gchar * diff --git a/src/ui/gui/var-display.c b/src/ui/gui/var-display.c index 951d62c0a8..86a58da702 100644 --- a/src/ui/gui/var-display.c +++ b/src/ui/gui/var-display.c @@ -42,10 +42,9 @@ missing_values_to_string (const struct variable *pv, GError **err) return xstrdup (gettext (none)); else { - gchar *s = NULL; + GString *gstr = g_string_sized_new (10); if (! mv_has_range (miss)) { - GString *gstr = g_string_sized_new (10); const int n = mv_n_values (miss); gchar *mv[4] = {0,0,0,0}; gint i; @@ -57,12 +56,9 @@ missing_values_to_string (const struct variable *pv, GError **err) g_string_append (gstr, mv[i]); g_free (mv[i]); } - s = gstr->str; - g_string_free (gstr, FALSE); } else { - GString *gstr = g_string_sized_new (10); gchar *l, *h; union value low, high; mv_get_range (miss, &low.f, &high.f); @@ -84,10 +80,8 @@ missing_values_to_string (const struct variable *pv, GError **err) g_string_append (gstr, ss); free (ss); } - s = gstr->str; - g_string_free (gstr, FALSE); } - return s; + return g_string_free_and_steal (gstr); } } diff --git a/src/ui/gui/widget-io.c b/src/ui/gui/widget-io.c index 589eac36eb..bd28597c11 100644 --- a/src/ui/gui/widget-io.c +++ b/src/ui/gui/widget-io.c @@ -43,7 +43,6 @@ widget_printf (const gchar *fmt, ...) char_directives d; arguments a; GString *output; - gchar *text; va_list ap; const char *s = fmt; @@ -94,7 +93,5 @@ widget_printf (const gchar *fmt, ...) if (*s) g_string_append_len (output, s, -1); - text = output->str; - g_string_free (output, FALSE); - return text; + return g_string_free_and_steal (output); }