[PATCH staging] ipack: make function tables const.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Any pure function table should be made const to avoid bugs
and smashing attacks. Also remove unnecessary
duplicate definition.

Compile tested only.

Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxxxx>


---
 drivers/staging/ipack/bridges/tpci200.c |    6 ++----
 drivers/staging/ipack/devices/ipoctal.c |    2 +-
 drivers/staging/ipack/ipack.c           |    2 +-
 drivers/staging/ipack/ipack.h           |    6 +++---
 4 files changed, 7 insertions(+), 9 deletions(-)

--- a/drivers/staging/ipack/bridges/tpci200.c	2012-09-07 08:51:08.028927586 -0700
+++ b/drivers/staging/ipack/bridges/tpci200.c	2012-09-07 08:51:09.988907900 -0700
@@ -14,10 +14,8 @@
 #include <linux/module.h>
 #include "tpci200.h"
 
-static struct ipack_bus_ops tpci200_bus_ops;
-
 /* TPCI200 controls registers */
-static int control_reg[] = {
+static const int control_reg[] = {
 	TPCI200_CONTROL_A_REG,
 	TPCI200_CONTROL_B_REG,
 	TPCI200_CONTROL_C_REG,
@@ -752,7 +750,7 @@ static void tpci200_uninstall(struct tpc
 	kfree(tpci200->slots);
 }
 
-static struct ipack_bus_ops tpci200_bus_ops = {
+static const struct ipack_bus_ops tpci200_bus_ops = {
 	.map_space = tpci200_slot_map_space,
 	.unmap_space = tpci200_slot_unmap_space,
 	.request_irq = tpci200_request_irq,
--- a/drivers/staging/ipack/ipack.c	2012-09-07 08:47:00.063417904 -0700
+++ b/drivers/staging/ipack/ipack.c	2012-09-07 08:51:09.988907900 -0700
@@ -70,7 +70,7 @@ static struct bus_type ipack_bus_type =
 };
 
 struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
-					    struct ipack_bus_ops *ops)
+					    const struct ipack_bus_ops *ops)
 {
 	int bus_nr;
 	struct ipack_bus_device *bus;
--- a/drivers/staging/ipack/ipack.h	2012-09-07 08:47:00.063417904 -0700
+++ b/drivers/staging/ipack/ipack.h	2012-09-07 08:51:09.988907900 -0700
@@ -95,7 +95,7 @@ struct ipack_driver_ops {
  */
 struct ipack_driver {
 	struct device_driver driver;
-	struct ipack_driver_ops *ops;
+	const struct ipack_driver_ops *ops;
 };
 
 /**
@@ -139,7 +139,7 @@ struct ipack_bus_device {
 	struct device *parent;
 	int slots;
 	int bus_nr;
-	struct ipack_bus_ops *ops;
+	const struct ipack_bus_ops *ops;
 };
 
 /**
@@ -153,7 +153,7 @@ struct ipack_bus_device {
  * available bus device in ipack.
  */
 struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
-					    struct ipack_bus_ops *ops);
+					    const struct ipack_bus_ops *ops);
 
 /**
  *	ipack_bus_unregister -- unregister an ipack bus
--- a/drivers/staging/ipack/devices/ipoctal.c	2012-09-07 08:47:00.063417904 -0700
+++ b/drivers/staging/ipack/devices/ipoctal.c	2012-09-07 08:51:09.988907900 -0700
@@ -863,7 +863,7 @@ static void ipoctal_remove(struct ipack_
 	}
 }
 
-static struct ipack_driver_ops ipoctal_drv_ops = {
+static const struct ipack_driver_ops ipoctal_drv_ops = {
 	.match = ipoctal_match,
 	.probe = ipoctal_probe,
 	.remove = ipoctal_remove,
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux