Skip to contentSkip to conversation

fs: cifs: remove unused variable.

PATCH Applied Cyril Roelandt 2 participants 2 messages Apr 3, 2014 – Apr 4, 2014 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: cifs: remove unused variable.

In SMB2_set_compression(), the "res_key" variable is only initialized to NULL and later kfreed. It is therefore useless and should be removed.

Found with the following semantic patch:

<smpl>
@@
identifier foo;
identifier f;
type T;
@@
* f(...) {
...
* T *foo = NULL;
... when forall

    when != foo

* kfree(foo);
...
}
</smpl>

---
 fs/cifs/smb2pdu.c | 2 --
 1 file changed, 2 deletions(-)
fs/cifs/smb2pdu.c +0 -2
index 8603447..3802f8c 100644
@@ -1352,7 +1352,6 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
 		     u64 persistent_fid, u64 volatile_fid)
 {
 	int rc;
-	char *res_key = NULL;
 	struct  compress_ioctl fsctl_input;
 	char *ret_data = NULL;
 
@@ -1365,7 +1364,6 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
 			2 /* in data len */, &ret_data /* out data */, NULL);
 
 	cifs_dbg(FYI, "set compression rc %d\n", rc);
-	kfree(res_key);
 
 	return rc;
 }
Signature · 1 line
1.9.1
Applied
#2 lore raw
In reply to a message not in the archive

merged into cifs-2.6.git for-next

Quoted 49 lines · Cyril Roelandt

In SMB2_set_compression(), the "res_key" variable is only initialized to NULL and later kfreed. It is therefore useless and should be removed.

Found with the following semantic patch:

<smpl>
@@
identifier foo;
identifier f;
type T;
@@
* f(...) {
...
* T *foo = NULL;
... when forall

    when != foo

* kfree(foo);
...
}
</smpl>

---
 fs/cifs/smb2pdu.c | 2 --
 1 file changed, 2 deletions(-)
fs/cifs/smb2pdu.c +0 -3
index 8603447..3802f8c 100644
@@ -1352,7 +1352,6 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
                     u64 persistent_fid, u64 volatile_fid)
 {
        int rc;
-       char *res_key = NULL;
        struct  compress_ioctl fsctl_input;
        char *ret_data = NULL;
 
@@ -1365,7 +1364,6 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
                        2 /* in data len */, &ret_data /* out data */, NULL);
 
        cifs_dbg(FYI, "set compression rc %d\n", rc);
-       kfree(res_key);
 
        return rc;
 }
--

1.9.1

Signature · 3 lines
Thanks,

Steve