[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] PATCH: Misc fixes to qparams



"Daniel P. Berrange" <berrange redhat com> wrote:

> I found a couple more small bugs in the qparams code
>
>  - In the qparam_query_parse() method, after appending each (name,value)
>    pair of params, it failed to free the temporary buffers for the
>    (name,value) pair.
>  - Did not allow for ';' as a valid query parameter separator
>  - In a couple of OOM cleanup scenarios it failed to free buffers allocated
>    earlier on
>
> In looking at this I decide we ought to have a test suite for this code
> so I'm also including one. It has 100% coverage of all the non-OOM code
> paths. The test case now passes when run under valgrind

Nice!

...
> +static const struct qparamParseDataEntry params1[] = { { "foo", "one" }, { "bar", "two" } };
> +static const struct qparamParseDataEntry params2[] = { { "foo", "one" }, { "foo", "two" } };
> +static const struct qparamParseDataEntry params3[] = { { "foo", "&one" }, { "bar", "&two" } };
> +static const struct qparamParseDataEntry params4[] = { { "foo", "" } };
> +static const struct qparamParseDataEntry params5[] = { { "foo", "one two" } };
> +static const struct qparamParseDataEntry params6[] = { { "foo", "one" } };

You can help the compiler by adding one more layer of "const"
there, since it's a const array of const elements, e.g.,

static const struct qparamParseDataEntry const params6[] = { { "foo", "one" } };
                                         ^^^^^


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]