[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: |
Jose E. Marchesi |
Subject: |
Re: [PATCH 1/2] MI: Improve JSON handling to be more declarative |
Date: |
Fri, 06 Aug 2021 14:31:18 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> 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?
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.