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

Bug#426745: marked as done (cdebconf-gtk-udeb: Reduce the usage of casting to struct frontend_data)



Your message dated Wed, 27 Jun 2007 21:17:02 +0000
with message-id <E1I3eso-0000WE-K5@ries.debian.org>
and subject line Bug#426745: fixed in cdebconf 0.117
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: cdebconf
Severity: wishlist
Tags: patch

Reduce the usage of casting to struct frontend_data

From: Otavio Salvador <otavio@ossystems.com.br>

Use a local variable to avoid casting when possible. This makes the
code easier to read.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---

 packages/cdebconf/src/modules/frontend/gtk/gtk.c |   25 +++++++++++-----------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/packages/cdebconf/src/modules/frontend/gtk/gtk.c b/packages/cdebconf/src/modules/frontend/gtk/gtk.c
index 59a6135..9ea2928 100644
--- a/packages/cdebconf/src/modules/frontend/gtk/gtk.c
+++ b/packages/cdebconf/src/modules/frontend/gtk/gtk.c
@@ -98,13 +98,14 @@ void register_setter(void (*func)(void*, struct question*),
              void *data, struct question *q, struct frontend *obj)
 {
     struct setter_struct *s;
+    struct frontend_data *frontend_data = obj->data;
 
     s = malloc(sizeof(struct setter_struct));
     s->func = func;
     s->data = data;
     s->q = q;
-    s->next = ((struct frontend_data*)obj->data)->setters;
-    ((struct frontend_data*)obj->data)->setters = s;
+    s->next = frontend_data->setters;
+    frontend_data->setters = s;
 }
 
 void free_description_data( GtkObject *obj, struct frontend_question_data* data )
@@ -1279,6 +1280,7 @@ void set_design_elements(struct frontend *obj, GtkWidget *window)
     GtkWidget *label_title, *h_title_box, *v_title_box, *logo_button;
     GList *focus_chain = NULL;
     int *ret_val;
+    struct frontend_data *data = obj->data;
 
     /* A logo is displayed in the upper area of the screen */
     logo_button = gtk_image_new_from_file("/usr/share/graphics/logo_debian.png");
@@ -1287,7 +1289,7 @@ void set_design_elements(struct frontend *obj, GtkWidget *window)
     /* A label is used to display the fontend's title */
     label_title = gtk_label_new(NULL);
     gtk_misc_set_alignment (GTK_MISC (label_title), 0, 0);
-    ((struct frontend_data*) obj->data)->title = label_title;
+    data->title = label_title;
     h_title_box = gtk_hbox_new (TRUE, 0);
     gtk_box_pack_start(GTK_BOX (h_title_box), label_title, TRUE, TRUE, DEFAULT_PADDING);
     v_title_box = gtk_vbox_new (TRUE, 0);
@@ -1295,7 +1297,7 @@ void set_design_elements(struct frontend *obj, GtkWidget *window)
 
     /* This is the box were question(s) will be displayed */
     targetbox = gtk_vbox_new (FALSE, 0);
-    ((struct frontend_data*) obj->data)->target_box = targetbox;
+    data->target_box = targetbox;
 
     actionbox = gtk_hbutton_box_new();
     h_actionbox = gtk_hbox_new(FALSE, 0);
@@ -1307,7 +1309,7 @@ void set_design_elements(struct frontend *obj, GtkWidget *window)
     button_screenshot = gtk_button_new_with_label (get_text(obj, "debconf/gtk-button-screenshot", "Screenshot"));
     g_signal_connect (G_OBJECT (button_screenshot), "clicked", G_CALLBACK (screenshot_button_callback), obj );
     gtk_box_pack_start (GTK_BOX(actionbox), button_screenshot, TRUE, TRUE, DEFAULT_PADDING);
-    ((struct frontend_data*) obj->data)->button_screenshot = button_screenshot;
+    data->button_screenshot = button_screenshot;
     gtk_widget_set_sensitive (button_screenshot, FALSE);
 
     /* Here are the back and forward buttons */
@@ -1328,8 +1330,8 @@ void set_design_elements(struct frontend *obj, GtkWidget *window)
     gtk_box_pack_start (GTK_BOX(actionbox), button_next, TRUE, TRUE, DEFAULT_PADDING);
     GTK_WIDGET_SET_FLAGS (button_next, GTK_CAN_DEFAULT);
 
-    ((struct frontend_data*) obj->data)->button_prev = button_prev;
-    ((struct frontend_data*) obj->data)->button_next = button_next;
+    data->button_prev = button_prev;
+    data->button_next = button_next;
     gtk_widget_set_sensitive (button_prev, FALSE);
     gtk_widget_set_sensitive (button_next, FALSE);
 
