This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: [PATCH]: swat warnings in wrapper.c
- To: msnyder at cygnus dot com
- Subject: Re: [PATCH]: swat warnings in wrapper.c
- From: Fernando Nasser <fnasser at cygnus dot com>
- Date: Thu, 30 Mar 2000 14:41:16 -0500
- CC: gdb-patches at sourceware dot cygnus dot com
- Organization: Red Hat , Inc. - Toronto
- References: <200003240133.RAA21744@seadog.cygnus.com>
Good catch. Looks OK to me.
Fernando
msnyder@cygnus.com wrote:
>
> This module uses a struct to pass multiple arguments between
> wrapper functions. At various times it casts pointers to ints
> and vice versa. I've modified it to use a union, so that we
> don't get warnings when pointer and int are of different size.
>
> 2000-03-23 Michael Snyder <msnyder@seadog.cygnus.com>
>
> * wrapper.[ch] (struct gdb_wrapper_arguments): change fields into
> unions, since they are all used to hold both pointers and ints
> at various times. Casting pointer to int and vice versa gives
> warnings (and is not safe) if they are not the same size.
>
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/gdb/ChangeLog,v
> retrieving revision 1.170
> diff -r1.170 ChangeLog
> 0a1,7
> > 2000-03-23 Michael Snyder <msnyder@seadog.cygnus.com>
> >
> > * wrapper.[ch] (struct gdb_wrapper_arguments): change fields into
> > unions, since they are all used to hold both pointers and ints
> > at various times. Casting pointer to int and vice versa gives
> > warnings (and is not safe) if they are not the same size.
> >
> Index: wrapper.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/wrapper.c,v
> retrieving revision 1.2
> diff -r1.2 wrapper.c
> 24c24
> < /* Use this struct used to pass arguments to wrapper routines. We assume
> ---
> > /* Use this struct to pass arguments to wrapper routines. We assume
> 30c30,35
> < char *result;
> ---
> > union wrapper_results
> > {
> > int integer;
> > void *pointer;
> > } result;
> >
> 33c38,42
> < char *args[10];
> ---
> > union wrapper_args
> > {
> > int integer;
> > void *pointer;
> > } args[10];
> 60,62c69,71
> < args.args[0] = (char *) stringptr;
> < args.args[1] = (char *) block;
> < args.args[2] = (char *) comma;
> ---
> > args.args[0].pointer = stringptr;
> > args.args[1].pointer = block;
> > args.args[2].integer = comma;
> 71c80
> < *expression = (struct expression *) args.result;
> ---
> > *expression = (struct expression *) args.result.pointer;
> 82,84c91,93
> < args->result = (char *) parse_exp_1((char **) args->args[0],
> < (struct block *) args->args[1],
> < (int) args->args[2]);
> ---
> > args->result.pointer = parse_exp_1((char **) args->args[0].pointer,
> > (struct block *) args->args[1].pointer,
> > args->args[2].integer);
> 94c103
> < args.args[0] = (char *) exp;
> ---
> > args.args[0].pointer = exp;
> 103c112
> < *value = (value_ptr) args.result;
> ---
> > *value = (value_ptr) args.result.pointer;
> 113,114c122,123
> < (args)->result =
> < (char *) evaluate_expression ((struct expression *) (args)->args[0]);
> ---
> > (args)->result.pointer =
> > (char *) evaluate_expression ((struct expression *) args->args[0].pointer);
> 124c133
> < args.args[0] = (char *) value;
> ---
> > args.args[0].pointer = value;
> 135c144
> < value_fetch_lazy ((value_ptr) (args)->args[0]);
> ---
> > value_fetch_lazy ((value_ptr) (args)->args[0].pointer);
> 147,148c156,157
> < args.args[0] = (char *) val1;
> < args.args[1] = (char *) val2;
> ---
> > args.args[0].pointer = val1;
> > args.args[1].pointer = val2;
> 157c166
> < *result = (int) args.result;
> ---
> > *result = args.result.integer;
> 168,169c177,178
> < val1 = (value_ptr) (args)->args[0];
> < val2 = (value_ptr) (args)->args[1];
> ---
> > val1 = (value_ptr) (args)->args[0].pointer;
> > val2 = (value_ptr) (args)->args[1].pointer;
> 171c180
> < (args)->result = (char *) value_equal (val1, val2);
> ---
> > (args)->result.integer = value_equal (val1, val2);
> 182c191
> < args.args[0] = (char *) val;
> ---
> > args.args[0].pointer = val;
> 191c200
> < *rval = (value_ptr) args.result;
> ---
> > *rval = (value_ptr) args.result.pointer;
> 202,203c211,212
> < val = (value_ptr) (args)->args[0];
> < (args)->result = (char *) value_ind (val);
> ---
> > val = (value_ptr) (args)->args[0].pointer;
> > (args)->result.pointer = value_ind (val);
> Index: wrapper.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/wrapper.h,v
> retrieving revision 1.2
> diff -r1.2 wrapper.h
> 22c22
> < /* Use this struct used to pass arguments to wrapper routines. */
> ---
> > /* Use this struct to pass arguments to wrapper routines. */
--
Fernando Nasser
Red Hat - Toronto E-Mail: fnasser@cygnus.com
2323 Yonge Street, Suite #300 Tel: 416-482-2661 ext. 311
Toronto, Ontario M4P 2C9 Fax: 416-482-6299