Skip to content

Commit

Permalink
USB: storage: Drop an unneeded a NULL test
Browse files Browse the repository at this point in the history
In each case, the NULL test is not necessary because the function is static
and at the only places where it is called, the us argument has already been
dereferenced.

The semantic patch that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
type T;
expression E,E1;
identifier i,fld;
statement S;
@@

- T i = E->fld;
+ T i;
  ... when != E=E1
      when != i
  if (E == NULL||...) S
+ i = E->fld;
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Julia Lawall authored and Greg Kroah-Hartman committed Sep 23, 2009
1 parent 981e60f commit 64aebe7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/usb/storage/datafab.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static int datafab_determine_lun(struct us_data *us,
unsigned char *buf;
int count = 0, rc;

if (!us || !info)
if (!info)
return USB_STOR_TRANSPORT_ERROR;

memcpy(command, scommand, 8);
Expand Down Expand Up @@ -399,7 +399,7 @@ static int datafab_id_device(struct us_data *us,
unsigned char *reply;
int rc;

if (!us || !info)
if (!info)
return USB_STOR_TRANSPORT_ERROR;

if (info->lun == -1) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/storage/jumpshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ static int jumpshot_id_device(struct us_data *us,
unsigned char *reply;
int rc;

if (!us || !info)
if (!info)
return USB_STOR_TRANSPORT_ERROR;

command[0] = 0xE0;
Expand Down

0 comments on commit 64aebe7

Please sign in to comment.