Skip to contentSkip to conversation

drivers/staging/vt6655/iwctl.c fix a sparse warning

PATCH Superseded Jimmy Li 4 participants 5 messages Mar 26, 2014 – Apr 3, 2014 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jimmy Li

author
#0 lore raw

PATCH 1/1 drivers/staging/vt6655/iwctl.c fix a sparse warning

fix a sparse warning. drivers/staging/vt6655/iwctl.c:1846:35: warning: cast from restricted gfp_t
drivers/staging/vt6655/iwctl.c:1846:35: warning: incorrect type in argument 2 (different base types)
drivers/staging/vt6655/iwctl.c:1846:35: expected restricted gfp_t
[usertype] flags
drivers/staging/vt6655/iwctl.c:1846:35: got int [signed] <noident>

---
 drivers/staging/vt6655/iwctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vt6655/iwctl.c +1 -1
index ac3fc16..5e25535 100644
@@ -1843,7 +1843,7 @@ int iwctl_siwencodeext(struct net_device *dev,
 	PRINT_K("SIOCSIWENCODEEXT...... \n");
 
 	blen = sizeof(*param);
-	buf = kmalloc((int)blen, (int)GFP_KERNEL);
+	buf = kmalloc((int)blen, GFP_KERNEL);
 	if (buf == NULL)
 		return -ENOMEM;
 	memset(buf, 0, blen);
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 8 lines · Jimmy Li

fix a sparse warning. drivers/staging/vt6655/iwctl.c:1846:35: warning: cast from restricted gfp_t
drivers/staging/vt6655/iwctl.c:1846:35: warning: incorrect type in argument 2 (different base types)
drivers/staging/vt6655/iwctl.c:1846:35: expected restricted gfp_t
[usertype] flags
drivers/staging/vt6655/iwctl.c:1846:35: got int [signed] <noident>

In the future, please don't line-wrap error/warning messages like this.

Quoted 21 lines
---
 drivers/staging/vt6655/iwctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vt6655/iwctl.c +1 -1
index ac3fc16..5e25535 100644
@@ -1843,7 +1843,7 @@ int iwctl_siwencodeext(struct net_device *dev,
 	PRINT_K("SIOCSIWENCODEEXT...... \n");
 
 	blen = sizeof(*param);
-	buf = kmalloc((int)blen, (int)GFP_KERNEL);
+	buf = kmalloc((int)blen, GFP_KERNEL);
 	if (buf == NULL)
 		return -ENOMEM;
 	memset(buf, 0, blen);
Signature · 1 line
1.7.10.4

Thanks, I'll queue this up after 3.15-rc1 is out, as my tree is currently closed.

greg k-h

#2 lore raw
In reply to Jimmy Li
Quoted 1 line · Jimmy Li

fix a sparse warning.

[]

drivers/staging/vt6655/iwctl.c

Quoted 1 line
drivers/staging/vt6655/iwctl.c +0 -0

[]

drivers/staging/vt6655/iwctl.c int iwctl_siwencodeext(struct net_device *dev,

Quoted 1 line
drivers/staging/vt6655/iwctl.c +0 -0
@@ -1843,7 +1843,7 @@ int iwctl_siwencodeext(struct net_device *dev,

[]

drivers/staging/vt6655/iwctl.c int iwctl_siwencodeext(struct net_device *dev, · line 1849

Quoted 6 lines
drivers/staging/vt6655/iwctl.c +1 -1
 	blen = sizeof(*param);
-	buf = kmalloc((int)blen, (int)GFP_KERNEL);
+	buf = kmalloc((int)blen, GFP_KERNEL);
 	if (buf == NULL)
 		return -ENOMEM;
 	memset(buf, 0, blen);

Ideally, this would be

	buf = kzalloc(sizeof(*param), GFP_KERNEL);
	if (!buf)
		return -ENOMEM;

removing the now unused blen variable declaration
and without the now unnecessary memset

author
#3 lore raw
In reply to Jimmy Li
Quoted 30 lines · Jimmy Li

fix a sparse warning. drivers/staging/vt6655/iwctl.c:1846:35: warning: cast from restricted gfp_t
drivers/staging/vt6655/iwctl.c:1846:35: warning: incorrect type in argument 2 (different base types)
drivers/staging/vt6655/iwctl.c:1846:35: expected restricted gfp_t
[usertype] flags
drivers/staging/vt6655/iwctl.c:1846:35: got int [signed] <noident>

---
 drivers/staging/vt6655/iwctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vt6655/iwctl.c +1 -1
index ac3fc16..5e25535 100644
@@ -1843,7 +1843,7 @@ int iwctl_siwencodeext(struct net_device *dev,
 	PRINT_K("SIOCSIWENCODEEXT...... \n");
 
 	blen = sizeof(*param);
-	buf = kmalloc((int)blen, (int)GFP_KERNEL);
+	buf = kmalloc((int)blen, GFP_KERNEL);
 	if (buf == NULL)
 		return -ENOMEM;
 	memset(buf, 0, blen);
Signature · 1 line
1.7.10.4

You are right, I found that variable buf also don't make sense here, maybe this could be more clear.

    param = kzalloc(sizeof(struct viawget_wpa_param), GFP_KERNEL);
    if (param == NULL)
        return -ENOMEM;

removing two unnecessary variable, buf and blen.

In this situation, I should send a new patch v2 for it base on the previous path? or send a new patch include all changes?

#4 lore raw
Quoted 11 lines · Jimmy Li

You are right, I found that variable buf also don't make sense here, maybe this could be more clear.

    param = kzalloc(sizeof(struct viawget_wpa_param), GFP_KERNEL);
    if (param == NULL)
        return -ENOMEM;

removing two unnecessary variable, buf and blen.

In this situation, I should send a new patch v2 for it base on the previous path? or send a new patch include all changes?

We throw away the original patch and you send a v2. Use the subject:

[PATCH v2] drivers/staging/vt6655/iwctl.c fix a sparse warning

Under the Signed-off-by line put:
Signed-off-by: you
---
v2: additional cleanups as well.

regards,
dan carpenter