linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: hwmon: remove redundant cast
@ 2018-10-26 22:30 Rasmus Villemoes
  2018-10-27 17:32 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Villemoes @ 2018-10-26 22:30 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: Rasmus Villemoes, linux-hwmon, linux-kernel

struct attribute::name which this local variable name is eventually
assigned to is "const char*", and so is the template parameter. We might
as well preserve the constness all the way through.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/hwmon/hwmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 975c95169884..ea42c5ec40d9 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -267,7 +267,7 @@ static struct attribute *hwmon_genattr(struct device *dev,
 	struct device_attribute *dattr;
 	struct attribute *a;
 	umode_t mode;
-	char *name;
+	const char *name;
 	bool is_string = is_string_attr(type, attr);
 
 	/* The attribute is invisible if there is no template string */
@@ -289,7 +289,7 @@ static struct attribute *hwmon_genattr(struct device *dev,
 		return ERR_PTR(-ENOMEM);
 
 	if (type == hwmon_chip) {
-		name = (char *)template;
+		name = template;
 	} else {
 		scnprintf(hattr->name, sizeof(hattr->name), template,
 			  index + hwmon_attr_base(type));
-- 
2.19.1.6.gbde171bbf5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drivers: hwmon: remove redundant cast
  2018-10-26 22:30 [PATCH] drivers: hwmon: remove redundant cast Rasmus Villemoes
@ 2018-10-27 17:32 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2018-10-27 17:32 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: Jean Delvare, linux-hwmon, linux-kernel

On Sat, Oct 27, 2018 at 12:30:59AM +0200, Rasmus Villemoes wrote:
> struct attribute::name which this local variable name is eventually
> assigned to is "const char*", and so is the template parameter. We might
> as well preserve the constness all the way through.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Applied to hwmon-next.

Note that the "drivers:" tag is unnecessary; I removed it when applying
the patch.

Guenter

> ---
>  drivers/hwmon/hwmon.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index 975c95169884..ea42c5ec40d9 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -267,7 +267,7 @@ static struct attribute *hwmon_genattr(struct device *dev,
>  	struct device_attribute *dattr;
>  	struct attribute *a;
>  	umode_t mode;
> -	char *name;
> +	const char *name;
>  	bool is_string = is_string_attr(type, attr);
>  
>  	/* The attribute is invisible if there is no template string */
> @@ -289,7 +289,7 @@ static struct attribute *hwmon_genattr(struct device *dev,
>  		return ERR_PTR(-ENOMEM);
>  
>  	if (type == hwmon_chip) {
> -		name = (char *)template;
> +		name = template;
>  	} else {
>  		scnprintf(hattr->name, sizeof(hattr->name), template,
>  			  index + hwmon_attr_base(type));

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-27 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-26 22:30 [PATCH] drivers: hwmon: remove redundant cast Rasmus Villemoes
2018-10-27 17:32 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).