Skip to contentSkip to conversation

xen-netback: make ops structs const

PATCH Applied Stephen Hemminger 3 participants 3 messages Jan 4, 2012 – Jan 5, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen-netback: make ops structs const

All tables of function pointers should be const to make hacks more difficult. Compile tested only.

---
Patch against net-next

drivers/net/xen-netback/interface.c +2 -2
@@ -223,7 +223,7 @@ static void xenvif_get_strings(struct ne
 	}
 }
 
-static struct ethtool_ops xenvif_ethtool_ops = {
+static const struct ethtool_ops xenvif_ethtool_ops = {
 	.get_link	= ethtool_op_get_link,
 
 	.get_sset_count = xenvif_get_sset_count,
@@ -231,7 +231,7 @@ static struct ethtool_ops xenvif_ethtool
 	.get_strings = xenvif_get_strings,
 };
 
-static struct net_device_ops xenvif_netdev_ops = {
+static const struct net_device_ops xenvif_netdev_ops = {
 	.ndo_start_xmit	= xenvif_start_xmit,
 	.ndo_get_stats	= xenvif_get_stats,
 	.ndo_open	= xenvif_open,
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Stephen Hemminger

All tables of function pointers should be const to make hacks more difficult. Compile tested only.

I also eyeballed for any writes to these structs and couldn't find one.

Quoted 1 line
Quoted 24 lines

---
Patch against net-next

drivers/net/xen-netback/interface.c +2 -2
@@ -223,7 +223,7 @@ static void xenvif_get_strings(struct ne
 	}
 }
 
-static struct ethtool_ops xenvif_ethtool_ops = {
+static const struct ethtool_ops xenvif_ethtool_ops = {
 	.get_link	= ethtool_op_get_link,
 
 	.get_sset_count = xenvif_get_sset_count,
@@ -231,7 +231,7 @@ static struct ethtool_ops xenvif_ethtool
 	.get_strings = xenvif_get_strings,
 };
 
-static struct net_device_ops xenvif_netdev_ops = {
+static const struct net_device_ops xenvif_netdev_ops = {
 	.ndo_start_xmit	= xenvif_start_xmit,
 	.ndo_get_stats	= xenvif_get_stats,
 	.ndo_open	= xenvif_open,