Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC 1/8] Language independent bits
Date: Sun, 15 Jan 2012 21:08:00 -0000	[thread overview]
Message-ID: <20120115203420.GA18901@host2.jankratochvil.net> (raw)
In-Reply-To: <m3aa5o7q3k.fsf@gmail.com>

On Sun, 15 Jan 2012 19:55:27 +0100, Sergio Durigan Junior wrote:
>  static int
> -unk_lang_parser (void)
> +unk_lang_parser (struct parser_state *ps)
>  {
>    return 1;
>  }
>  
>  static void
> -unk_lang_error (char *msg)
> +unk_lang_error (struct parser_state *ps, char *msg)
>  {
>    error (_("Attempted to parse an expression with unknown language"));
>  }

Do you use `ps' in these two functions in some later patch?  Otherwise I do
not think it should be passed.  It can be always passed (sure incl. updating
callers and the callers of the callers) later when needed.


> +static void
> +initialize_expout (struct parser_state *ps, int initial_size,
> +		   const struct language_defn *lang,
> +		   struct gdbarch *gdbarch)
> +{
> +  ps->expout_size = initial_size;
> +  ps->expout_ptr = 0;
> +  ps->expout = (struct expression *)
> +    xmalloc (sizeof (struct expression)
> +    + EXP_ELEM_TO_BYTES (ps->expout_size));

That return type cast is excessive.  It had meaning for K&R C where xmalloc
returns PTR but that is no longer supported.  There should be done
s/PTR/void */ everywhere and #define PTR should be removed
and #pragma GCC poison -ed.


> +  ps->expout->language_defn = lang;
> +  ps->expout->gdbarch = gdbarch;
> +}
 [...]
> -extern struct expression *expout;
> -extern int expout_size;
> -extern int expout_ptr;
> +#define parse_gdbarch(ps) (ps->expout->gdbarch)
> +#define parse_language(ps) (ps->expout->language_defn)
->
   #define parse_gdbarch(ps) ((ps)->expout->gdbarch)
   #define parse_language(ps) ((ps)->expout->language_defn)

>  
> -#define parse_gdbarch (expout->gdbarch)
> -#define parse_language (expout->language_defn)
> +struct parser_state {

Opening { should be on a new line.


> +
> +    /* The expression related to this parser state.  */

Indentation should be by 2, not 4 spaces.

> +
> +    struct expression *expout;
> +
> +    /* The size of the expression above.  */
> +
> +    int expout_size;

Memory object size does not fit into `int', it should be `size_t'.


> +
> +    /* The number of elements already in the expression.  This is used
> +       to know where to put new elements.  */
> +
> +    int expout_ptr;

Likewise.


> +};
[...]
> +/* Reallocate the `expout' pointer inside PS so that it can accommodate
> +   at least LENELT expression elements.  This function does nothing if
> +   there is enough room for the elements.  */
> +
> +extern void increase_expout_size (struct parser_state *ps, int lenelt);

Memory object size does not fit into `int', it should be `size_t'.



Sorry this is not review/approval, just comments.


Thanks,
Jan


  reply	other threads:[~2012-01-15 20:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-15 18:51 [RFC 0/8] Beginning to remove globals from parser-defs.h Sergio Durigan Junior
2012-01-15 18:56 ` [RFC 1/8] Language independent bits Sergio Durigan Junior
2012-01-15 21:08   ` Jan Kratochvil [this message]
2012-01-15 21:17     ` Sergio Durigan Junior
2012-01-15 22:03       ` Jan Kratochvil
2012-01-16 12:32         ` Sergio Durigan Junior
2012-01-16 20:40     ` Tom Tromey
2012-01-16 19:39       ` Sergio Durigan Junior
2012-01-16 19:40         ` Jan Kratochvil
2012-01-16 20:27         ` Tom Tromey
2012-01-17 16:44     ` Doug Evans
2012-01-17 16:54       ` Jan Kratochvil
2012-01-15 19:01 ` [RFC 2/8] C language Sergio Durigan Junior
2012-01-16 19:29   ` Tom Tromey
2012-01-16 19:55     ` Sergio Durigan Junior
2012-01-18 11:38     ` Sergio Durigan Junior
2012-01-18 16:50       ` Tom Tromey
2012-01-15 19:04 ` [RFC 3/8] Ada language Sergio Durigan Junior
2012-01-15 19:05 ` [RFC 4/8] Fortran language Sergio Durigan Junior
2012-01-15 19:06 ` [RFC 5/8] Java language Sergio Durigan Junior
2012-01-15 19:07 ` [RFC 6/8] Modula-2 language Sergio Durigan Junior
2012-01-17 10:21   ` Gaius Mulley
2012-01-15 19:10 ` [RFC 7/8] Objective-C language Sergio Durigan Junior
2012-01-15 20:34 ` [RFC 8/8] Pascal language Sergio Durigan Junior
2012-01-16 19:29   ` Tom Tromey
2012-01-16 19:29 ` [RFC 0/8] Beginning to remove globals from parser-defs.h Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120115203420.GA18901@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sergiodj@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox