diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-09-30 05:22:14 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-09-30 05:22:14 -0400 |
commit | cf04a4c764cd3e651a64b3e667bb6a673ead99e1 (patch) | |
tree | 61fc379e33ca08e68326b9f76577fd2a57435034 | |
parent | db4148da2cc84c31419b5e3ae3115ac6e11817a1 (diff) |
netdev: use const for some name functions
dev_change_name and netdev_drivername should use const char on
parameters that are read-only input values. The strcpy to newname is
not needed since newname is not used later in function.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/netdevice.h | 4 | ||||
-rw-r--r-- | net/core/dev.c | 9 |
2 files changed, 6 insertions, 7 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d675df08b946..9cfd20be8b7f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1225,7 +1225,7 @@ extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); | |||
1225 | extern int dev_ethtool(struct net *net, struct ifreq *); | 1225 | extern int dev_ethtool(struct net *net, struct ifreq *); |
1226 | extern unsigned dev_get_flags(const struct net_device *); | 1226 | extern unsigned dev_get_flags(const struct net_device *); |
1227 | extern int dev_change_flags(struct net_device *, unsigned); | 1227 | extern int dev_change_flags(struct net_device *, unsigned); |
1228 | extern int dev_change_name(struct net_device *, char *); | 1228 | extern int dev_change_name(struct net_device *, const char *); |
1229 | extern int dev_set_alias(struct net_device *, const char *, size_t); | 1229 | extern int dev_set_alias(struct net_device *, const char *, size_t); |
1230 | extern int dev_change_net_namespace(struct net_device *, | 1230 | extern int dev_change_net_namespace(struct net_device *, |
1231 | struct net *, const char *); | 1231 | struct net *, const char *); |
@@ -1670,7 +1670,7 @@ extern void dev_seq_stop(struct seq_file *seq, void *v); | |||
1670 | extern int netdev_class_create_file(struct class_attribute *class_attr); | 1670 | extern int netdev_class_create_file(struct class_attribute *class_attr); |
1671 | extern void netdev_class_remove_file(struct class_attribute *class_attr); | 1671 | extern void netdev_class_remove_file(struct class_attribute *class_attr); |
1672 | 1672 | ||
1673 | extern char *netdev_drivername(struct net_device *dev, char *buffer, int len); | 1673 | extern char *netdev_drivername(const struct net_device *dev, char *buffer, int len); |
1674 | 1674 | ||
1675 | extern void linkwatch_run_queue(void); | 1675 | extern void linkwatch_run_queue(void); |
1676 | 1676 | ||
diff --git a/net/core/dev.c b/net/core/dev.c index a90737fe2472..64f0d5b7cdfc 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -890,7 +890,7 @@ int dev_alloc_name(struct net_device *dev, const char *name) | |||
890 | * Change name of a device, can pass format strings "eth%d". | 890 | * Change name of a device, can pass format strings "eth%d". |
891 | * for wildcarding. | 891 | * for wildcarding. |
892 | */ | 892 | */ |
893 | int dev_change_name(struct net_device *dev, char *newname) | 893 | int dev_change_name(struct net_device *dev, const char *newname) |
894 | { | 894 | { |
895 | char oldname[IFNAMSIZ]; | 895 | char oldname[IFNAMSIZ]; |
896 | int err = 0; | 896 | int err = 0; |
@@ -916,7 +916,6 @@ int dev_change_name(struct net_device *dev, char *newname) | |||
916 | err = dev_alloc_name(dev, newname); | 916 | err = dev_alloc_name(dev, newname); |
917 | if (err < 0) | 917 | if (err < 0) |
918 | return err; | 918 | return err; |
919 | strcpy(newname, dev->name); | ||
920 | } | 919 | } |
921 | else if (__dev_get_by_name(net, newname)) | 920 | else if (__dev_get_by_name(net, newname)) |
922 | return -EEXIST; | 921 | return -EEXIST; |
@@ -4754,10 +4753,10 @@ err_name: | |||
4754 | return -ENOMEM; | 4753 | return -ENOMEM; |
4755 | } | 4754 | } |
4756 | 4755 | ||
4757 | char *netdev_drivername(struct net_device *dev, char *buffer, int len) | 4756 | char *netdev_drivername(const struct net_device *dev, char *buffer, int len) |
4758 | { | 4757 | { |
4759 | struct device_driver *driver; | 4758 | const struct device_driver *driver; |
4760 | struct device *parent; | 4759 | const struct device *parent; |
4761 | 4760 | ||
4762 | if (len <= 0 || !buffer) | 4761 | if (len <= 0 || !buffer) |
4763 | return buffer; | 4762 | return buffer; |