This is not the proper solution. If you start ovn-northd and do not add any
logical switches or routers, then there will be no logical flows created.
Currently, if you run `ovs-sbctl lflow-list` in this circumstance, it lists
nothing and exits cleanly. With this change, the command hits the assertion
and crashes.
it's not an erroneous case to have no logical flows to sort. I think the
proper thing to do in this case is to check the value of n_flows after the
loop that populates lflows. If it is 0, then close the vconn and exit the
function early.

On Sat, Oct 28, 2017 at 12:37 PM William Tu <[email protected]> wrote:

> Clang reports possible null pointer 'lflows' passed to qsort.
> This is due to the checker unable to make sure whether 'lflows'
> gets malloc or not in the previous loop.  Thus, fix it by adding
> ovs_assert to pass clang checker.
>
> Signed-off-by: William Tu <[email protected]>
> ---
>  ovn/utilities/ovn-sbctl.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
> index 7af5863b08fc..b1f106002842 100644
> --- a/ovn/utilities/ovn-sbctl.c
> +++ b/ovn/utilities/ovn-sbctl.c
> @@ -860,6 +860,7 @@ cmd_lflow_list(struct ctl_context *ctx)
>          lflows[n_flows] = lflow;
>          n_flows++;
>      }
> +    ovs_assert(lflows);
>      qsort(lflows, n_flows, sizeof *lflows, lflow_cmp);
>
>      bool print_uuid = shash_find(&ctx->options, "--uuid") != NULL;
> --
> 2.7.4
>
> _______________________________________________
> dev mailing list
> [email protected]
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to