On Wed, 2008-12-17 at 10:26 +0100, Gabriel Paubert wrote:

> Aprt from that, I am the only one still compiling on non-x86
> machines? 
> 
> On a machine where char are unsigned by default, there is a 
> bug with spectacular side effects (burst of error messages
> ending with segmentation fault) due to a char parameter in
> s_basic_new_object(). When the first parameter is -1, it ends
> up being converted to 255 and stored as such in the object
> structure (where the type is int).

-1 was OBJ_HEAD IIRC. And actually, it is gone in git HEAD. Try building
from the HEAD now, and see if the bug manifests anywhere else.

in any case, OBJECT's "type" member is an integer, so I agree that we
should be passing the object type as int.

Thanks for the patch. Someone should apply it (I will if I remember, but
if someone else with commit access wants to, please do - as I'll not get
to it today).

> Since char are always promoted to int when passed as argument,
> the following (tested) patch seems to be the best solution:
> 
> BTW, I did not find any option that made gcc (4.3.2, stock 
> Debian Lenny) spit a warning in that case...
> 
> 
> diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
> index 05672d6..c2dcba9 100644
> --- a/libgeda/include/prototype.h
> +++ b/libgeda/include/prototype.h
> @@ -317,7 +317,7 @@ char *s_attrib_get(int counter);
>  void error_if_called(void);
>  void exit_if_null(void *ptr);
>  OBJECT *s_basic_init_object(OBJECT *new_node, int type, char const *name);
> -OBJECT *s_basic_new_object(char type, char const *prefix);
> +OBJECT *s_basic_new_object(int type, char const *prefix);
>  void print_struct_forw(GList *list);
>  void print_struct(OBJECT *ptr);
>  void s_delete_object(TOPLEVEL *toplevel, OBJECT *o_current);
> diff --git a/libgeda/src/s_basic.c b/libgeda/src/s_basic.c
> index 86d2679..34ac573 100644
> --- a/libgeda/src/s_basic.c
> +++ b/libgeda/src/s_basic.c
> @@ -154,7 +154,7 @@ OBJECT *s_basic_init_object(OBJECT *new_node, int type, 
> char const *name)
>   *  \param [in] prefix    The name prefix for the session-unique object name.
>   *  \return A pointer to the fully constructed OBJECT.
>   */
> -OBJECT *s_basic_new_object(char type, char const *prefix)
> +OBJECT *s_basic_new_object(int type, char const *prefix)
>  {
>    return s_basic_init_object(g_malloc(sizeof (OBJECT)), type, prefix);
>  }

Best wishes,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)



_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev

Reply via email to