Skip to content

Commit

Permalink
drivers/net: Move a dereference below a NULL test
Browse files Browse the repository at this point in the history
If the NULL test is necessary, then the dereference should be moved below
the NULL test.

The semantic patch that makes this change 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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Julia Lawall authored and David S. Miller committed Jul 21, 2009
1 parent 0021195 commit 0376d5b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/bnx2x_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -4212,13 +4212,14 @@ static void bnx2x_turn_off_sf(struct bnx2x *bp, u8 port)
u8 bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 driver_loaded,
u8 *version, u16 len)
{
struct bnx2x *bp = params->bp;
struct bnx2x *bp;
u32 ext_phy_type = 0;
u32 spirom_ver = 0;
u8 status = 0 ;

if (version == NULL || params == NULL)
return -EINVAL;
bp = params->bp;

spirom_ver = REG_RD(bp, params->shmem_base +
offsetof(struct shmem_region,
Expand Down

0 comments on commit 0376d5b

Please sign in to comment.