[ovs-dev] Coverity incorrect expression of HMAP_FOR_EACH_WITH_HASH

Usman Ansari uansari at vmware.com
Wed Mar 18 18:43:16 UTC 2020


Ben,

I have verified your change to the macro and sending the patch.

Thanks.

On 3/17/20, 8:33 PM, "dev on behalf of William Tu" <ovs-dev-bounces at openvswitch.org on behalf of u9012063 at gmail.com> wrote:

    On Tue, Mar 17, 2020 at 5:39 PM Ben Pfaff <blp at ovn.org> wrote:
    >
    > On Tue, Mar 17, 2020 at 05:00:42PM -0700, William Tu wrote:
    > > Hi,
    > >
    > > We're looking at the coverity results and there are lots of issues of
    > > Incorrect expression
    > > Assign_where_compare_meant: use of "=" where "==" may have been intended
    > >
    > > Because in our source code, we have
    > > HMAP_FOR_EACH_WITH_HASH(id_node, node, hash, &pool->map) {
    > > ...
    > >
    > > And Due to "(NODE = NULL)" in the CONDITION statement below:
    > > #define HMAP_FOR_EACH_WITH_HASH(NODE, MEMBER, HASH, HMAP)               \
    > >     for (INIT_CONTAINER(NODE, hmap_first_with_hash(HMAP, HASH), MEMBER); \
    > >          (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) || (NODE = NULL); \
    > >          ASSIGN_CONTAINER(NODE, hmap_next_with_hash(&(NODE)->MEMBER),   \
    > >                           MEMBER))
    > >
    > > While this is correct, I wonder how can we avoid this?
    >
    > We could rewrite (NODE = NULL) as ((NODE = NULL), false).
    
    Thanks!
    Let me try it and get back to you.
    William
    _______________________________________________
    dev mailing list
    dev at openvswitch.org
    https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&data=02%7C01%7Cuansari%40vmware.com%7C8948d58fbeac4ddf83b908d7caed2402%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637200992195133490&sdata=o2Ini421ztOl84NHRgKzD2fUkMo1BQGoGpNXeGn%2Fg%2Bk%3D&reserved=0
    



More information about the dev mailing list