[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] MI: Improve JSON handling to be more declarative
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: [PATCH 1/2] MI: Improve JSON handling to be more declarative |
Date: |
Fri, 6 Aug 2021 18:32:27 +0430 |
Hi, Jose.
On Fri, Aug 06, 2021 at 02:31:18PM +0200, Jose E. Marchesi wrote:
>
> > diff --git a/poke/pk-mi.c b/poke/pk-mi.c
> > index c44b04d7..95ad34a9 100644
> > --- a/poke/pk-mi.c
> > +++ b/poke/pk-mi.c
> > @@ -57,14 +57,14 @@ static void pk_mi_dispatch_msg (pk_mi_msg msg);
> > static void
> > pk_mi_process_frame_msg (int size, char *frame_msg)
> > {
> > - pk_mi_msg msg = pk_mi_json_to_msg (frame_msg);
> > + char *errmsg = NULL;
> > + pk_mi_msg msg = pk_mi_json_to_msg (frame_msg, &errmsg);
> >
> > - if (!msg)
> > - /* Bad message. Ignore it. */
> > - /* XXX: raise an event to communicate this to the client? */
> > - return;
> > -
> > - pk_mi_dispatch_msg (msg);
> > + if (msg)
> > + pk_mi_dispatch_msg (msg);
> > + else
> > + ; /* XXX: raise an event to communicate this to the client. */
> > + free (errmsg);
> > }
> >
> > static int
>
> Why having `errmsg' if it is not used? Why is it useful?
>
In the following patch, I use it to report the error message to the client.
> If you keep it, I would rewrite pk_mi_json_to_msg in a way that you can
> pass NULL instead of a pointer when you are not interested in the error
> message.
>
Actually, it accepts `NULL` pointers, but I forgot to use it in this
patch. Sorry!
I'll fix for this patch.
Regards,
Mohammad-Reza