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. [...] >