提交 cf04a4c7 编写于 作者: S Stephen Hemminger 提交者: David S. Miller

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: NStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 db4148da
...@@ -1225,7 +1225,7 @@ extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); ...@@ -1225,7 +1225,7 @@ extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
extern int dev_ethtool(struct net *net, struct ifreq *); extern int dev_ethtool(struct net *net, struct ifreq *);
extern unsigned dev_get_flags(const struct net_device *); extern unsigned dev_get_flags(const struct net_device *);
extern int dev_change_flags(struct net_device *, unsigned); extern int dev_change_flags(struct net_device *, unsigned);
extern int dev_change_name(struct net_device *, char *); extern int dev_change_name(struct net_device *, const char *);
extern int dev_set_alias(struct net_device *, const char *, size_t); extern int dev_set_alias(struct net_device *, const char *, size_t);
extern int dev_change_net_namespace(struct net_device *, extern int dev_change_net_namespace(struct net_device *,
struct net *, const char *); struct net *, const char *);
...@@ -1670,7 +1670,7 @@ extern void dev_seq_stop(struct seq_file *seq, void *v); ...@@ -1670,7 +1670,7 @@ extern void dev_seq_stop(struct seq_file *seq, void *v);
extern int netdev_class_create_file(struct class_attribute *class_attr); extern int netdev_class_create_file(struct class_attribute *class_attr);
extern void netdev_class_remove_file(struct class_attribute *class_attr); extern void netdev_class_remove_file(struct class_attribute *class_attr);
extern char *netdev_drivername(struct net_device *dev, char *buffer, int len); extern char *netdev_drivername(const struct net_device *dev, char *buffer, int len);
extern void linkwatch_run_queue(void); extern void linkwatch_run_queue(void);
......
...@@ -890,7 +890,7 @@ int dev_alloc_name(struct net_device *dev, const char *name) ...@@ -890,7 +890,7 @@ int dev_alloc_name(struct net_device *dev, const char *name)
* Change name of a device, can pass format strings "eth%d". * Change name of a device, can pass format strings "eth%d".
* for wildcarding. * for wildcarding.
*/ */
int dev_change_name(struct net_device *dev, char *newname) int dev_change_name(struct net_device *dev, const char *newname)
{ {
char oldname[IFNAMSIZ]; char oldname[IFNAMSIZ];
int err = 0; int err = 0;
...@@ -916,7 +916,6 @@ int dev_change_name(struct net_device *dev, char *newname) ...@@ -916,7 +916,6 @@ int dev_change_name(struct net_device *dev, char *newname)
err = dev_alloc_name(dev, newname); err = dev_alloc_name(dev, newname);
if (err < 0) if (err < 0)
return err; return err;
strcpy(newname, dev->name);
} }
else if (__dev_get_by_name(net, newname)) else if (__dev_get_by_name(net, newname))
return -EEXIST; return -EEXIST;
...@@ -4754,10 +4753,10 @@ static int __net_init netdev_init(struct net *net) ...@@ -4754,10 +4753,10 @@ static int __net_init netdev_init(struct net *net)
return -ENOMEM; return -ENOMEM;
} }
char *netdev_drivername(struct net_device *dev, char *buffer, int len) char *netdev_drivername(const struct net_device *dev, char *buffer, int len)
{ {
struct device_driver *driver; const struct device_driver *driver;
struct device *parent; const struct device *parent;
if (len <= 0 || !buffer) if (len <= 0 || !buffer)
return buffer; return buffer;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册