Skip to contentSkip to conversation

rtc: s35390a: Make buf an unsigned char in s35390a_init

PATCH In review Nathan Chancellor 2 participants 4 messages Oct 18, 2018 – Oct 22, 2018 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: s35390a: Make buf an unsigned char in s35390a_init

Clang warns:

drivers/rtc/rtc-s35390a.c:124:27: warning: implicit conversion from 'int' to 'char' changes value from 192 to -64 [-Wconstant-conversion]

        buf = S35390A_FLAG_RESET | S35390A_FLAG_24H;
            ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

1 warning generated.

Update buf to be an unsigned char, which matches the size and signedness of the buf member in struct i2c_msg (__u8).

https://github.com/ClangBuiltLinux/linux/issues/145

---
 drivers/rtc/rtc-s35390a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-s35390a.c +1 -1
index 77feb603cd4c..9fd51337cfae 100644
@@ -108,7 +108,7 @@ static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len)
 
 static int s35390a_init(struct s35390a *s35390a)
 {
-	char buf;
+	unsigned char buf;
 	int ret;
 	unsigned initcount = 0;
 
Signature · 1 line
2.19.1
#1 lore raw

Hello,

Quoted 22 lines · Nathan Chancellor

Clang warns:

drivers/rtc/rtc-s35390a.c:124:27: warning: implicit conversion from 'int' to 'char' changes value from 192 to -64 [-Wconstant-conversion]

        buf = S35390A_FLAG_RESET | S35390A_FLAG_24H;
            ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

1 warning generated.

Update buf to be an unsigned char, which matches the size and signedness of the buf member in struct i2c_msg (__u8).

https://github.com/ClangBuiltLinux/linux/issues/145

---
 drivers/rtc/rtc-s35390a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-s35390a.c +0 -0
index 77feb603cd4c..9fd51337cfae 100644

drivers/rtc/rtc-s35390a.c static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len) · line 111

Quoted 5 lines
drivers/rtc/rtc-s35390a.c +1 -1
@@ -108,7 +108,7 @@ static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len)
 
 static int s35390a_init(struct s35390a *s35390a)
 {
-	char buf;
+	unsigned char buf;

I would use a u8 directly which has the advantage to be shorter :)

Quoted 6 lines
drivers/rtc/rtc-s35390a.c +0 -0
 	int ret;
 	unsigned initcount = 0;
 
Signature · 1 line
2.19.1
Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH v2 1/1 rtc: s35390a: Change buf's type to u8 in s35390a_init

In reply to Nathan Chancellor

Clang warns:

drivers/rtc/rtc-s35390a.c:124:27: warning: implicit conversion from 'int' to 'char' changes value from 192 to -64 [-Wconstant-conversion]

        buf = S35390A_FLAG_RESET | S35390A_FLAG_24H;
            ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

1 warning generated.

Update buf to be an unsigned 8-bit integer, which matches the buf member in struct i2c_msg.

https://github.com/ClangBuiltLinux/linux/issues/145

---

v1 -> v2:

* Use u8 instead of unsigned char, as it's clearer that this is an integer value and it's shorter.

 drivers/rtc/rtc-s35390a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-s35390a.c +1 -1
index 77feb603cd4c..3c64dbb08109 100644
@@ -108,7 +108,7 @@ static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len)
 
 static int s35390a_init(struct s35390a *s35390a)
 {
-	char buf;
+	u8 buf;
 	int ret;
 	unsigned initcount = 0;
 
Signature · 1 line
2.19.1
maintainer Applied
#3 lore raw

Re: [PATCH v2] rtc: s35390a: Change buf's type to u8 in s35390a_init

Quoted 15 lines · Nathan Chancellor

Clang warns:

drivers/rtc/rtc-s35390a.c:124:27: warning: implicit conversion from 'int' to 'char' changes value from 192 to -64 [-Wconstant-conversion]

        buf = S35390A_FLAG_RESET | S35390A_FLAG_24H;
            ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

1 warning generated.

Update buf to be an unsigned 8-bit integer, which matches the buf member in struct i2c_msg.

https://github.com/ClangBuiltLinux/linux/issues/145

---

Quoted 8 lines

v1 -> v2:

* Use u8 instead of unsigned char, as it's clearer that this is an integer value and it's shorter.

 drivers/rtc/rtc-s35390a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com