* [RFC: sound/i2c/cs8427] clang warns about cast to signed char
@ 2018-10-18 10:10 ` Philipp K
0 siblings, 0 replies; 4+ messages in thread
From: Philipp K @ 2018-10-18 10:10 UTC (permalink / raw)
Cc: kernelnewbies, linux-kernel, perex, tiwai, Lukas Bulwahn
Hi,
I tried compiling the cs8247 sound module with clang and hit the
following warning:
sound/i2c/cs8427.c:141:31: warning: implicit conversion from 'int' to
'char' changes value from 160 to -96 [-Wconstant-conversion]
data[0] = CS8427_REG_AUTOINC | CS8427_REG_CORU_DATABUF;
~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
data is a char array, and CS8427_REG_AUTOINC is defined as 0x80 (dec
128) which is too big for a (signed) char.
Looking at other code in the same file, we usually use unsigned chars.
So is there a reason for data being signed in this case? Otherwise we
could just change data to unsigned char and be on the safe side.
If you want I can send in a patch.
Regards,
Philipp
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC: sound/i2c/cs8427] clang warns about cast to signed char
@ 2018-10-18 10:10 ` Philipp K
0 siblings, 0 replies; 4+ messages in thread
From: Philipp K @ 2018-10-18 10:10 UTC (permalink / raw)
To: kernelnewbies
Hi,
I tried compiling the cs8247 sound module with clang and hit the
following warning:
sound/i2c/cs8427.c:141:31: warning: implicit conversion from 'int' to
'char' changes value from 160 to -96 [-Wconstant-conversion]
data[0] = CS8427_REG_AUTOINC | CS8427_REG_CORU_DATABUF;
~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
data is a char array, and CS8427_REG_AUTOINC is defined as 0x80 (dec
128) which is too big for a (signed) char.
Looking at other code in the same file, we usually use unsigned chars.
So is there a reason for data being signed in this case? Otherwise we
could just change data to unsigned char and be on the safe side.
If you want I can send in a patch.
Regards,
Philipp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC: sound/i2c/cs8427] clang warns about cast to signed char
2018-10-18 10:10 ` Philipp K
@ 2018-10-18 10:13 ` Takashi Iwai
-1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2018-10-18 10:13 UTC (permalink / raw)
To: Philipp K; +Cc: Lukas Bulwahn, kernelnewbies, perex, linux-kernel
On Thu, 18 Oct 2018 12:10:28 +0200,
Philipp K wrote:
>
> Hi,
>
> I tried compiling the cs8247 sound module with clang and hit the
> following warning:
>
> sound/i2c/cs8427.c:141:31: warning: implicit conversion from 'int' to
> 'char' changes value from 160 to -96 [-Wconstant-conversion]
> data[0] = CS8427_REG_AUTOINC | CS8427_REG_CORU_DATABUF;
> ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
>
> data is a char array, and CS8427_REG_AUTOINC is defined as 0x80 (dec
> 128) which is too big for a (signed) char.
>
> Looking at other code in the same file, we usually use unsigned chars.
>
> So is there a reason for data being signed in this case? Otherwise we
> could just change data to unsigned char and be on the safe side.
No any reason I know of. It must be just an old convention.
> If you want I can send in a patch.
Yes, please.
thanks,
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC: sound/i2c/cs8427] clang warns about cast to signed char
@ 2018-10-18 10:13 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2018-10-18 10:13 UTC (permalink / raw)
To: kernelnewbies
On Thu, 18 Oct 2018 12:10:28 +0200,
Philipp K wrote:
>
> Hi,
>
> I tried compiling the cs8247 sound module with clang and hit the
> following warning:
>
> sound/i2c/cs8427.c:141:31: warning: implicit conversion from 'int' to
> 'char' changes value from 160 to -96 [-Wconstant-conversion]
> data[0] = CS8427_REG_AUTOINC | CS8427_REG_CORU_DATABUF;
> ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
>
> data is a char array, and CS8427_REG_AUTOINC is defined as 0x80 (dec
> 128) which is too big for a (signed) char.
>
> Looking at other code in the same file, we usually use unsigned chars.
>
> So is there a reason for data being signed in this case? Otherwise we
> could just change data to unsigned char and be on the safe side.
No any reason I know of. It must be just an old convention.
> If you want I can send in a patch.
Yes, please.
thanks,
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-18 10:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-18 10:10 [RFC: sound/i2c/cs8427] clang warns about cast to signed char Philipp K
2018-10-18 10:10 ` Philipp K
2018-10-18 10:13 ` Takashi Iwai
2018-10-18 10:13 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.