* [PATCH] [sound/i2c/cs8427] Fix int to char conversion
@ 2018-10-18 10:33 Philipp Klocke
2018-10-18 13:46 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Philipp Klocke @ 2018-10-18 10:33 UTC (permalink / raw)
Cc: lukas.bulwahn, linux-kernel, Philipp Klocke, Jaroslav Kysela,
Takashi Iwai
Compiling with clang yields the following warning:
sound/i2c/cs8427.c:140: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;
~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Because CS8427_REG_AUTOINC is defined as 128, it is too big for a
char field.
So change data from char to unsigned char, that it can hold the value.
This patch does not change the generated code.
Signed-off-by: Philipp Klocke <philipp97kl@gmail.com>
---
sound/i2c/cs8427.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c
index 2647309bc675..8afa2f888466 100644
--- a/sound/i2c/cs8427.c
+++ b/sound/i2c/cs8427.c
@@ -118,7 +118,7 @@ static int snd_cs8427_send_corudata(struct snd_i2c_device *device,
struct cs8427 *chip = device->private_data;
char *hw_data = udata ?
chip->playback.hw_udata : chip->playback.hw_status;
- char data[32];
+ unsigned char data[32];
int err, idx;
if (!memcmp(hw_data, ndata, count))
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [sound/i2c/cs8427] Fix int to char conversion
2018-10-18 10:33 [PATCH] [sound/i2c/cs8427] Fix int to char conversion Philipp Klocke
@ 2018-10-18 13:46 ` Takashi Iwai
[not found] ` <CAGZ+4_KdtsmuvrtmSnt729xCs1W4s+O+7hXS-D7gVc5+4W+ThQ@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2018-10-18 13:46 UTC (permalink / raw)
To: Philipp Klocke; +Cc: lukas.bulwahn, Jaroslav Kysela, linux-kernel
On Thu, 18 Oct 2018 12:33:02 +0200,
Philipp Klocke wrote:
>
> Compiling with clang yields the following warning:
>
> sound/i2c/cs8427.c:140: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;
> ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
>
> Because CS8427_REG_AUTOINC is defined as 128, it is too big for a
> char field.
> So change data from char to unsigned char, that it can hold the value.
>
> This patch does not change the generated code.
>
> Signed-off-by: Philipp Klocke <philipp97kl@gmail.com>
Applied, thanks.
But at the next time, please put the relevant subsystem MLs to Cc,
and use the proper subject prefix (depending on the subsystem).
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [sound/i2c/cs8427] Fix int to char conversion
[not found] ` <CAGZ+4_KdtsmuvrtmSnt729xCs1W4s+O+7hXS-D7gVc5+4W+ThQ@mail.gmail.com>
@ 2018-10-18 13:55 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2018-10-18 13:55 UTC (permalink / raw)
To: Philipp K; +Cc: Lukas Bulwahn, Jaroslav Kysela, linux-kernel
On Thu, 18 Oct 2018 15:47:55 +0200,
Philipp K wrote:
>
> [1 <text/plain; UTF-8 (7bit)>]
>
> On Thu, Oct 18, 2018, 15:46 Takashi Iwai <tiwai@suse.de> wrote:
>
> On Thu, 18 Oct 2018 12:33:02 +0200,
> Philipp Klocke wrote:
> >
> > Compiling with clang yields the following warning:
> >
> > sound/i2c/cs8427.c:140: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;
> > ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Because CS8427_REG_AUTOINC is defined as 128, it is too big for a
> > char field.
> > So change data from char to unsigned char, that it can hold the value.
> >
> > This patch does not change the generated code.
> >
> > Signed-off-by: Philipp Klocke <philipp97kl@gmail.com>
>
> Applied, thanks.
>
> But at the next time, please put the relevant subsystem MLs to Cc,
>
> Oh sorry I forgot that. Just used the get maintainer script.
>
> and use the proper subject prefix (depending on the subsystem).
>
> What would have been the correct prefix in this case?
In this particular case, I modified the subject to
ALSA: i2c/cs8427: Fix int to char conversion
The subject prefix usage is case-by-case. Better to look at the
commits of the relevant file and just follow the convention in
general.
thanks,
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-18 13:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-18 10:33 [PATCH] [sound/i2c/cs8427] Fix int to char conversion Philipp Klocke
2018-10-18 13:46 ` Takashi Iwai
[not found] ` <CAGZ+4_KdtsmuvrtmSnt729xCs1W4s+O+7hXS-D7gVc5+4W+ThQ@mail.gmail.com>
2018-10-18 13:55 ` 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.