[Evolution-hackers] Uninitialized item.type in build_items (widgets/misc/e-filter-bar.c)

2006-10-18 Thread Pavel Roskin
Hello!

item.type can be used uninitialized in function build_items() in
widgets/misc/e-filter-bar.c

item.type is only initialized if type is 0 and there is a condition
described as:

/* Add a separator if there is at least one custom rule.  */

What's even more worrying is that item.type is not changed before
subsequent calls to g_array_append_vals(), whereas item.id and item.text
are changed.

Possible values of item.type are:

enum _ESearchBarItemType {
ESB_ITEMTYPE_NORMAL,
ESB_ITEMTYPE_CHECK,
ESB_ITEMTYPE_RADIO,
};

ESB_ITEMTYPE_NORMAL and ESB_ITEMTYPE_CHECK are only referenced in a
switch statement in set_option() in widgets/misc/e-search-bar.c - they
are never assigned to anything.

However, item.type is set to ESB_ITEMTYPE_NORMAL implicitly in
build_items (0 is used instead of the symbolic constant).

set_option() has a catch-all default for item types other than those in
the enum.  That would work (with some luck!) for those uninitialized
values of item.type from build_items():

default:
   /* Fixme : this should be a normal item */
   item = gtk_radio_menu_item_new_with_label (group, str);
   group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (item));
   break;

This issue was found by Valgrind, not by a compiler.  I could
misunderstand the logic, but Valgrind actually finds uninitialized data
being used.  I believe it's a serious problem that needs attention from
Evolution hackers.

-- 
Regards,
Pavel Roskin

___
Evolution-hackers mailing list
Evolution-hackers@gnome.org
http://mail.gnome.org/mailman/listinfo/evolution-hackers


Re: [Evolution-hackers] [PATCH 1/3] Provide declaration for get_font_options()

2006-08-18 Thread Pavel Roskin
Hello!

Quoting Srinivasa Ragavan [EMAIL PROTECTED]:

 Pavel,

 Please commit this.

Thanks!  I guess you mean I can use my credentials I used for other GNOME
projects.  Unfortunately, I´ll be away until September 4th, and I´m typing this
in an internet cafe.  I´ll appreciate if somebody commits it for me.

--
Regards,
Pavel Roskin
___
Evolution-hackers mailing list
Evolution-hackers@gnome.org
http://mail.gnome.org/mailman/listinfo/evolution-hackers


Re: [Evolution-hackers] [PATCH 3/3] Add some missing includes

2006-08-15 Thread Pavel Roskin
Hello, Tor!

On Tue, 2006-08-15 at 08:50 +, Tor Lillqvist wrote:
 må 2006-08-14 klockan 19:58 -0400 skrev Pavel Roskin:
  +#include gtk/gtkeventbox.h
  +#include gtk/gtkimage.h
 
 Isn't the correct thing here to just include gtk/gtk.h and not attempt
 to hand-pick individual gtk headers?

Being quite new to all this, I'm trying to follow the existing style
rather than fix warnings and do The Right Thing at once.

It should be easy (for anyone knowing Perl, that is) to replace
gtk/gtk*.h with gtk/gtk.h across the board and then remove duplicate
headers.

-- 
Regards,
Pavel Roskin


___
Evolution-hackers mailing list
Evolution-hackers@gnome.org
http://mail.gnome.org/mailman/listinfo/evolution-hackers


[Evolution-hackers] [PATCH 2/3] Fix warning about ignored token after #endif

2006-08-14 Thread Pavel Roskin
From: Pavel Roskin [EMAIL PROTECTED]


---

 a11y/widgets/ea-expander.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/a11y/widgets/ea-expander.h b/a11y/widgets/ea-expander.h
