All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6/11] drivers/net/hamradio: Move a dereference below a NULL test
@ 2008-12-16 15:13 ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2008-12-16 15:13 UTC (permalink / raw)
  To: jgarzik, netdev, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

In each case, 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>

---
 drivers/net/hamradio/mkiss.c        |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index b8e25c4..e5770d1 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -847,12 +847,13 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
 	unsigned int cmd, unsigned long arg)
 {
 	struct mkiss *ax = mkiss_get(tty);
-	struct net_device *dev = ax->dev;
+	struct net_device *dev;
 	unsigned int tmp, err;
 
 	/* First make sure we're connected. */
 	if (ax == NULL)
 		return -ENXIO;
+	dev = ax->dev;
 
 	switch (cmd) {
  	case SIOCGIFNAME:

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 6/11] drivers/net/hamradio: Move a dereference below a NULL
@ 2008-12-16 15:13 ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2008-12-16 15:13 UTC (permalink / raw)
  To: jgarzik, netdev, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

In each case, 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>

---
 drivers/net/hamradio/mkiss.c        |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index b8e25c4..e5770d1 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -847,12 +847,13 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
 	unsigned int cmd, unsigned long arg)
 {
 	struct mkiss *ax = mkiss_get(tty);
-	struct net_device *dev = ax->dev;
+	struct net_device *dev;
 	unsigned int tmp, err;
 
 	/* First make sure we're connected. */
 	if (ax = NULL)
 		return -ENXIO;
+	dev = ax->dev;
 
 	switch (cmd) {
  	case SIOCGIFNAME:

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 6/11] drivers/net/hamradio: Move a dereference below a NULL test
  2008-12-16 15:13 ` [PATCH 6/11] drivers/net/hamradio: Move a dereference below a NULL Julia Lawall
@ 2008-12-16 23:43   ` David Miller
  -1 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2008-12-16 23:43 UTC (permalink / raw)
  To: julia; +Cc: jgarzik, netdev, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>
Date: Tue, 16 Dec 2008 16:13:50 +0100 (CET)

> In each case, 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:
 ...
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied to net-next-2.6


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 6/11] drivers/net/hamradio: Move a dereference below a
@ 2008-12-16 23:43   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2008-12-16 23:43 UTC (permalink / raw)
  To: julia; +Cc: jgarzik, netdev, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>
Date: Tue, 16 Dec 2008 16:13:50 +0100 (CET)

> In each case, 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:
 ...
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied to net-next-2.6


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-12-16 23:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-16 15:13 [PATCH 6/11] drivers/net/hamradio: Move a dereference below a NULL test Julia Lawall
2008-12-16 15:13 ` [PATCH 6/11] drivers/net/hamradio: Move a dereference below a NULL Julia Lawall
2008-12-16 23:43 ` [PATCH 6/11] drivers/net/hamradio: Move a dereference below a NULL test David Miller
2008-12-16 23:43   ` [PATCH 6/11] drivers/net/hamradio: Move a dereference below a David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.