printing: Fix compiler warnings

Fix warnings due to -Wdeclaration-after-statement and -Wshadow.
This commit is contained in:
Matthias Clasen 2015-05-30 21:19:13 -04:00
parent fdb9a8e142
commit 23032587db
3 changed files with 32 additions and 47 deletions

View File

@ -490,16 +490,14 @@ gtk_cloudprint_account_printer (GtkCloudprintAccount *account,
gpointer user_data) gpointer user_data)
{ {
RestProxyCall *call; RestProxyCall *call;
GTask *task;
GError *error = NULL; GError *error = NULL;
GTK_NOTE (PRINTING, GTK_NOTE (PRINTING,
g_print ("Cloud Print Backend: (%p) 'printer' REST call for " g_print ("Cloud Print Backend: (%p) 'printer' REST call for "
"printer id %s", account, printerid)); "printer id %s", account, printerid));
GTask *task = g_task_new (G_OBJECT (account), task = g_task_new (G_OBJECT (account), cancellable, callback, user_data);
cancellable,
callback,
user_data);
g_task_set_task_data (task, g_task_set_task_data (task,
g_object_ref (account), g_object_ref (account),

View File

@ -530,13 +530,13 @@ unlock_read_alias_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GTask *task; GTask *task;
SecretsServiceData *task_data; SecretsServiceData *task_data;
GError *error = NULL; GError *error = NULL;
GVariant *output, GVariant *output, *subresult;
*subresult; gsize path_len = 0;
gsize path_len = 0; const gchar *collection_path;
const gchar *collection_path; const gchar *to_unlock[2];
task = user_data; task = user_data;
task_data = g_task_get_task_data (task); 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); collection_path = g_variant_get_string (subresult, &path_len);
to_unlock[0] = collection_path;
const gchar * const to_unlock[] = to_unlock[1] = NULL;
{
collection_path, NULL
};
task_data->collection_path = g_strdup (collection_path); task_data->collection_path = g_strdup (collection_path);

View File

@ -4513,7 +4513,7 @@ value_is_off (const char *value)
strcasecmp (value, "False") == 0); strcasecmp (value, "False") == 0);
} }
static char * static const char *
ppd_group_name (ppd_group_t *group) ppd_group_name (ppd_group_t *group)
{ {
return group->name; return group->name;
@ -4544,7 +4544,7 @@ available_choices (ppd_file_t *ppd,
installed_options = NULL; installed_options = NULL;
for (i = 0; i < ppd->num_groups; i++) for (i = 0; i < ppd->num_groups; i++)
{ {
char *name; const char *name;
name = ppd_group_name (&ppd->groups[i]); name = ppd_group_name (&ppd->groups[i]);
if (strcmp (name, "InstallableOptions") == 0) if (strcmp (name, "InstallableOptions") == 0)
@ -4885,7 +4885,7 @@ strptr_cmp (const void *a,
static gboolean static gboolean
string_in_table (gchar *str, string_in_table (const gchar *str,
const gchar *table[], const gchar *table[],
gint table_len) gint table_len)
{ {
@ -4902,23 +4902,19 @@ handle_option (GtkPrinterOptionSet *set,
GtkPrintSettings *settings) GtkPrintSettings *settings)
{ {
GtkPrinterOption *option; GtkPrinterOption *option;
char *name; char *option_name;
int i; int i;
if (STRING_IN_TABLE (ppd_option->keyword, cups_option_blacklist)) if (STRING_IN_TABLE (ppd_option->keyword, cups_option_blacklist))
return; return;
name = get_ppd_option_name (ppd_option->keyword); option_name = get_ppd_option_name (ppd_option->keyword);
option = NULL; option = NULL;
if (ppd_option->ui == PPD_UI_PICKONE) if (ppd_option->ui == PPD_UI_PICKONE)
{ option = create_pickone_option (ppd_file, ppd_option, option_name);
option = create_pickone_option (ppd_file, ppd_option, name);
}
else if (ppd_option->ui == PPD_UI_BOOLEAN) else if (ppd_option->ui == PPD_UI_BOOLEAN)
{ option = create_boolean_option (ppd_file, ppd_option, option_name);
option = create_boolean_option (ppd_file, ppd_option, name);
}
#ifdef PRINT_IGNORED_OPTIONS #ifdef PRINT_IGNORED_OPTIONS
else else
g_warning ("CUPS Backend: Ignoring pickmany setting %s\n", ppd_option->text); g_warning ("CUPS Backend: Ignoring pickmany setting %s\n", ppd_option->text);
@ -4926,27 +4922,21 @@ handle_option (GtkPrinterOptionSet *set,
if (option) if (option)
{ {
char *name; const char *name;
name = ppd_group_name (toplevel_group); name = ppd_group_name (toplevel_group);
if (STRING_IN_TABLE (name, if (STRING_IN_TABLE (name, color_group_whitelist) ||
color_group_whitelist) || STRING_IN_TABLE (ppd_option->keyword, color_option_whitelist))
STRING_IN_TABLE (ppd_option->keyword,
color_option_whitelist))
{ {
option->group = g_strdup ("ColorPage"); option->group = g_strdup ("ColorPage");
} }
else if (STRING_IN_TABLE (name, else if (STRING_IN_TABLE (name, image_quality_group_whitelist) ||
image_quality_group_whitelist) || STRING_IN_TABLE (ppd_option->keyword, image_quality_option_whitelist))
STRING_IN_TABLE (ppd_option->keyword,
image_quality_option_whitelist))
{ {
option->group = g_strdup ("ImageQualityPage"); option->group = g_strdup ("ImageQualityPage");
} }
else if (STRING_IN_TABLE (name, else if (STRING_IN_TABLE (name, finishing_group_whitelist) ||
finishing_group_whitelist) || STRING_IN_TABLE (ppd_option->keyword, finishing_option_whitelist))
STRING_IN_TABLE (ppd_option->keyword,
finishing_option_whitelist))
{ {
option->group = g_strdup ("FinishingPage"); option->group = g_strdup ("FinishingPage");
} }
@ -4970,7 +4960,7 @@ handle_option (GtkPrinterOptionSet *set,
gtk_printer_option_set_add (set, option); gtk_printer_option_set_add (set, option);
} }
g_free (name); g_free (option_name);
} }
static void static void
@ -4981,7 +4971,7 @@ handle_group (GtkPrinterOptionSet *set,
GtkPrintSettings *settings) GtkPrintSettings *settings)
{ {
gint i; gint i;
gchar *name; const gchar *name;
/* Ignore installable options */ /* Ignore installable options */
name = ppd_group_name (toplevel_group); name = ppd_group_name (toplevel_group);
@ -5351,20 +5341,20 @@ cups_printer_get_options (GtkPrinter *printer,
if (ppd_file) if (ppd_file)
{ {
GtkPaperSize *paper_size; GtkPaperSize *paper_size;
ppd_option_t *option; ppd_option_t *ppd_option;
const gchar *ppd_name; const gchar *ppd_name;
ppdMarkDefaults (ppd_file); ppdMarkDefaults (ppd_file);
paper_size = gtk_page_setup_get_paper_size (page_setup); paper_size = gtk_page_setup_get_paper_size (page_setup);
option = ppdFindOption (ppd_file, "PageSize"); ppd_option = ppdFindOption (ppd_file, "PageSize");
if (option) if (ppd_option)
{ {
ppd_name = gtk_paper_size_get_ppd_name (paper_size); ppd_name = gtk_paper_size_get_ppd_name (paper_size);
if (ppd_name) if (ppd_name)
strncpy (option->defchoice, ppd_name, PPD_MAX_NAME); strncpy (ppd_option->defchoice, ppd_name, PPD_MAX_NAME);
else else
{ {
gchar *custom_name; gchar *custom_name;
@ -5383,7 +5373,7 @@ cups_printer_get_options (GtkPrinter *printer,
* 230.4x142.9" * 230.4x142.9"
*/ */
custom_name = g_strdup_printf (_("Custom %s×%s"), width, height); 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); g_free (custom_name);
} }
} }