index ab36aba..e23a77d 100644
--- a/a11y/widgets/ea-expander.h
+++ b/a11y/widgets/ea-expander.h
@@ -47,4 +47,4 @@ struct _EaExpanderClass {
 GType ea_expander_get_type (void);
 AtkObject* ea_expander_new (GtkWidget *expander);
 
-#endif /* ! _EA_EXPANDER_H */_
+#endif /* ! _EA_EXPANDER_H_ */
___
Evolution-hackers mailing list
Evolution-hackers@gnome.org
http://mail.gnome.org/mailman/listinfo/evolution-hackers


[Evolution-hackers] [RFC PATCH] Uninitialized item.type

2006-08-13 Thread Pavel Roskin
Hello!

Current Evolution from CVS have become very unstable, and I'm trying to
fix at least some breakage using Valgrind.

The first error it has found is jump depending on uninitialized variable
in e-search-bar.c on line 637:

switch (items[i].type) {

Items are created in e-filter-bar.c in function build_items().  I see
that item.type is initialized to 0 if the type argument is 0.
Otherwise, it's simply not initialized.

set_option() in the same e-filter-bar.c calls build_items() with type=1.

I also noticed that ESearchBarItemType is not used in the sources.  I
think it exists to improve readability of the sources.

Please be careful with this patch.  I have no idea what filter-bar is
and how to invoke it.

The patch initializes item.type with type not only when type is 0.  It
also uses ESearchBarItemType consistently.

--- widgets/misc/e-filter-bar.c
+++ widgets/misc/e-filter-bar.c
@@ -337,7 +337,7 @@ dup_item_no_subitems (ESearchBarItem *de
 }
 
 static GArray *
-build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, 
GPtrArray *rules)
+build_items (ESearchBar *esb, ESearchBarItem *items, ESearchBarItemType type, 
int *start, GPtrArray *rules)
 {
FilterRule *rule = NULL;
EFilterBar *efb = (EFilterBar *)esb;
@@ -368,14 +368,14 @@ build_items (ESearchBar *esb, ESearchBar

*start = id;
 
-   if (type == 0) {
+   item.type = type;
+   if (type == ESB_ITEMTYPE_NORMAL) {
source = FILTER_SOURCE_INCOMING;
 
/* Add a separator if there is at least one custom rule.  */
if (rule_context_next_rule (efb-context, rule, source) != 
NULL) {
item.id = 0;
item.text = NULL;
-   item.type = 0;
g_array_append_vals (menu, item, 1);
}
} else {
@@ -386,7 +386,7 @@ build_items (ESearchBar *esb, ESearchBar
while ((rule = rule_context_next_rule (efb-context, rule, source))) {
item.id = id++;
 
-   if (type == 0  num = 10) {
+   if (type == ESB_ITEMTYPE_NORMAL  num = 10) {
item.text = g_strdup_printf (_%d. %s, num % 10, 
rule-name);
num ++;
} else {
@@ -418,7 +418,7 @@ build_items (ESearchBar *esb, ESearchBar
}

/* always add on the advanced menu */
-   if (type == 1) {
+   if (type == ESB_ITEMTYPE_CHECK) {
ESearchBarItem sb_items[2] = { E_FILTERBAR_SEPARATOR, 
E_FILTERBAR_ADVANCED, 
   /* E_FILTERBAR_SEPARATOR, 
E_FILTERBAR_SAVE */ };
ESearchBarItem dup_items[2];
@@ -458,7 +458,7 @@ generate_menu (ESearchBar *esb, ESearchB
EFilterBar *efb = (EFilterBar *)esb;
GArray *menu;
 
-   menu = build_items (esb, items, 0, efb-menu_base, efb-menu_rules);
+   menu = build_items (esb, items, ESB_ITEMTYPE_NORMAL, efb-menu_base, 
efb-menu_rules);
((ESearchBarClass *)parent_class)-set_menu (esb, (ESearchBarItem 
*)menu-data);
free_built_items (menu);
 }
@@ -507,7 +507,7 @@ set_option (ESearchBar *esb, ESearchBarI
GArray *menu;
EFilterBar *efb = (EFilterBar *)esb;

-   menu = build_items (esb, items, 1, efb-option_base, 
efb-option_rules);
+   menu = build_items (esb, items, ESB_ITEMTYPE_CHECK, efb-option_base, 
efb-option_rules);
((ESearchBarClass *)parent_class)-set_option (esb, (ESearchBarItem 
*)menu-data);
free_built_items (menu);



-- 
Regards,
Pavel Roskin


___
Evolution-hackers mailing list
Evolution-hackers@gnome.org
http://mail.gnome.org/mailman/listinfo/evolution-hackers