[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 1/9] qapi: Make qapi_bool_parse() gracefully handle NULL v
From: |
Ilya Leoshkevich |
Subject: |
Re: [PATCH v4 1/9] qapi: Make qapi_bool_parse() gracefully handle NULL value |
Date: |
Fri, 10 Jan 2025 14:03:09 +0100 |
User-agent: |
Evolution 3.52.4 (3.52.4-2.fc40) |
On Fri, 2025-01-10 at 11:33 +0000, Daniel P. Berrangé wrote:
> On Wed, Jan 08, 2025 at 09:04:56PM +0100, Ilya Leoshkevich wrote:
> > Use g_strcmp0(), so that NULL is considered an invalid parameter
> > value.
>
> Why are we calling qapi_bool_parse with a NULL value in the first
> place ? IMHO this is a sign of a bug higher up the call chain
> that ought to be fixed, as in general all our input parsing code
> would expect non-NULL input values.
The intended use case is the following (patch 7/9):
g_auto(GStrv) tokens = g_strsplit(*arg, "=", 2);
Error *err = NULL;
if (g_strcmp0(tokens[0], "suspend") == 0) {
if (!qapi_bool_parse(tokens[0], tokens[1], &suspend, &err)) {
warn_report_err(err);
[...]
The idea is to uniformly handle "suspend=y", "suspend=invalid" and
"suspend"; the latter requires checking whether token[1] is NULL.
Of course, this can be special-cased in the caller, but this would be
less elegant.
[...]
>
- [PATCH v4 0/9] gdbstub: Allow late attachment, Ilya Leoshkevich, 2025/01/08
- [PATCH v4 2/9] gdbstub: Allow the %d placeholder in the socket path, Ilya Leoshkevich, 2025/01/08
- [PATCH v4 4/9] user: Introduce user/signal.h, Ilya Leoshkevich, 2025/01/08
- [PATCH v4 5/9] user: Introduce host_interrupt_signal, Ilya Leoshkevich, 2025/01/08
- [PATCH v4 6/9] osdep: Introduce qemu_kill_thread(), Ilya Leoshkevich, 2025/01/08
- [PATCH v4 8/9] docs/user: Document the %d placeholder and suspend=n QEMU_GDB features, Ilya Leoshkevich, 2025/01/08
- [PATCH v4 7/9] gdbstub: Allow late attachment, Ilya Leoshkevich, 2025/01/08
- [PATCH v4 9/9] tests/tcg: Add late gdbstub attach test, Ilya Leoshkevich, 2025/01/08