Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1461154 > unrolled thread

[PATCH] rtc: fix a cast removing the const attribute

Started byLABBE Corentin <clabbe.montjoie@gmail.com>
First post2016-08-12 14:50 +0200
Last post2016-08-13 02:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] rtc: fix a cast removing the const attribute LABBE Corentin <clabbe.montjoie@gmail.com> - 2016-08-12 14:50 +0200
    Re: [PATCH] rtc: fix a cast removing the const attribute Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-08-13 02:20 +0200

#1461154 — [PATCH] rtc: fix a cast removing the const attribute

FromLABBE Corentin <clabbe.montjoie@gmail.com>
Date2016-08-12 14:50 +0200
Subject[PATCH] rtc: fix a cast removing the const attribute
Message-ID<s5k4q-1GM-19@gated-at.bofh.it>
The char pointer buf_ptr is assigned an address from a const char
pointer buf (parameter of wakealarm_store).
The data pointer by buf_ptr is never modified.
So casting it to a (char *) is useless.

This patch remove this cast, and transform buf_ptr to a const char pointer.

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 drivers/rtc/rtc-sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 63b9fb1..1218d5d 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -160,7 +160,7 @@ wakealarm_store(struct device *dev, struct device_attribute *attr,
 	unsigned long push = 0;
 	struct rtc_wkalrm alm;
 	struct rtc_device *rtc = to_rtc_device(dev);
-	char *buf_ptr;
+	const char *buf_ptr;
 	int adjust = 0;
 
 	/* Only request alarms that trigger in the future.  Disable them
@@ -171,7 +171,7 @@ wakealarm_store(struct device *dev, struct device_attribute *attr,
 		return retval;
 	rtc_tm_to_time(&alm.time, &now);
 
-	buf_ptr = (char *)buf;
+	buf_ptr = buf;
 	if (*buf_ptr == '+') {
 		buf_ptr++;
 		if (*buf_ptr == '=') {
-- 
2.7.3

[toc] | [next] | [standalone]


#1461542

FromAlexandre Belloni <alexandre.belloni@free-electrons.com>
Date2016-08-13 02:20 +0200
Message-ID<s5uQ9-xH-7@gated-at.bofh.it>
In reply to#1461154
On 12/08/2016 at 14:46:14 +0200, LABBE Corentin wrote :
> The char pointer buf_ptr is assigned an address from a const char
> pointer buf (parameter of wakealarm_store).
> The data pointer by buf_ptr is never modified.
> So casting it to a (char *) is useless.
> 
> This patch remove this cast, and transform buf_ptr to a const char pointer.
> 
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
>  drivers/rtc/rtc-sysfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web