* [PATCH] emu10k1: Fix coccicheck warning
@ 2013-03-10 12:37 Vicentiu Ciorbaru
2013-03-10 16:32 ` Clemens Ladisch
0 siblings, 1 reply; 6+ messages in thread
From: Vicentiu Ciorbaru @ 2013-03-10 12:37 UTC (permalink / raw)
To: perex; +Cc: tiwai, wfp5p, cvicentiu, alsa-devel, linux-kernel
Removed redundant cast of kmalloc return pointer.
Signed-off-by: Vicentiu Ciorbaru <cvicentiu@gmail.com>
---
sound/pci/emu10k1/emufx.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 0275209..a0f7502 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -1183,9 +1183,8 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
mm_segment_t seg;
if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL ||
- (icode->gpr_map = (u_int32_t __user *)
- kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
- GFP_KERNEL)) == NULL ||
+ (icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024,
+ sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
(controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
sizeof(*controls), GFP_KERNEL)) == NULL) {
err = -ENOMEM;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] emu10k1: Fix coccicheck warning
2013-03-10 12:37 [PATCH] emu10k1: Fix coccicheck warning Vicentiu Ciorbaru
@ 2013-03-10 16:32 ` Clemens Ladisch
0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2013-03-10 16:32 UTC (permalink / raw)
To: Vicentiu Ciorbaru; +Cc: tiwai, alsa-devel, wfp5p, linux-kernel
Vicentiu Ciorbaru wrote:
> Removed redundant cast of kmalloc return pointer.
> - (icode->gpr_map = (u_int32_t __user *)
> - kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
> - GFP_KERNEL)) == NULL ||
> + (icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024,
> + sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
Why would casting to __user be redundant?
Regards,
Clemens
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] emu10k1: Fix coccicheck warning
@ 2013-03-10 16:32 ` Clemens Ladisch
0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2013-03-10 16:32 UTC (permalink / raw)
To: Vicentiu Ciorbaru; +Cc: perex, tiwai, wfp5p, alsa-devel, linux-kernel
Vicentiu Ciorbaru wrote:
> Removed redundant cast of kmalloc return pointer.
> - (icode->gpr_map = (u_int32_t __user *)
> - kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
> - GFP_KERNEL)) == NULL ||
> + (icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024,
> + sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
Why would casting to __user be redundant?
Regards,
Clemens
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] emu10k1: Fix coccicheck warning
[not found] ` <CACzaYTOE=tVst3=TvUCtxpMuUOtJiHQ3o2wbgWeMvxwZy41DMw@mail.gmail.com>
@ 2013-03-10 19:49 ` Clemens Ladisch
0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2013-03-10 19:49 UTC (permalink / raw)
To: Vicentiu Ciorbaru; +Cc: tiwai, alsa-devel, wfp5p, linux-kernel
Vicentiu Ciorbaru wrote:
> On Sun, Mar 10, 2013 at 6:32 PM, Clemens Ladisch <clemens@ladisch.de> wrote:
>> Vicentiu Ciorbaru wrote:
>>> Removed redundant cast of kmalloc return pointer.
>>
>>> - (icode->gpr_map = (u_int32_t __user *)
>>> - kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
>>> - GFP_KERNEL)) == NULL ||
>>> + (icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024,
>>> + sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
>>
>> Why would casting to __user be redundant?
>
> My reasoning behind the patch is that the C standard does not require a
> specific cast of a void pointer in order to set it to the type of the
> member gpr_map of the struct snd_emu10k1_fx8010_code. I named it redundant
> because the compiler would cast to it anyway.
That's correct as far as the C standard is concerned. However, __user is
a non-standard extension.
> The line also appears as a warning when running make coccicheck.
And when you remove the __user, you get a warning when running make C=x.
Both coccinelle and sparse are merely tools for finding likely bugs.
When it isn't possible to make them both happy with or without the cast,
that just shows that the code itself is badly designed.
The driver should be redesigned to not access user and kernel space
memory through the same pointer.
Regards,
Clemens
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] emu10k1: Fix coccicheck warning
@ 2013-03-10 19:49 ` Clemens Ladisch
0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2013-03-10 19:49 UTC (permalink / raw)
To: Vicentiu Ciorbaru; +Cc: perex, tiwai, wfp5p, alsa-devel, linux-kernel
Vicentiu Ciorbaru wrote:
> On Sun, Mar 10, 2013 at 6:32 PM, Clemens Ladisch <clemens@ladisch.de> wrote:
>> Vicentiu Ciorbaru wrote:
>>> Removed redundant cast of kmalloc return pointer.
>>
>>> - (icode->gpr_map = (u_int32_t __user *)
>>> - kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
>>> - GFP_KERNEL)) == NULL ||
>>> + (icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024,
>>> + sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
>>
>> Why would casting to __user be redundant?
>
> My reasoning behind the patch is that the C standard does not require a
> specific cast of a void pointer in order to set it to the type of the
> member gpr_map of the struct snd_emu10k1_fx8010_code. I named it redundant
> because the compiler would cast to it anyway.
That's correct as far as the C standard is concerned. However, __user is
a non-standard extension.
> The line also appears as a warning when running make coccicheck.
And when you remove the __user, you get a warning when running make C=x.
Both coccinelle and sparse are merely tools for finding likely bugs.
When it isn't possible to make them both happy with or without the cast,
that just shows that the code itself is badly designed.
The driver should be redesigned to not access user and kernel space
memory through the same pointer.
Regards,
Clemens
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] emu10k1: Fix coccicheck warning
2013-03-10 19:49 ` Clemens Ladisch
(?)
@ 2013-03-10 19:59 ` Vicentiu Ciorbaru
-1 siblings, 0 replies; 6+ messages in thread
From: Vicentiu Ciorbaru @ 2013-03-10 19:59 UTC (permalink / raw)
To: Clemens Ladisch; +Cc: perex, tiwai, wfp5p, alsa-devel, linux-kernel
>> My reasoning behind the patch is that the C standard does not require a
>> specific cast of a void pointer in order to set it to the type of the
>> member gpr_map of the struct snd_emu10k1_fx8010_code. I named it redundant
>> because the compiler would cast to it anyway.
>
> That's correct as far as the C standard is concerned. However, __user is
> a non-standard extension.
>
>> The line also appears as a warning when running make coccicheck.
>
> And when you remove the __user, you get a warning when running make C=x.
>
> Both coccinelle and sparse are merely tools for finding likely bugs.
> When it isn't possible to make them both happy with or without the cast,
> that just shows that the code itself is badly designed.
>
> The driver should be redesigned to not access user and kernel space
> memory through the same pointer.
In that case I thank you for the quick feedback and I will try looking
more deeply into the issue.
Vicentiu
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-03-10 19:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-10 12:37 [PATCH] emu10k1: Fix coccicheck warning Vicentiu Ciorbaru
2013-03-10 16:32 ` Clemens Ladisch
2013-03-10 16:32 ` Clemens Ladisch
[not found] ` <CACzaYTOE=tVst3=TvUCtxpMuUOtJiHQ3o2wbgWeMvxwZy41DMw@mail.gmail.com>
2013-03-10 19:49 ` Clemens Ladisch
2013-03-10 19:49 ` Clemens Ladisch
2013-03-10 19:59 ` Vicentiu Ciorbaru
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.