[ovs-dev] [rtnl_link_stats64 1/4] datapath: Use struct assignment in place of memcpy() for copying stats.

Ben Pfaff blp at nicira.com
Thu Nov 4 21:18:07 UTC 2010


We might as well take advantage of type safety when we can get it.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 datapath/vport.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/datapath/vport.c b/datapath/vport.c
index 6c8eb08..f0c8182 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -910,7 +910,7 @@ int vport_set_stats(struct vport *vport, struct odp_vport_stats *stats)
 
 	if (vport->ops->flags & VPORT_F_GEN_STATS) {
 		spin_lock_bh(&vport->stats_lock);
-		memcpy(&vport->offset_stats, stats, sizeof(struct odp_vport_stats));
+		vport->offset_stats = *stats;
 		spin_unlock_bh(&vport->stats_lock);
 
 		return 0;
@@ -1030,7 +1030,7 @@ int vport_get_stats(struct vport *vport, struct odp_vport_stats *stats)
 
 		spin_lock_bh(&vport->stats_lock);
 
-		memcpy(stats, &vport->offset_stats, sizeof(struct odp_vport_stats));
+		*stats = vport->offset_stats;
 
 		stats->rx_errors	+= vport->err_stats.rx_errors
 						+ vport->err_stats.rx_frame_err
-- 
1.7.1





More information about the dev mailing list