[PATCH 1/2] rtc: define maximum size of RTC device name in rtc.h

From: Roman Fietze
Date: Thu Jul 03 2014 - 08:20:40 EST


Signed-off-by: Roman Fietze <roman.fietze@xxxxxxxxxxxxx>
---
drivers/rtc/rtc-proc.c | 10 ++++------
include/linux/rtc.h | 1 +
2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index ffa69e1..a77ca46 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -18,19 +18,17 @@

#include "rtc-core.h"

-#define NAME_SIZE 10
-
#if defined(CONFIG_RTC_HCTOSYS_DEVICE)
static bool is_rtc_hctosys(struct rtc_device *rtc)
{
int size;
- char name[NAME_SIZE];
+ char name[RTC_HCTOSYS_DEVICE_SIZE];

- size = scnprintf(name, NAME_SIZE, "rtc%d", rtc->id);
- if (size > NAME_SIZE)
+ size = scnprintf(name, RTC_HCTOSYS_DEVICE_SIZE, "rtc%d", rtc->id);
+ if (size > RTC_HCTOSYS_DEVICE_SIZE)
return false;

- return !strncmp(name, CONFIG_RTC_HCTOSYS_DEVICE, NAME_SIZE);
+ return !strncmp(name, rtc_hctosys_device, RTC_HCTOSYS_DEVICE_SIZE);
}
#else
static bool is_rtc_hctosys(struct rtc_device *rtc)
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index c2c2897..0a115b5 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -192,6 +192,7 @@ static inline bool is_leap_year(unsigned int year)
}

#ifdef CONFIG_RTC_HCTOSYS_DEVICE
+#define RTC_HCTOSYS_DEVICE_SIZE 10
extern int rtc_hctosys_ret;
#else
#define rtc_hctosys_ret -ENODEV
--
1.8.4.5



Roman

--
Roman Fietze Telemotive AG Buero Muehlhausen
Breitwiesen 73347 Muehlhausen
Tel.: +49 7335 18493-45 http://www.telemotive.de

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/