V4L/DVB (13949): Move a dereference below a NULL test
authorJulia Lawall <julia@diku.dk>
Tue, 22 Dec 2009 21:00:07 +0000 (18:00 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 26 Feb 2010 18:10:33 +0000 (15:10 -0300)
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;
identifier i,fld;
statement S;
@@

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

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/dvb-usb/dw2102.c

index 83a35524a82a9138eb7285a2c5ba7805980836d7..accc65509b071685f254b0e01a52cc1451481eb2 100644 (file)
@@ -470,12 +470,13 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                                                int num)
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
-       struct usb_device *udev = d->udev;
+       struct usb_device *udev;
        int ret = 0;
        int len, i, j;
 
        if (!d)
                return -ENODEV;
+       udev = d->udev;
        if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
                return -EAGAIN;