[ovs-dev] [PATCH] ofproto: Use shash_find_and_delete() in ofport_destroy__().

Ben Pfaff blp at ovn.org
Sat May 27 05:50:52 UTC 2017


This is shorter and slightly safer than combining calls to shash_find()
and shash_delete().

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762983&defectInstanceId=4305289&mergedDefectId=179850
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 ofproto/ofproto.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index d5410fd1b20f..4f627d5f9080 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2511,8 +2511,7 @@ ofport_destroy__(struct ofport *port)
     const char *name = netdev_get_name(port->netdev);
 
     hmap_remove(&ofproto->ports, &port->hmap_node);
-    shash_delete(&ofproto->port_by_name,
-                 shash_find(&ofproto->port_by_name, name));
+    shash_find_and_delete(&ofproto->port_by_name);
 
     netdev_close(port->netdev);
     ofproto->ofproto_class->port_dealloc(port);
-- 
2.10.2



More information about the dev mailing list