[gtk+] printing: Fix compiler warnings



commit 23032587dba46c281fffae5ddd23672cc6f6c777
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat May 30 21:19:13 2015 -0400

    printing: Fix compiler warnings
    
    Fix warnings due to -Wdeclaration-after-statement and -Wshadow.

 .../cloudprint/gtkcloudprintaccount.c              |    6 +--
 modules/printbackends/cups/gtkcupssecretsutils.c   |   19 +++----
 modules/printbackends/cups/gtkprintbackendcups.c   |   54 ++++++++------------
 3 files changed, 32 insertions(+), 47 deletions(-)
---
diff --git a/modules/printbackends/cloudprint/gtkcloudprintaccount.c 
b/modules/printbackends/cloudprint/gtkcloudprintaccount.c
index b35a130..ee65a18 100644
--- a/modules/printbackends/cloudprint/gtkcloudprintaccount.c
+++ b/modules/printbackends/cloudprint/gtkcloudprintaccount.c
@@ -490,16 +490,14 @@ gtk_cloudprint_account_printer (GtkCloudprintAccount *account,
                                gpointer user_data)
 {
   RestProxyCall *call;
+  GTask *task;
   GError *error = NULL;
 
   GTK_NOTE (PRINTING,
            g_print ("Cloud Print Backend: (%p) 'printer' REST call for "
                     "printer id %s", account, printerid));
 
-  GTask *task = g_task_new (G_OBJECT (account),
-                           cancellable,
-                           callback,
-                           user_data);
+  task = g_task_new (G_OBJECT (account), cancellable, callback, user_data);
 
   g_task_set_task_data (task,
                        g_object_ref (account),
diff --git a/modules/printbackends/cups/gtkcupssecretsutils.c 
b/modules/printbackends/cups/gtkcupssecretsutils.c
index 7c5f374..d5df4a7 100644
--- a/modules/printbackends/cups/gtkcupssecretsutils.c
+++ b/modules/printbackends/cups/gtkcupssecretsutils.c
@@ -530,13 +530,13 @@ unlock_read_alias_cb (GObject      *source_object,
                       GAsyncResult *res,
                       gpointer      user_data)
 {
-  GTask              *task;
+  GTask *task;
   SecretsServiceData *task_data;
-  GError             *error = NULL;
-  GVariant           *output,
-                     *subresult;
-  gsize               path_len = 0;
-  const gchar        *collection_path;
+  GError *error = NULL;
+  GVariant *output, *subresult;
+  gsize path_len = 0;
+  const gchar *collection_path;
+  const gchar *to_unlock[2];
 
   task = user_data;
   task_data = g_task_get_task_data (task);
@@ -561,11 +561,8 @@ unlock_read_alias_cb (GObject      *source_object,
     }
 
   collection_path = g_variant_get_string (subresult, &path_len);
-
-  const gchar * const to_unlock[] =
-  {
-    collection_path, NULL
-  };
+  to_unlock[0] = collection_path;
+  to_unlock[1] = NULL;
 
   task_data->collection_path = g_strdup (collection_path);
 
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c 
b/modules/printbackends/cups/gtkprintbackendcups.c
index be14027..05b03bc 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -4513,7 +4513,7 @@ value_is_off (const char *value)
           strcasecmp (value, "False") == 0);
 }
 
-static char *
+static const char *
 ppd_group_name (ppd_group_t *group)
 {
   return group->name;
@@ -4544,7 +4544,7 @@ available_choices (ppd_file_t     *ppd,
   installed_options = NULL;
   for (i = 0; i < ppd->num_groups; i++)
     {
-      char *name;
+      const char *name;
 
       name = ppd_group_name (&ppd->groups[i]);
       if (strcmp (name, "InstallableOptions") == 0)
@@ -4885,7 +4885,7 @@ strptr_cmp (const void *a,
 
 
 static gboolean
-string_in_table (gchar       *str,
+string_in_table (const gchar *str,
                 const gchar *table[],
                 gint         table_len)
 {
@@ -4902,23 +4902,19 @@ handle_option (GtkPrinterOptionSet *set,
               GtkPrintSettings    *settings)
 {
   GtkPrinterOption *option;
-  char *name;
+  char *option_name;
   int i;
 
   if (STRING_IN_TABLE (ppd_option->keyword, cups_option_blacklist))
     return;
 
-  name = get_ppd_option_name (ppd_option->keyword);
+  option_name = get_ppd_option_name (ppd_option->keyword);
 
   option = NULL;
   if (ppd_option->ui == PPD_UI_PICKONE)
-    {
-      option = create_pickone_option (ppd_file, ppd_option, name);
-    }
+    option = create_pickone_option (ppd_file, ppd_option, option_name);
   else if (ppd_option->ui == PPD_UI_BOOLEAN)
-    {
-      option = create_boolean_option (ppd_file, ppd_option, name);
-    }
+    option = create_boolean_option (ppd_file, ppd_option, option_name);
 #ifdef PRINT_IGNORED_OPTIONS
   else
     g_warning ("CUPS Backend: Ignoring pickmany setting %s\n", ppd_option->text);
@@ -4926,27 +4922,21 @@ handle_option (GtkPrinterOptionSet *set,
 
   if (option)
     {
-      char *name;
+      const char *name;
 
       name = ppd_group_name (toplevel_group);
-      if (STRING_IN_TABLE (name,
-                          color_group_whitelist) ||
-         STRING_IN_TABLE (ppd_option->keyword,
-                          color_option_whitelist))
+      if (STRING_IN_TABLE (name, color_group_whitelist) ||
+         STRING_IN_TABLE (ppd_option->keyword, color_option_whitelist))
        {
          option->group = g_strdup ("ColorPage");
        }
-      else if (STRING_IN_TABLE (name,
-                               image_quality_group_whitelist) ||
-              STRING_IN_TABLE (ppd_option->keyword,
-                               image_quality_option_whitelist))
+      else if (STRING_IN_TABLE (name, image_quality_group_whitelist) ||
+              STRING_IN_TABLE (ppd_option->keyword, image_quality_option_whitelist))
        {
          option->group = g_strdup ("ImageQualityPage");
        }
-      else if (STRING_IN_TABLE (name,
-                               finishing_group_whitelist) ||
-              STRING_IN_TABLE (ppd_option->keyword,
-                               finishing_option_whitelist))
+      else if (STRING_IN_TABLE (name, finishing_group_whitelist) ||
+              STRING_IN_TABLE (ppd_option->keyword, finishing_option_whitelist))
        {
          option->group = g_strdup ("FinishingPage");
        }
@@ -4970,7 +4960,7 @@ handle_option (GtkPrinterOptionSet *set,
       gtk_printer_option_set_add (set, option);
     }
 
-  g_free (name);
+  g_free (option_name);
 }
 
 static void
@@ -4981,7 +4971,7 @@ handle_group (GtkPrinterOptionSet *set,
              GtkPrintSettings    *settings)
 {
   gint i;
-  gchar *name;
+  const gchar *name;
 
   /* Ignore installable options */
   name = ppd_group_name (toplevel_group);
@@ -5351,20 +5341,20 @@ cups_printer_get_options (GtkPrinter           *printer,
   if (ppd_file)
     {
       GtkPaperSize *paper_size;
-      ppd_option_t *option;
-      const gchar  *ppd_name;
+      ppd_option_t *ppd_option;
+      const gchar *ppd_name;
 
       ppdMarkDefaults (ppd_file);
 
       paper_size = gtk_page_setup_get_paper_size (page_setup);
 
-      option = ppdFindOption (ppd_file, "PageSize");
-      if (option)
+      ppd_option = ppdFindOption (ppd_file, "PageSize");
+      if (ppd_option)
        {
          ppd_name = gtk_paper_size_get_ppd_name (paper_size);
 
          if (ppd_name)
-           strncpy (option->defchoice, ppd_name, PPD_MAX_NAME);
+           strncpy (ppd_option->defchoice, ppd_name, PPD_MAX_NAME);
          else
            {
              gchar *custom_name;
@@ -5383,7 +5373,7 @@ cups_printer_get_options (GtkPrinter           *printer,
               * 230.4x142.9"
                */
              custom_name = g_strdup_printf (_("Custom %s×%s"), width, height);
-             strncpy (option->defchoice, custom_name, PPD_MAX_NAME);
+             strncpy (ppd_option->defchoice, custom_name, PPD_MAX_NAME);
              g_free (custom_name);
            }
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]