@@ -1341,7 +1343,7 @@ void set_design_elements(struct frontend *obj, GtkWidget *window)
     g_signal_connect (G_OBJECT(button_cancel), "clicked",
                       G_CALLBACK(cancel_button_callback), obj);
     gtk_box_pack_start (GTK_BOX(actionbox), button_cancel, TRUE, TRUE, DEFAULT_PADDING);
-    ((struct frontend_data*) obj->data)->button_cancel = button_cancel;
+    data->button_cancel = button_cancel;
     gtk_widget_set_sensitive (button_cancel, FALSE);
 
     /* focus order inside actionbox */
@@ -1396,7 +1398,7 @@ void *eventhandler_thread()
 
 static int gtk_initialize(struct frontend *obj, struct configuration *conf)
 {
-    struct frontend_data *fe_data;
+    struct frontend_data *fe_data = obj->data;
     GtkWidget *window;
 	GThread *thread_events_listener;
 	GError *err_events_listener = NULL ;
@@ -1408,13 +1410,12 @@ static int gtk_initialize(struct frontend *obj, struct configuration *conf)
     name[1] = NULL;
 
     /* INFO(INFO_DEBUG, "GTK_DI - gtk_initialize() called"); */
-    obj->data = NEW(struct frontend_data);
     obj->interactive = 1;
 
     /* It's recomended setting fields in frontend_data structure to NULL,
      * as otherwise older GTKDFB versions may cause segfaults.
      */
-    fe_data = obj->data;
+    fe_data = NEW(struct frontend_data);
     fe_data->window = NULL;
     fe_data->title = NULL;
     fe_data->target_box = NULL;
@@ -1447,7 +1448,7 @@ static int gtk_initialize(struct frontend *obj, struct configuration *conf)
     gtk_window_set_decorated (GTK_WINDOW (window), TRUE);
     set_design_elements (obj, window);
     gtk_rc_reparse_all();
-    ((struct frontend_data*) obj->data)->window = window;
+    fe_data->window = window;
     gtk_widget_set_default_direction(get_text_direction(obj));
     gtk_widget_show_all(window);
 

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-rc2-686 (SMP w/1 CPU core)
Locale: LANG=pt_BR.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages cdebconf depends on:
ii  libatk1.0-0                   1.18.0-2   The ATK accessibility toolkit
ii  libc6                         2.5-9      GNU C Library: Shared libraries
ii  libcairo2                     1.4.6-1.1  The Cairo 2D vector graphics libra
ii  libdebian-installer4          0.51       Library of common debian-installer
ii  libdirectfb-0.9-25            0.9.25.1-5 direct frame buffer graphics - sha
ii  libglib2.0-0                  2.12.12-1  The GLib library of C routines
pn  libgtk-directfb-2.0-0         <none>     (no description available)
ii  libgtk2.0-0                   2.10.12-2  The GTK+ graphical user interface 
ii  libnewt0.52                   0.52.2-10  Not Erik's Windowing Toolkit - tex
ii  libpango1.0-0                 1.16.4-1   Layout and rendering of internatio
pn  libtextwrap1                  <none>     (no description available)

cdebconf recommends no packages.


--- End Message ---
--- Begin Message ---
Source: cdebconf
Source-Version: 0.117

We believe that the bug you reported is fixed in the latest version of
cdebconf, which is due to be installed in the Debian FTP archive:

cdebconf-gtk-udeb_0.117_powerpc.udeb
  to pool/main/c/cdebconf/cdebconf-gtk-udeb_0.117_powerpc.udeb
cdebconf-newt-udeb_0.117_powerpc.udeb
  to pool/main/c/cdebconf/cdebconf-newt-udeb_0.117_powerpc.udeb
cdebconf-priority_0.117_all.udeb
  to pool/main/c/cdebconf/cdebconf-priority_0.117_all.udeb
cdebconf-text-udeb_0.117_powerpc.udeb
  to pool/main/c/cdebconf/cdebconf-text-udeb_0.117_powerpc.udeb
cdebconf-udeb_0.117_powerpc.udeb
  to pool/main/c/cdebconf/cdebconf-udeb_0.117_powerpc.udeb
cdebconf_0.117.dsc
  to pool/main/c/cdebconf/cdebconf_0.117.dsc
cdebconf_0.117.tar.gz
  to pool/main/c/cdebconf/cdebconf_0.117.tar.gz
cdebconf_0.117_powerpc.deb
  to pool/main/c/cdebconf/cdebconf_0.117_powerpc.deb
libdebconfclient0-dev_0.117_powerpc.deb
  to pool/main/c/cdebconf/libdebconfclient0-dev_0.117_powerpc.deb
libdebconfclient0-udeb_0.117_powerpc.udeb
  to pool/main/c/cdebconf/libdebconfclient0-udeb_0.117_powerpc.udeb
libdebconfclient0_0.117_powerpc.deb
  to pool/main/c/cdebconf/libdebconfclient0_0.117_powerpc.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 426745@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Colin Watson <cjwatson@debian.org> (supplier of updated cdebconf package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Wed, 27 Jun 2007 20:44:38 +0100
Source: cdebconf
Binary: cdebconf-slang-udeb libdebconfclient0 cdebconf-priority cdebconf libdebconfclient0-dev cdebconf-udeb libdebconfclient0-udeb cdebconf-gtk-udeb cdebconf-text-udeb cdebconf-newt-udeb
Architecture: source powerpc all
Version: 0.117
Distribution: unstable
Urgency: low
Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
Changed-By: Colin Watson <cjwatson@debian.org>
Description: 
 cdebconf   - Debian Configuration Management System (C-implementation)
 cdebconf-gtk-udeb - Gtk+ frontend for Debian Configuration Management System (udeb)
 cdebconf-newt-udeb - Newt frontend for Debian Configuration Management System (udeb)
 cdebconf-priority - Change debconf priority (udeb)
 cdebconf-text-udeb - Plain text frontend for Debian Configuration Management System (udeb)
 cdebconf-udeb - Debian Configuration Management System (C-implementation) (udeb)
 libdebconfclient0 - Debian Configuration Management System (C-implementation)
 libdebconfclient0-dev - Development files for cdebconf
 libdebconfclient0-udeb - Debian Configuration Management System (C-implementation) (udeb)
Closes: 329743 426745 427657 430108
Changes: 
 cdebconf (0.117) unstable; urgency=low
 .
   [ Attilio Fiandrotti ]
   * gtk.c: remove some compatibility conditions that are no longer needed.
     Closes: #427657.
   * Removed workaround for #404482, fixed upstream in gtk+ release 2.10.13.
 .
   [ Otavio Salvador ]
   * Reduce the usage of casting to struct frontend_data on GTK frontend
     code. Closes: #426745.
 .
   [ Colin Watson ]
   * Remove five function pointers in every struct template that always
     pointed to the same functions (or were entirely unused, in the cases of
     get and set); export those functions from template.c instead.
   * Fix off-by-one error reading from confmodule (thanks, Baruch Even;
     closes: #430108).
   * Document proposed PROGRESS REGION command.
   * Fix a bunch of reference-counting bugs and other memory leaks.
   * If DEBCONF_DROP_TRANSLATIONS is set to 1, then don't read translations
     we aren't going to use, and reload the templates database if the
     language is changed since we might not have the correct translations in
     memory any more. This saves around 20MB of memory at d-i run-time
     (closes: #329743). Note that this means that after the templates
     database is first saved (in practice, after anna has run), it will no
     longer be possible to change the language and get translated messages.
Files: 
 1feba30de31a9d1bfdd954adc20d9a37 1178 utils optional cdebconf_0.117.dsc
 aab8da6067d12af9f5154c00e84f0e52 239271 utils optional cdebconf_0.117.tar.gz
 a264f24aefb2b0056d86a13554fd6412 2688 debian-installer standard cdebconf-priority_0.117_all.udeb
 56a1906f39deb5c45ff018d94d7a3504 174080 utils extra cdebconf_0.117_powerpc.deb
 cb99a4f2d3a8e67f50b644d7a25216e5 35878 libs optional libdebconfclient0_0.117_powerpc.deb
 e206338b2622accf27670f96a55ced53 34666 libdevel optional libdebconfclient0-dev_0.117_powerpc.deb
 2ee9bfddedffc01c5eb5a1b08612445e 84038 debian-installer standard cdebconf-udeb_0.117_powerpc.udeb
 9205521d050ec76f9362d51c1ec2a620 5492 debian-installer optional libdebconfclient0-udeb_0.117_powerpc.udeb
 fa8db2581a4d2fb7d0094eacb6bfbb6e 19072 debian-installer optional cdebconf-newt-udeb_0.117_powerpc.udeb
 1764a73f9e652a9d7fe60d33914d629b 20746 debian-installer optional cdebconf-text-udeb_0.117_powerpc.udeb
 bac9334c888c3880ba3c7eb3e7d604fa 24958 debian-installer optional cdebconf-gtk-udeb_0.117_powerpc.udeb
Package-Type: udeb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGgtAc9t0zAhD6TNERAtFlAJ0dEqBjHdWX/nm69PGR75cCBosmsACfXXAu
YVrwFhJT0vNNZConaNLCGqI=
=KMzS
-----END PGP SIGNATURE-----


--- End Message ---

Reply to: