Commit 90f5dfcc6afafcc3e1c18298143c1213b071990d

Authored by Julia Lawall
Committed by David S. Miller
1 parent 662f44af63

drivers/net: Remove redundant test

In each case, ap is checked not to be NULL a few lines before.

A simplified version of the semantic patch that makes this change is as
follows: (http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
expression E;
position p1,p2;
@@

if (x@p1 == NULL || ...) { ... when forall
   return ...; }
... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\)
(
x@p2 == NULL
|
x@p2 != NULL
)

// another path to the test that is not through p1?
@s exists@
local idexpression r.x;
position r.p1,r.p2;
@@

... when != x@p1
(
x@p2 == NULL
|
x@p2 != NULL
)

@fix depends on !s@
position r.p1,r.p2;
expression x,E;
statement S1,S2;
@@

(
- if ((x@p2 != NULL) || ...)
  S1
|
- if ((x@p2 == NULL) && ...) S1
|
- BUG_ON(x@p2 == NULL);
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 0 additions and 12 deletions Side-by-side Diff

drivers/net/ppp_async.c
... ... @@ -293,9 +293,6 @@
293 293 err = -EFAULT;
294 294 switch (cmd) {
295 295 case PPPIOCGCHAN:
296   - err = -ENXIO;
297   - if (!ap)
298   - break;
299 296 err = -EFAULT;
300 297 if (put_user(ppp_channel_index(&ap->chan), p))
301 298 break;
... ... @@ -303,9 +300,6 @@
303 300 break;
304 301  
305 302 case PPPIOCGUNIT:
306   - err = -ENXIO;
307   - if (!ap)
308   - break;
309 303 err = -EFAULT;
310 304 if (put_user(ppp_unit_number(&ap->chan), p))
311 305 break;
drivers/net/ppp_synctty.c
... ... @@ -333,9 +333,6 @@
333 333 err = -EFAULT;
334 334 switch (cmd) {
335 335 case PPPIOCGCHAN:
336   - err = -ENXIO;
337   - if (!ap)
338   - break;
339 336 err = -EFAULT;
340 337 if (put_user(ppp_channel_index(&ap->chan), p))
341 338 break;
... ... @@ -343,9 +340,6 @@
343 340 break;
344 341  
345 342 case PPPIOCGUNIT:
346   - err = -ENXIO;
347   - if (!ap)
348   - break;
349 343 err = -EFAULT;
350 344 if (put_user(ppp_unit_number(&ap->chan), p))
351 345 break;