Skip to contentSkip to conversation

sound: pci: emu10k1: Remove useless casting in emufx.c

PATCH In review Geyslan G. Bem 2 participants 4 messages Oct 16, 2013 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound: pci: emu10k1: Remove useless casting in emufx.c

Casting (void *) value returned by kcalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

---
 sound/pci/emu10k1/emufx.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
sound/pci/emu10k1/emufx.c +5 -7
index 0275209..3f51dac 100644
@@ -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;
@@ -1815,10 +1814,9 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
 
 	if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
 		return -ENOMEM;
-	if ((icode->gpr_map = (u_int32_t __user *)
-	     kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
-		     GFP_KERNEL)) == NULL ||
-            (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
+	if ((icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
+				      GFP_KERNEL)) == NULL ||
+	    (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
 				sizeof(struct snd_emu10k1_fx8010_control_gpr),
 				GFP_KERNEL)) == NULL ||
 	    (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
Signature · 1 line
1.8.4
#1 lore raw

At Wed, 16 Oct 2013 13:21:45 -0300,

Quoted 5 lines · Geyslan G. Bem

Casting (void *) value returned by kcalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

You missed __user prefix. You can't cast user and kernel pointers implicitly.

Takashi

Quoted 37 lines
---
 sound/pci/emu10k1/emufx.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
sound/pci/emu10k1/emufx.c +5 -7
index 0275209..3f51dac 100644
@@ -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;
@@ -1815,10 +1814,9 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
 
 	if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
 		return -ENOMEM;
-	if ((icode->gpr_map = (u_int32_t __user *)
-	     kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
-		     GFP_KERNEL)) == NULL ||
-            (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
+	if ((icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
+				      GFP_KERNEL)) == NULL ||
+	    (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
 				sizeof(struct snd_emu10k1_fx8010_control_gpr),
 				GFP_KERNEL)) == NULL ||
 	    (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
Signature · 1 line
1.8.4
#2 lore raw

2013/10/16 Takashi Iwai <[email protected]>:

Quoted 6 lines

At Wed, 16 Oct 2013 13:21:45 -0300,

Quoted 4 lines · Geyslan G. Bem

Casting (void *) value returned by kcalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

Quoted 8 lines
Quoted 1 line

You missed __user prefix. You can't cast user and kernel pointers implicitly.

Takashi

Takashi,

My mistake, I'll fix that later.

Thank you.

Quoted 37 lines
Quoted 37 lines
---
 sound/pci/emu10k1/emufx.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
sound/pci/emu10k1/emufx.c +5 -8
index 0275209..3f51dac 100644
@@ -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;
@@ -1815,10 +1814,9 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
 
      if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
              return -ENOMEM;
-     if ((icode->gpr_map = (u_int32_t __user *)
-          kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
-                  GFP_KERNEL)) == NULL ||
-            (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
+     if ((icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
+                                   GFP_KERNEL)) == NULL ||
+         (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
                              sizeof(struct snd_emu10k1_fx8010_control_gpr),
                              GFP_KERNEL)) == NULL ||
          (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
--

1.8.4

#3 lore raw

2013/10/16 Geyslan Gregório Bem <[email protected]>:

Quoted 13 lines

2013/10/16 Takashi Iwai <[email protected]>:

Quoted 12 lines

At Wed, 16 Oct 2013 13:21:45 -0300,

Quoted 5 lines · Geyslan G. Bem

Casting (void *) value returned by kcalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

You missed __user prefix. You can't cast user and kernel pointers implicitly.

Quoted 8 lines
Quoted 2 lines

Takashi

Takashi,

My mistake, I'll fix that later.

Thank you.

I sent a substitute patch:
[PATCH] sound: pci: emu10k1: code refactoring and casting removal

Thank you.

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
---
 sound/pci/emu10k1/emufx.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
sound/pci/emu10k1/emufx.c +5 -8
index 0275209..3f51dac 100644
@@ -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;
@@ -1815,10 +1814,9 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
 
      if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
              return -ENOMEM;
-     if ((icode->gpr_map = (u_int32_t __user *)
-          kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
-                  GFP_KERNEL)) == NULL ||
-            (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
+     if ((icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
+                                   GFP_KERNEL)) == NULL ||
+         (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
                              sizeof(struct snd_emu10k1_fx8010_control_gpr),
                              GFP_KERNEL)) == NULL ||
          (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
--

1.8.4