Skip to contentSkip to conversation

rtc: max77686: add missing variable initialization

PATCH In review Jingoo Han 2 participants 2 messages Feb 15, 2013

Subsystems (2)
lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/1 rtc: max77686: add missing variable initialization

Fixed build warning as below:

drivers/rtc/rtc-max77686.c: In function 'max77686_rtc_update':
drivers/rtc/rtc-max77686.c:147:6: warning: 'data' may be used uninitialized in this function [-Wuninitialized]

---
 drivers/rtc/rtc-max77686.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/rtc/rtc-max77686.c +1 -1
index abe27c0..2634fed 100644
@@ -133,7 +133,7 @@ static int max77686_rtc_update(struct max77686_rtc_info *info,
 	enum MAX77686_RTC_OP op)
 {
 	int ret;
-	unsigned int data;
+	unsigned int data = 0;
 
 	switch (op) {
 	case MAX77686_RTC_WRITE:
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 15 lines · On Fri, 15 Feb 2013 16:45:38 +0900 Jingoo Han <[email protected]> wrote:

Fixed build warning as below:

drivers/rtc/rtc-max77686.c: In function 'max77686_rtc_update':
drivers/rtc/rtc-max77686.c:147:6: warning: 'data' may be used uninitialized in this function [-Wuninitialized]

---
 drivers/rtc/rtc-max77686.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/rtc/rtc-max77686.c +0 -0
index abe27c0..2634fed 100644

drivers/rtc/rtc-max77686.c static int max77686_rtc_update(struct max77686_rtc_info *info, · line 139

Quoted 8 lines
drivers/rtc/rtc-max77686.c +1 -1
@@ -133,7 +133,7 @@ static int max77686_rtc_update(struct max77686_rtc_info *info,
 	enum MAX77686_RTC_OP op)
 {
 	int ret;
-	unsigned int data;
+	unsigned int data = 0;
 
 	switch (op) {
 	case MAX77686_RTC_WRITE:

spose so. But the end result is rather awkward-looking.

As `op' must be (and is) one of MAX77686_RTC_WRITE and MAX77686_RTC_READ, the straightfoward implementation is

static int max77686_rtc_update(struct max77686_rtc_info *info,

	enum MAX77686_RTC_OP op)
{
	int ret;
	unsigned int data;

	if (op == MAX77686_RTC_WRITE)
		data = 1 << RTC_UDR_SHIFT;
	else
		data = 1 << RTC_RBUDR_SHIFT;