All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] Remove unnecessary null pointer checks?
@ 2014-02-21 21:52 SF Markus Elfring
  2014-02-21 22:27 ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-21 21:52 UTC (permalink / raw)
  To: cocci

Hello,

I have tried the following short semantic patch out on a source file directory
for Linux 3.13.1.

@Remove_unnecessary_pointer_checks@
expression x;
@@
-if (x)
    kfree(x);


Some update candidates were found. I imagine that this search pattern can be
extended a bit more.
How do think about the applicability of corresponding changes for current kernel
source code?
What will be a good way to discuss such fixes on other mailing lists eventually?

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-21 21:52 [Cocci] Remove unnecessary null pointer checks? SF Markus Elfring
@ 2014-02-21 22:27 ` Julia Lawall
  2014-02-22  8:09   ` SF Markus Elfring
                     ` (2 more replies)
  0 siblings, 3 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-21 22:27 UTC (permalink / raw)
  To: cocci

On Fri, 21 Feb 2014, SF Markus Elfring wrote:

> Hello,
> 
> I have tried the following short semantic patch out on a source file directory
> for Linux 3.13.1.
> 
> @Remove_unnecessary_pointer_checks@
> expression x;
> @@
> -if (x)
>     kfree(x);
> 
> 
> Some update candidates were found. I imagine that this search pattern can be
> extended a bit more.

Not sure what you mean by extended.  There are indeed some other functions 
in Linux that perform NULL tests before doing anything, and thus they 
don't really need a null test around them.  Actually, it could be possible 
to find such functions using Coccinelle.

On the other hand, I think that one should study the code carefully before 
making such a change.  There are several ways to make error handling code.  
One is to have one label at the end of the function, to have all error 
cases jump to there, and then to have if tests to decide what should be 
done.  Another way is to have lots of labels, and jump directly to the 
right place, without any tests.

I think that the second way is nicer.  So in removing such an if, one can 
consider whether the code could be further improved by adding more labels, 
and jumping to the right place directly, rather tha executing unnecessary 
code.

> How do think about the applicability of corresponding changes for current kernel
> source code?
> What will be a good way to discuss such fixes on other mailing lists eventually?

If you want to propose Linux related fixes, you may want to look at the 
kernel janitors mailing list.

http://vger.kernel.org/vger-lists.html#kernel-janitors

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-21 22:27 ` Julia Lawall
@ 2014-02-22  8:09   ` SF Markus Elfring
  2014-02-22 12:36     ` Julia Lawall
  2014-02-23 14:40   ` SF Markus Elfring
  2014-03-27 13:41   ` [Cocci] How to exclude volatile data accesses in expressions with SmPL? SF Markus Elfring
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-22  8:09 UTC (permalink / raw)
  To: cocci

> Not sure what you mean by extended.

I have tried the following search pattern.

@Show_functions_with_input_pointer_validation@
identifier fun, x;
type t;
@@
*fun(..., t* x, ...)
 {
  ...
  if (!x) return;
  ...
 }


Will your current tool version "1.0.0-rc20" find also the kfree() functions?
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/mm/slab.c#n3641

Should I add any variant of "unlikely(ZERO_OR_NULL_PTR(...))" to my filter
pattern eventually?


> If you want to propose Linux related fixes, you may want to look at the 
> kernel janitors mailing list.

Would it make sense to add the shown semantic patches to a specific script
directory?
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/scripts/coccinelle

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-22  8:09   ` SF Markus Elfring
@ 2014-02-22 12:36     ` Julia Lawall
  2014-02-22 18:01       ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-02-22 12:36 UTC (permalink / raw)
  To: cocci

On Sat, 22 Feb 2014, SF Markus Elfring wrote:

> > Not sure what you mean by extended.
> 
> I have tried the following search pattern.
> 
> @Show_functions_with_input_pointer_validation@
> identifier fun, x;
> type t;
> @@
> *fun(..., t* x, ...)
>  {
>   ...
>   if (!x) return;
>   ...
>  }
> 
> 
> Will your current tool version "1.0.0-rc20" find also the kfree() functions?
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/mm/slab.c#n3641
> 
> Should I add any variant of "unlikely(ZERO_OR_NULL_PTR(...))" to my filter
> pattern eventually?

If you want to match a call to ZERO_OR_NULL_PTR, then you need to include 
that in the semantic patch.  Coccinelle does not expand macros, so if 
doesn't see the relation to a NULL test.

> > If you want to propose Linux related fixes, you may want to look at the 
> > kernel janitors mailing list.
> 
> Would it make sense to add the shown semantic patches to a specific script
> directory?
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/scripts/coccinelle

Not sure to understand what the "shown semantic patches" refers to.  What 
you have proposed is a semntic patch that finds functions that test their 
argument for NULL and return if the test is satisfied.  That gives the 
user some information, but the rules in the Linux kernel are for finding 
bugs or making transformations.

Personally, I rather like null tests, if they are really needed, ie not 
implied to be always false by the context, because they give some 
information, eg that the value can be null at this point, and it is 
important to take that into account when considerin the following 
operation.  So I'm not very eager to go around removing them.

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-22 12:36     ` Julia Lawall
@ 2014-02-22 18:01       ` SF Markus Elfring
  2014-10-26  6:07         ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-22 18:01 UTC (permalink / raw)
  To: cocci

> If you want to match a call to ZERO_OR_NULL_PTR, then you need to include 
> that in the semantic patch.  Coccinelle does not expand macros, so if 
> doesn't see the relation to a NULL test.

I have tried a command like the following a moment ago.

elfring at Sonne:~/Projekte/Coccinelle/janitor>
MY_PATTERN=find_input_pointer_validation2.cocci && cat $MY_PATTERN && echo
'-----' && spatch --version && spatch --sp-file $MY_PATTERN
/usr/src/linux-stable/mm/slab.c --recursive-includes -I
/usr/src/linux-stable/include/linux -I /usr/src/linux-stable/include/uapi -I
/usr/src/linux-stable/arch/ia64/include -I
/usr/src/linux-stable/include/asm-generic -I
/usr/src/linux-stable/include/asm-generic/bitops -I /usr/local/include/c++/4.8.2
-I /usr/local/include/c++/4.8.2/x86_64-unknown-linux-gnu -I /usr/local/include
-I /usr/include
@Show_functions_with_input_pointer_validation@
identifier fun, x;
type t;
@@
*void fun(..., t* x, ...)
 {
  ...
  if (unlikely(ZERO_OR_NULL_PTR(x)))
     return;
  ...
 }
-----
spatch version 1.0.0-rc20 with Python support and with PCRE support
init_defs_builtins: ...
(ONCE) TYPE: header trace/events/kmem.h not found

previous modification:
MINUS
According to environment 2:
   Show_functions_with_input_pointer_validation.t -> const
void
   Show_functions_with_input_pointer_validation.fun -> id kfree

current modification:
MINUS
According to environment 2:
   Show_functions_with_input_pointer_validation.t -> const void
   Show_functions_with_input_pointer_validation.fun -> id kfree

Fatal error: exception Failure("Show_functions_with_input_pointer_validation:
already tagged token:
C code context
File "/usr/src/linux-stable/mm/slab.c", line 3650, column 11,  charpos = 94972
    around = 'const', whole content = void kfree(const void *objp)")



How can I achieve a better result here?



> What you have proposed is a semntic patch that finds functions that test
> their argument for NULL and return if the test is satisfied.  That gives
> the user some information, but the rules in the Linux kernel are for finding 
> bugs or making transformations.

I try to collect all names for functions which handle passed null pointers in a
known way. I hope that such a function list can be converted into a constraint
for a metavariable in another semantic patch variant.

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-21 22:27 ` Julia Lawall
  2014-02-22  8:09   ` SF Markus Elfring
@ 2014-02-23 14:40   ` SF Markus Elfring
  2014-02-23 15:37     ` Julia Lawall
  2014-03-27 13:41   ` [Cocci] How to exclude volatile data accesses in expressions with SmPL? SF Markus Elfring
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-23 14:40 UTC (permalink / raw)
  To: cocci

> Not sure what you mean by extended.

I would also like to try another source code search approach like the following.

elfring at Sonne:~/Projekte/Coccinelle/janitor> LINE='-----' && echo $LINE &&
PAT=list_input_parameter_validation1.cocci && cat $PAT && echo $LINE &&
SP=/usr/local/bin/spatch && $SP --version && $SP --sp-file $PAT
/usr/src/linux-stable/fs/btrfs/extent_map.c
-----
@initialize:python@
@@
import sys
result = []
mark = ['"', '', '"']
delimiter = '|'

def store_positions(fun, typ, point, places):
    """Add source code positions to an internal list."""
    for place in places:
        fields = []
        fields.append(fun)

        mark[1] = typ
        fields.append(''.join(mark))

        fields.append(point)

        mark[1] = place.file.replace('"', '""')
        fields.append(''.join(mark))

        fields.append(place.line)
        fields.append(str(int(place.column) + 1))
        result.append(delimiter.join(fields))

@safety_check@
identifier work, input;
type data_type;
position pos;
@@
 void work at pos(...,data_type input,...)
 {
  ...
(
  if (!input) return;
|
  if (input) { ... }
|
  if (input) { ... } else { ... }
|
  switch (input) { case 0: return; ... }
)
  ...
 }

@script:python collection depends on safety_check@
typ << safety_check.data_type;
fun << safety_check.work;
point << safety_check.input;
places << safety_check.pos;
@@
store_positions(fun, typ, point, places)

@finalize:python@
@@
if result:
   result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
'"source file"', "line", "column")))
   print("\r\n".join(result))
else:
   sys.stderr.write("No result for this analysis!\n")
-----
spatch version 1.0.0-rc20 with Python support and with PCRE support
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: /usr/src/linux-stable/fs/btrfs/extent_map.c
No result for this analysis!


Why is the function "free_extent_map" not displayed here?
Do I need to adjust my SmPL rule "safety_check" anyhow?

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-23 14:40   ` SF Markus Elfring
@ 2014-02-23 15:37     ` Julia Lawall
  2014-02-23 16:33       ` SF Markus Elfring
                         ` (2 more replies)
  0 siblings, 3 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-23 15:37 UTC (permalink / raw)
  To: cocci

Something goes wrong with the switch pattern.  I would have to look into 
why.  But I think that a switch is highly improbable for making such a 
test, so you could just drop it.  You may also want to specify that input 
has pointer type, since you are actually looking for NULL tests, not zero 
tests.

julia

On Sun, 23 Feb 2014, SF Markus Elfring wrote:

> > Not sure what you mean by extended.
> 
> I would also like to try another source code search approach like the following.
> 
> elfring at Sonne:~/Projekte/Coccinelle/janitor> LINE='-----' && echo $LINE &&
> PAT=list_input_parameter_validation1.cocci && cat $PAT && echo $LINE &&
> SP=/usr/local/bin/spatch && $SP --version && $SP --sp-file $PAT
> /usr/src/linux-stable/fs/btrfs/extent_map.c
> -----
> @initialize:python@
> @@
> import sys
> result = []
> mark = ['"', '', '"']
> delimiter = '|'
> 
> def store_positions(fun, typ, point, places):
>     """Add source code positions to an internal list."""
>     for place in places:
>         fields = []
>         fields.append(fun)
> 
>         mark[1] = typ
>         fields.append(''.join(mark))
> 
>         fields.append(point)
> 
>         mark[1] = place.file.replace('"', '""')
>         fields.append(''.join(mark))
> 
>         fields.append(place.line)
>         fields.append(str(int(place.column) + 1))
>         result.append(delimiter.join(fields))
> 
> @safety_check@
> identifier work, input;
> type data_type;
> position pos;
> @@
>  void work at pos(...,data_type input,...)
>  {
>   ...
> (
>   if (!input) return;
> |
>   if (input) { ... }
> |
>   if (input) { ... } else { ... }
> |
>   switch (input) { case 0: return; ... }
> )
>   ...
>  }
> 
> @script:python collection depends on safety_check@
> typ << safety_check.data_type;
> fun << safety_check.work;
> point << safety_check.input;
> places << safety_check.pos;
> @@
> store_positions(fun, typ, point, places)
> 
> @finalize:python@
> @@
> if result:
>    result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
> '"source file"', "line", "column")))
>    print("\r\n".join(result))
> else:
>    sys.stderr.write("No result for this analysis!\n")
> -----
> spatch version 1.0.0-rc20 with Python support and with PCRE support
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: /usr/src/linux-stable/fs/btrfs/extent_map.c
> No result for this analysis!
> 
> 
> Why is the function "free_extent_map" not displayed here?
> Do I need to adjust my SmPL rule "safety_check" anyhow?
> 
> Regards,
> Markus
> 

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-23 15:37     ` Julia Lawall
@ 2014-02-23 16:33       ` SF Markus Elfring
  2014-02-23 16:42         ` Julia Lawall
  2014-02-23 22:14       ` SF Markus Elfring
  2014-11-28 16:00       ` [Cocci] Remove unnecessary null pointer checks? SF Markus Elfring
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-23 16:33 UTC (permalink / raw)
  To: cocci

> Something goes wrong with the switch pattern. I would have to look into why.

Thanks for your quick feedback.


> But I think that a switch is highly improbable for making such a test,
> so you could just drop it.

I just try to make the discussed filter patterns as complete as possible.


> You may also want to specify that input has pointer type, since you are
> actually looking for NULL tests, not zero tests.

This is an important implementation detail which I would like to generalise so
that also functions like "btrfsic_process_written_block" will be safely found by
further source code searches.
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/fs/btrfs/check-integrity.c?id=878a876b2e10888afe53766dcca33f723ae20edc#n1835

This one was found by the previous simple pattern for example despite I expected
it to handle primarily pointer data types instead of an "unsigned int" in this case.

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-23 16:33       ` SF Markus Elfring
@ 2014-02-23 16:42         ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-23 16:42 UTC (permalink / raw)
  To: cocci

> > You may also want to specify that input has pointer type, since you are
> > actually looking for NULL tests, not zero tests.
> 
> This is an important implementation detail which I would like to generalise so
> that also functions like "btrfsic_process_written_block" will be safely found by
> further source code searches.
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/fs/btrfs/check-integrity.c?id=878a876b2e10888afe53766dcca33f723ae20edc#n1835
> 
> This one was found by the previous simple pattern for example despite I expected
> it to handle primarily pointer data types instead of an "unsigned int" in this case.

As you like.  As a general principle, I think it is better to work on 
fewer things at once.  There are many reason why values may be null or 0, 
and if you lump too many of them together, you will end up with more 
information than is manageable.  No bugs are involved here, you are only 
making the code simpler, and if you miss some possibilities for making the 
code simpler, it doesn't matter.  You can just work on them later.

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-23 15:37     ` Julia Lawall
  2014-02-23 16:33       ` SF Markus Elfring
@ 2014-02-23 22:14       ` SF Markus Elfring
  2014-02-24  6:00         ` Julia Lawall
  2014-11-28 16:00       ` [Cocci] Remove unnecessary null pointer checks? SF Markus Elfring
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-23 22:14 UTC (permalink / raw)
  To: cocci

> But I think that a switch is highly improbable for making such a test,
> so you could just drop it.

I have got another idea for a bit of fine-tuning. I got the impression from the
manual that the SmPL syntax element "singleton" might be applicable.

elfring at Sonne:~/Projekte/Coccinelle/janitor> LINE='-----' && echo $LINE &&
PAT=list_input_parameter_validation2.cocci && cat $PAT && echo $LINE &&
SP=/usr/local/bin/spatch && $SP --version && $SP --sp-file $PAT
/usr/src/linux-stable/fs/btrfs/extent_map.c
-----


@initialize:python@
@@
import sys
result = []
mark = ['"', '', '"']
delimiter = '|'

def store_positions(fun, typ, point, places):
    """Add source code positions to an internal list."""
    for place in places:
        fields = []
        fields.append(fun)

        mark[1] = typ
        fields.append(''.join(mark))

        fields.append(point)

        mark[1] = place.file.replace('"', '""')
        fields.append(''.join(mark))

        fields.append(place.line)
        fields.append(str(int(place.column) + 1))
        result.append(delimiter.join(fields))

@safety_check@
identifier work, input;
type data_type;
position pos;
statement is, es;
@@
 void work at pos(...,data_type input,...)
 {
  ...
( if (!input) return;
| if (input) is
? else es
  ;
)
  ...
 }

@script:python collection depends on safety_check@
typ << safety_check.data_type;
fun << safety_check.work;
point << safety_check.input;
places << safety_check.pos;
@@
store_positions(fun, typ, point, places)

@finalize:python@
@@
if result:
   result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
'"source file"', "line", "column")))
   print("\r\n".join(result))
else:
   sys.stderr.write("No result for this analysis!\n")
-----
spatch version 1.0.0-rc20 with Python support and with PCRE support
init_defs_builtins: /usr/local/share/coccinelle/standard.h
warning: incompatible arity found on line 36
?safety_check:es
Fatal error: exception Failure("get_before_e: not supported")


Can this situation be improved?

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-23 22:14       ` SF Markus Elfring
@ 2014-02-24  6:00         ` Julia Lawall
  2014-02-24 10:55           ` SF Markus Elfring
  2014-02-24 15:05           ` SF Markus Elfring
  0 siblings, 2 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-24  6:00 UTC (permalink / raw)
  To: cocci

On Sun, 23 Feb 2014, SF Markus Elfring wrote:

> > But I think that a switch is highly improbable for making such a test,
> > so you could just drop it.
> 
> I have got another idea for a bit of fine-tuning. I got the impression from the
> manual that the SmPL syntax element "singleton" might be applicable.
> 
> elfring at Sonne:~/Projekte/Coccinelle/janitor> LINE='-----' && echo $LINE &&
> PAT=list_input_parameter_validation2.cocci && cat $PAT && echo $LINE &&
> SP=/usr/local/bin/spatch && $SP --version && $SP --sp-file $PAT
> /usr/src/linux-stable/fs/btrfs/extent_map.c

Please don't put all of this noise in your messages.  The only thing that 
is interesting is the file on which you have run Coccinelle.

> -----
> 
> 
> @initialize:python@
> @@
> import sys
> result = []
> mark = ['"', '', '"']
> delimiter = '|'
> 
> def store_positions(fun, typ, point, places):
>     """Add source code positions to an internal list."""
>     for place in places:
>         fields = []
>         fields.append(fun)
> 
>         mark[1] = typ
>         fields.append(''.join(mark))
> 
>         fields.append(point)
> 
>         mark[1] = place.file.replace('"', '""')
>         fields.append(''.join(mark))
> 
>         fields.append(place.line)
>         fields.append(str(int(place.column) + 1))
>         result.append(delimiter.join(fields))
> 
> @safety_check@
> identifier work, input;
> type data_type;
> position pos;
> statement is, es;
> @@
>  void work at pos(...,data_type input,...)
>  {
>   ...
> ( if (!input) return;
> | if (input) is
> ? else es
>   ;

There is no need to put the ? else es.  If you put if (intput) is else es 
then an isomorphism will consider the case where else es is not there.

Also, the semicolon after is/es does not look right.  Notmally one does 
not put an extra semicolon after an if.

julia

> )
>   ...
>  }
> 
> @script:python collection depends on safety_check@
> typ << safety_check.data_type;
> fun << safety_check.work;
> point << safety_check.input;
> places << safety_check.pos;
> @@
> store_positions(fun, typ, point, places)
> 
> @finalize:python@
> @@
> if result:
>    result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
> '"source file"', "line", "column")))
>    print("\r\n".join(result))
> else:
>    sys.stderr.write("No result for this analysis!\n")
> -----
> spatch version 1.0.0-rc20 with Python support and with PCRE support
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> warning: incompatible arity found on line 36
> ?safety_check:es
> Fatal error: exception Failure("get_before_e: not supported")
> 
> 
> Can this situation be improved?
> 
> Regards,
> Markus
> 
> 

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-24  6:00         ` Julia Lawall
@ 2014-02-24 10:55           ` SF Markus Elfring
  2014-02-24 11:22             ` Julia Lawall
  2014-02-24 15:05           ` SF Markus Elfring
  1 sibling, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-24 10:55 UTC (permalink / raw)
  To: cocci

> There is no need to put the ? else es.

Thanks for your explanation.

I get a "surprise" if I try out the following SmPL variant.

@safety_check@
identifier function, input;
type data_type;
position pos;
statement is, es;
@@
 void function at pos(...,data_type input,...)
 {
  ...
( if (!input) return;
| if (input) is else es
)
  ...
 }

@script:python collection depends on safety_check@
typ << safety_check.data_type;
fun << safety_check.function;
point << safety_check.input;
places << safety_check.pos;
@@
store_positions(fun, typ, point, places)


Response:
875 883
Fatal error: exception Failure("scriptmeta: parse error:
 = File "list_input_parameter_validation3.cocci", line 43, column 20,  charpos = 875
    around = 'function', whole content = fun << safety_check.function;


Can such names be reused which are key words@other places?

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-24 10:55           ` SF Markus Elfring
@ 2014-02-24 11:22             ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-24 11:22 UTC (permalink / raw)
  To: cocci

On Mon, 24 Feb 2014, SF Markus Elfring wrote:

> > There is no need to put the ? else es.
>
> Thanks for your explanation.
>
> I get a "surprise" if I try out the following SmPL variant.
>
> @safety_check@
> identifier function, input;
> type data_type;
> position pos;
> statement is, es;
> @@
>  void function at pos(...,data_type input,...)
>  {
>   ...
> ( if (!input) return;
> | if (input) is else es
> )
>   ...
>  }
>
> @script:python collection depends on safety_check@
> typ << safety_check.data_type;
> fun << safety_check.function;
> point << safety_check.input;
> places << safety_check.pos;
> @@
> store_positions(fun, typ, point, places)
>
>
> Response:
> 875 883
> Fatal error: exception Failure("scriptmeta: parse error:
>  = File "list_input_parameter_validation3.cocci", line 43, column 20,  charpos = 875
>     around = 'function', whole content = fun << safety_check.function;
>
>
> Can such names be reused which are key words at other places?

Apparently there is a problem in this case.  I will make a note of it.  In
the meantime, just use another name.

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-24  6:00         ` Julia Lawall
  2014-02-24 10:55           ` SF Markus Elfring
@ 2014-02-24 15:05           ` SF Markus Elfring
  2014-02-24 15:19             ` Julia Lawall
  2014-02-24 16:14             ` Julia Lawall
  1 sibling, 2 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-24 15:05 UTC (permalink / raw)
  To: cocci

> There is no need to put the ? else es.

I get the following result for the adjusted search pattern.

 void work at pos(...,data_type input,...)
 {
  ...
( if (!input) return;
| if (input) is else es
)
  ...
 }


elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch --sp-file
list_input_parameter_validation2.cocci /usr/src/linux-stable/arch/um/kernel/sysrq.c
...
function|"data type"|"parameter"|"source file"|line|column
show_stack|"unsigned long
*"|stack|"/usr/src/linux-stable/arch/um/kernel/sysrq.c"|67|6


This example does not fit to my expectation because it seems that the function
implementation does not refer to the passed values.
Do you get any idea for this potential mismatch?

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-24 15:05           ` SF Markus Elfring
@ 2014-02-24 15:19             ` Julia Lawall
  2014-02-24 15:58               ` SF Markus Elfring
  2014-02-24 16:14             ` Julia Lawall
  1 sibling, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-02-24 15:19 UTC (permalink / raw)
  To: cocci

On Mon, 24 Feb 2014, SF Markus Elfring wrote:

> > There is no need to put the ? else es.
>
> I get the following result for the adjusted search pattern.
>
>  void work at pos(...,data_type input,...)
>  {
>   ...
> ( if (!input) return;
> | if (input) is else es
> )
>   ...
>  }
>
>
> elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch --sp-file
> list_input_parameter_validation2.cocci /usr/src/linux-stable/arch/um/kernel/sysrq.c
> ...
> function|"data type"|"parameter"|"source file"|line|column
> show_stack|"unsigned long
> *"|stack|"/usr/src/linux-stable/arch/um/kernel/sysrq.c"|67|6
>
>
> This example does not fit to my expectation because it seems that the function
> implementation does not refer to the passed values.
> Do you get any idea for this potential mismatch?

I'm not sure, but I think it has to do with the fact that the entire
function is an if where both branches leave the function.  It seems to be
considering that to be error-handling code.  It does not require to find
the complete pattern on execution paths that correspond to error-handling
code.  So it doesn't require to find the pattern at all.

In your case, I think you want to be completely sure that regardless of
the execution path chosen, the test is performed.  So you should put when
string after the first ... (ie the one after the first { ).

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-24 15:19             ` Julia Lawall
@ 2014-02-24 15:58               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-24 15:58 UTC (permalink / raw)
  To: cocci

>> This example does not fit to my expectation because it seems that the function
>> implementation does not refer to the passed values.

I must correct my conclusion here. One function parameter is actually used in
the condition "!stack" while the second parameter is forwarded to other function
calls.
Is this source code line 83 handled by a SmPL isomorphism?


> In your case, I think you want to be completely sure that regardless of
> the execution path chosen, the test is performed.  So you should put when
> string after the first ... (ie the one after the first { ).

I'm sorry. I do not really understand your suggestion.

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-24 15:05           ` SF Markus Elfring
  2014-02-24 15:19             ` Julia Lawall
@ 2014-02-24 16:14             ` Julia Lawall
  2014-02-24 16:34               ` SF Markus Elfring
  2014-02-25  9:10               ` SF Markus Elfring
  1 sibling, 2 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-24 16:14 UTC (permalink / raw)
  To: cocci

On Mon, 24 Feb 2014, SF Markus Elfring wrote:

> > There is no need to put the ? else es.
>
> I get the following result for the adjusted search pattern.
>
>  void work at pos(...,data_type input,...)
>  {
>   ...
> ( if (!input) return;
> | if (input) is else es
> )
>   ...
>  }
>
>
> elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch --sp-file
> list_input_parameter_validation2.cocci /usr/src/linux-stable/arch/um/kernel/sysrq.c
> ...
> function|"data type"|"parameter"|"source file"|line|column
> show_stack|"unsigned long
> *"|stack|"/usr/src/linux-stable/arch/um/kernel/sysrq.c"|67|6
>
>
> This example does not fit to my expectation because it seems that the function
> implementation does not refer to the passed values.
> Do you get any idea for this potential mismatch?

Sorry, I had been looking at the wrong function when I wrote my previous
response.

Indeed, there are some uses of isomorphisms at work here.  First the

if (input) is else es

is changed to

if (!input) es else is

and then that is changed to

if (!input) es

which matches the code at line 83.

I'm not sure what is the point of the if (input) is else es pattern.  I
would think you only want to find cases where the function does nothing
until it tests input and aborts the function is the value is 0.  So you
only want the return case.  Before it, you would want

... when != S

where S is a statement typed metavariable.  That way the ... will only
match declarations.

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-24 16:14             ` Julia Lawall
@ 2014-02-24 16:34               ` SF Markus Elfring
  2014-02-25  9:10               ` SF Markus Elfring
  1 sibling, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-24 16:34 UTC (permalink / raw)
  To: cocci

> I'm not sure what is the point of the if (input) is else es pattern.

Now it seems that I added it because of too few considerations for isomorphisms.


> I would think you only want to find cases where the function does nothing
> until it tests input and aborts the function is the value is 0.  So you
> only want the return case.  Before it, you would want
> 
> ... when != S
> 
> where S is a statement typed metavariable.  That way the ... will only
> match declarations.

We have got different expectations about the amount of source code before the
statement "return". A bit more fine-tuning with the SmPL construct "when" might
be needed to achieve further constraints.

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-24 16:14             ` Julia Lawall
  2014-02-24 16:34               ` SF Markus Elfring
@ 2014-02-25  9:10               ` SF Markus Elfring
  2014-02-25  9:16                 ` Julia Lawall
  1 sibling, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-25  9:10 UTC (permalink / raw)
  To: cocci

>> This example does not fit to my expectation because it seems that the function
>> implementation does not refer to the passed values.

I'm sorry that I overlooked information somehow there.

The implementations of the function "show_stack" can be nice source code
examples for further fine-tuning of proposed filter patterns.
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/arch/um/kernel/sysrq.c?id=8ed12fcc194d93c6a17714120a7027ee4d76a881#n67

Its interface contains two pointer parameters.


> I'm not sure what is the point of the if (input) is else es pattern.

I can also adjust the search approach like the following.

@safety_check@
identifier work, input;
type data_type;
position pos;
statement is, es;
@@
 void work at pos(...,data_type input,...)
 {
  ...
( if (input) is
| if (likely(input)) is
)
  else es
  ...
 }


> I would think you only want to find cases where the function does nothing
> until it tests input and aborts the function is the value is 0.

I guess that the interpretation of "nothing relevant" will need further
considerations, won't it?


> So you only want the return case.

Not "only" this one ...

I have got a feeling for a need to introspect the else branch for useful
properties. I am unsure about better analysis of the metavariable "es" with the
semantic patch language.

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25  9:10               ` SF Markus Elfring
@ 2014-02-25  9:16                 ` Julia Lawall
  2014-02-25 10:01                   ` SF Markus Elfring
                                     ` (2 more replies)
  0 siblings, 3 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-25  9:16 UTC (permalink / raw)
  To: cocci

> I can also adjust the search approach like the following.
>
> @safety_check@
> identifier work, input;
> type data_type;
> position pos;
> statement is, es;
> @@
>  void work at pos(...,data_type input,...)
>  {
>   ...
> ( if (input) is
> | if (likely(input)) is
> )
>   else es

This is not allowed.  Inside a disjunction you need to have complete
terms.

>   ...
>  }
>
>
> > I would think you only want to find cases where the function does nothing
> > until it tests input and aborts the function is the value is 0.
>
> I guess that the interpretation of "nothing relevant" will need further
> considerations, won't it?
>
>
> > So you only want the return case.
>
> Not "only" this one ...
>
> I have got a feeling for a need to introspect the else branch for useful
> properties. I am unsure about better analysis of the metavariable "es" with the
> semantic patch language.

I'm not sure to understand your goal.  If the code currently has:

if (x != NULL)
   call(x);

then the developer does not want to execute any of the code within call if
x is NULL.  If you just check that there is a NULL test on x somewhere
within the definition of call, then that is not enough to ensure that
nothing is executed within call.  If you remove the NULL test, you could
drastically change the behavior of the program.

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25  9:16                 ` Julia Lawall
@ 2014-02-25 10:01                   ` SF Markus Elfring
  2014-02-25 17:28                   ` SF Markus Elfring
  2014-02-26  7:25                   ` [Cocci] Branch layout for if statements with SmPL disjunctions SF Markus Elfring
  2 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-25 10:01 UTC (permalink / raw)
  To: cocci

> This is not allowed.  Inside a disjunction you need to have complete terms.

Thanks for your information. I guess that another adjustment will fit to the
SmPL syntax then.

( if (input) is else es
| if (likely(input)) is else es
)


> I'm not sure to understand your goal.  If the code currently has:
> 
> if (x != NULL)
>    call(x);
> 
> then the developer does not want to execute any of the code within call if
> x is NULL.

Yes. - This is one of the use cases I am trying to improve. It depends on the
knowledge if something unwanted will happen if a null pointer (or zero) would be
passed. If it is documented for example that an implementation of the function
"call" checks the condition "!= NULL", I find the same check by the caller
redundant.


> If you just check that there is a NULL test on x somewhere within the definition
> of call, then that is not enough to ensure that nothing is executed within call.

Would you like to suggest any more fine-tuning?


> If you remove the NULL test, you could drastically change the behavior of the program.

I agree in principle.

But I would like to delete redundant checks from some source files.

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25  9:16                 ` Julia Lawall
  2014-02-25 10:01                   ` SF Markus Elfring
@ 2014-02-25 17:28                   ` SF Markus Elfring
  2014-02-25 17:42                     ` Julia Lawall
  2014-02-26  7:25                   ` [Cocci] Branch layout for if statements with SmPL disjunctions SF Markus Elfring
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-25 17:28 UTC (permalink / raw)
  To: cocci

> I'm not sure to understand your goal.

I get an interesting result for example if I try the following source code
search pattern out. Do you find it useful?

@Delete_unnecessary_checks@
expression x;
identifier release =~ "^(?x)
(?:
   (?:kz?|slob_)free
|
   (?:
      abc
   |  xyz
   )
)$";
@@
-if (x)
    release(...,x,...);

elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch --sp-file
delete_unnecessary_checks1.cocci /usr/src/linux-stable/fs/btrfs/inode.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: /usr/src/linux-stable/fs/btrfs/inode.c
diff =
--- /usr/src/linux-stable/fs/btrfs/inode.c
+++ /tmp/cocci-output-3740-5d95d8-inode.c
@@ -5137,8 +5137,7 @@ static int btrfs_dentry_delete(const str

 static void btrfs_dentry_release(struct dentry *dentry)
 {
-       if (dentry->d_fsdata)
-               kfree(dentry->d_fsdata);
+       kfree(dentry->d_fsdata);
 }


> If you remove the NULL test, you could drastically change the behavior
> of the program.

But it seems that I stumble on a software debug challenge after I replaced the
dummy alternation in the regular expression above by the real list of 5142
function names which were found by the other discussed pattern.

elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch --sp-file
delete_unnecessary_checks2.cocci /usr/src/linux-stable/fs/btrfs/inode.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
Fatal error: exception Pcre.Error(_)

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25 17:28                   ` SF Markus Elfring
@ 2014-02-25 17:42                     ` Julia Lawall
  2014-02-25 20:11                       ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-02-25 17:42 UTC (permalink / raw)
  To: cocci



On Tue, 25 Feb 2014, SF Markus Elfring wrote:

> > I'm not sure to understand your goal.
>
> I get an interesting result for example if I try the following source code
> search pattern out. Do you find it useful?
>
> @Delete_unnecessary_checks@
> expression x;
> identifier release =~ "^(?x)
> (?:
>    (?:kz?|slob_)free
> |
>    (?:
>       abc
>    |  xyz
>    )
> )$";
> @@
> -if (x)
>     release(...,x,...);
>
> elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch --sp-file
> delete_unnecessary_checks1.cocci /usr/src/linux-stable/fs/btrfs/inode.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: /usr/src/linux-stable/fs/btrfs/inode.c
> diff =
> --- /usr/src/linux-stable/fs/btrfs/inode.c
> +++ /tmp/cocci-output-3740-5d95d8-inode.c
> @@ -5137,8 +5137,7 @@ static int btrfs_dentry_delete(const str
>
>  static void btrfs_dentry_release(struct dentry *dentry)
>  {
> -       if (dentry->d_fsdata)
> -               kfree(dentry->d_fsdata);
> +       kfree(dentry->d_fsdata);
>  }
>
>
> > If you remove the NULL test, you could drastically change the behavior
> > of the program.
>
> But it seems that I stumble on a software debug challenge after I replaced the
> dummy alternation in the regular expression above by the real list of 5142
> function names which were found by the other discussed pattern.
>
> elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch --sp-file
> delete_unnecessary_checks2.cocci /usr/src/linux-stable/fs/btrfs/inode.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> Fatal error: exception Pcre.Error(_)

I don't think it is a good approach to do anything related to 5142
different functions at once.  It would be better to pick a small set of
functions, and work on them carefully.

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25 17:42                     ` Julia Lawall
@ 2014-02-25 20:11                       ` SF Markus Elfring
  2014-02-25 20:20                         ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-25 20:11 UTC (permalink / raw)
  To: cocci

> I don't think it is a good approach to do anything related to 5142
> different functions at once.

A source code search with the following pattern found only six functions for
further consideration.

@is_unnecessary_check@
expression data;
identifier work;
identifier release =~ "^kz?free$";
position pos;
type t;
@@
 t work at pos(...)
 {
  ...
( if (data) release(data);
| if (likely(data)) release(data);
)
  ...
 }


I wonder a bit about this analysis result because the SmPL pattern I started
this discussion thread with showed a few more update candidates.


> It would be better to pick a small set of functions, and work on them carefully.

I would prefer to handle a more complete fix pattern.

By the way: I read about corresponding software update approaches in an article
"Best practices for a big patch series" by Wolfram Sang.


How are the chances to resolve the message "Fatal error: exception
Pcre.Error(_)" with a proposed long alternation?

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25 20:11                       ` SF Markus Elfring
@ 2014-02-25 20:20                         ` Julia Lawall
  2014-02-25 20:37                           ` [Cocci] Source code analysis with big regular expressions? SF Markus Elfring
                                             ` (3 more replies)
  0 siblings, 4 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-25 20:20 UTC (permalink / raw)
  To: cocci

On Tue, 25 Feb 2014, SF Markus Elfring wrote:

> > I don't think it is a good approach to do anything related to 5142
> > different functions at once.
> 
> A source code search with the following pattern found only six functions for
> further consideration.
> 
> @is_unnecessary_check@
> expression data;
> identifier work;
> identifier release =~ "^kz?free$";
> position pos;
> type t;
> @@
>  t work at pos(...)
>  {
>   ...
> ( if (data) release(data);
> | if (likely(data)) release(data);
> )
>   ...
>  }
> 
> 
> I wonder a bit about this analysis result because the SmPL pattern I started
> this discussion thread with showed a few more update candidates.

Remember that ... matches the shortest path between what is before and 
what is after.  So if there is another if test on the same data in the 
function, that will cause a failure.  If yo udon't care to have this 
constraint, you can put when any on a ...

> > It would be better to pick a small set of functions, and work on them 
> > carefully.
> 
> I would prefer to handle a more complete fix pattern.

As you like, but I think that no Linux maintainer will accept a patch that 
makes more than a few changes, so doing them all at once is a waste of 
time.  Anyway, you would have to split up the patches according to 
maintainer.

> By the way: I read about corresponding software update approaches in an 
> article "Best practices for a big patch series" by Wolfram Sang.
> 
> 
> How are the chances to resolve the message "Fatal error: exception
> Pcre.Error(_)" with a proposed long alternation?

Pcre is a standard library.  I know nothing about its implementation.  But 
it is not surprising that a regular expression with over 5000 options 
exceeds its capacity.

julia

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

* [Cocci] Source code analysis with big regular expressions?
  2014-02-25 20:20                         ` Julia Lawall
@ 2014-02-25 20:37                           ` SF Markus Elfring
  2014-02-25 20:44                             ` Julia Lawall
  2014-02-25 21:44                           ` [Cocci] Remove unnecessary null pointer checks? SF Markus Elfring
                                             ` (2 subsequent siblings)
  3 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-25 20:37 UTC (permalink / raw)
  To: cocci

> Pcre is a standard library.  I know nothing about its implementation.
> But it is not surprising that a regular expression with over 5000 options 
> exceeds its capacity.

Are there any chances to find the source code place from which the exception
"Pcre.Error(_)" was thrown?

Regards,
Markus

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

* [Cocci] Source code analysis with big regular expressions?
  2014-02-25 20:37                           ` [Cocci] Source code analysis with big regular expressions? SF Markus Elfring
@ 2014-02-25 20:44                             ` Julia Lawall
  2014-02-25 20:54                               ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-02-25 20:44 UTC (permalink / raw)
  To: cocci



On Tue, 25 Feb 2014, SF Markus Elfring wrote:

> > Pcre is a standard library.  I know nothing about its implementation.
> > But it is not surprising that a regular expression with over 5000 options 
> > exceeds its capacity.
> 
> Are there any chances to find the source code place from which the exception
> "Pcre.Error(_)" was thrown?

Set the OCAMLRUNPARAM environment variable to b in your shell.  I don't 
know if it is necessary to recompile coccinelle.  Then when it crashes you 
will get a backtrace.

julia

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

* [Cocci] Source code analysis with big regular expressions?
  2014-02-25 20:44                             ` Julia Lawall
@ 2014-02-25 20:54                               ` SF Markus Elfring
  2014-02-25 21:02                                 ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-25 20:54 UTC (permalink / raw)
  To: cocci

> Set the OCAMLRUNPARAM environment variable to b in your shell.  I don't 
> know if it is necessary to recompile coccinelle.  Then when it crashes you 
> will get a backtrace.

elfring at Sonne:~/Projekte/Coccinelle/janitor> export OCAMLRUNPARAM=b && spatch
--sp-file delete_unnecessary_checks2.cocci
/usr/src/linux-stable/fs/btrfs/inode.cinit_defs_builtins:
/usr/local/share/coccinelle/standard.h
Fatal error: exception Pcre.Error(_)
Called from file "engine.ml", line 206, characters 1-27
Called from file "engine.ml", line 359, characters 23-36


How much can this information help us here?

Regards,
Markus

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

* [Cocci] Source code analysis with big regular expressions?
  2014-02-25 20:54                               ` SF Markus Elfring
@ 2014-02-25 21:02                                 ` Julia Lawall
  2014-02-25 21:19                                   ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-02-25 21:02 UTC (permalink / raw)
  To: cocci

On Tue, 25 Feb 2014, SF Markus Elfring wrote:

> > Set the OCAMLRUNPARAM environment variable to b in your shell.  I don't 
> > know if it is necessary to recompile coccinelle.  Then when it crashes you 
> > will get a backtrace.
> 
> elfring at Sonne:~/Projekte/Coccinelle/janitor> export OCAMLRUNPARAM=b && spatch
> --sp-file delete_unnecessary_checks2.cocci
> /usr/src/linux-stable/fs/btrfs/inode.cinit_defs_builtins:
> /usr/local/share/coccinelle/standard.h
> Fatal error: exception Pcre.Error(_)
> Called from file "engine.ml", line 206, characters 1-27
> Called from file "engine.ml", line 359, characters 23-36
> 
> 
> How much can this information help us here?

Those two lines at least are not from Coccinelle, so I guess that they are 
from the PCRE implementation.  But I don't think there is anything to do.  
The regular expression engine is just not likely to be designed to support 
such a large regular expression.

If you like you can give each of the function names one by one as a 
command line argument.  Eg

spatch file.cocci file.c -D fn=whatever

and then in your semantic patch

@@
identifier virtual.fn;
@@

... use fn as an identifier ...

julia

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

* [Cocci] Source code analysis with big regular expressions?
  2014-02-25 21:02                                 ` Julia Lawall
@ 2014-02-25 21:19                                   ` SF Markus Elfring
  2014-02-25 21:29                                     ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-25 21:19 UTC (permalink / raw)
  To: cocci

> Those two lines at least are not from Coccinelle, so I guess that they are 
> from the PCRE implementation.

Are there any chances to retrieve a more detailed error information?


> The regular expression engine is just not likely to be designed to support 
> such a large regular expression.

I would try to compare the processing of big patterns with similar interfaces
from other software.


> If you like you can give each of the function names one by one as a 
> command line argument.

I imagine that this approach will result also in different opinions about a
useful patch granularity.
http://lwn.net/Articles/585782/

Regards,
Markus

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

* [Cocci] Source code analysis with big regular expressions?
  2014-02-25 21:19                                   ` SF Markus Elfring
@ 2014-02-25 21:29                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-25 21:29 UTC (permalink / raw)
  To: cocci



On Tue, 25 Feb 2014, SF Markus Elfring wrote:

> > Those two lines at least are not from Coccinelle, so I guess that they are 
> > from the PCRE implementation.
> 
> Are there any chances to retrieve a more detailed error information?
> 
> 
> > The regular expression engine is just not likely to be designed to support 
> > such a large regular expression.
> 
> I would try to compare the processing of big patterns with similar interfaces
> from other software.
> 
> 
> > If you like you can give each of the function names one by one as a 
> > command line argument.
> 
> I imagine that this approach will result also in different opinions about a
> useful patch granularity.
> http://lwn.net/Articles/585782/

In my opinion, the change you are proposing is controversial.  Particular 
code instances may be corrected in a better way.  If you try to do 
everything at once then the kernel maintainer will have a big block that 
he has to either accept or reject.  If there is one change that is not 
made in the best way, then he will have to reject it.

On the other hand, if you do a few things at a time, then most of the 
individual things you do will perhaps be noncontroversial.

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25 20:20                         ` Julia Lawall
  2014-02-25 20:37                           ` [Cocci] Source code analysis with big regular expressions? SF Markus Elfring
@ 2014-02-25 21:44                           ` SF Markus Elfring
  2014-02-25 21:48                             ` Julia Lawall
  2014-02-26  8:04                           ` SF Markus Elfring
  2014-02-26 11:30                           ` SF Markus Elfring
  3 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-25 21:44 UTC (permalink / raw)
  To: cocci

> Remember that ... matches the shortest path between what is before and 
> what is after.  So if there is another if test on the same data in the 
> function, that will cause a failure.  If yo udon't care to have this 
> constraint, you can put when any on a ...

Which SmPL "when variant" would you recommend here?

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25 21:44                           ` [Cocci] Remove unnecessary null pointer checks? SF Markus Elfring
@ 2014-02-25 21:48                             ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-25 21:48 UTC (permalink / raw)
  To: cocci

On Tue, 25 Feb 2014, SF Markus Elfring wrote:

> > Remember that ... matches the shortest path between what is before and 
> > what is after.  So if there is another if test on the same data in the 
> > function, that will cause a failure.  If yo udon't care to have this 
> > constraint, you can put when any on a ...
> 
> Which SmPL "when variant" would you recommend here?

when any

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

* [Cocci] Branch layout for if statements with SmPL disjunctions
  2014-02-25  9:16                 ` Julia Lawall
  2014-02-25 10:01                   ` SF Markus Elfring
  2014-02-25 17:28                   ` SF Markus Elfring
@ 2014-02-26  7:25                   ` SF Markus Elfring
  2014-02-26  9:39                     ` Julia Lawall
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-26  7:25 UTC (permalink / raw)
  To: cocci

>> ( if (input) is
>> | if (likely(input)) is
>> )
>>   else es
> 
> This is not allowed.  Inside a disjunction you need to have complete terms.

I imagine that it would be nice if parts from an if statement could be written
in the shown way. Would such an extension be useful for the semantic patch language?

I can easily adjust my simple pattern here because each if branch will be
matched by a metavariable. I hope that the corresponding repetition of bigger
subpatterns can be avoided in the future.

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25 20:20                         ` Julia Lawall
  2014-02-25 20:37                           ` [Cocci] Source code analysis with big regular expressions? SF Markus Elfring
  2014-02-25 21:44                           ` [Cocci] Remove unnecessary null pointer checks? SF Markus Elfring
@ 2014-02-26  8:04                           ` SF Markus Elfring
  2014-02-26 11:30                           ` SF Markus Elfring
  3 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-26  8:04 UTC (permalink / raw)
  To: cocci

> Remember that ... matches the shortest path between what is before and 
> what is after.  So if there is another if test on the same data in the 
> function, that will cause a failure.  If yo udon't care to have this 
> constraint, you can put when any on a ...

The following pattern variant does not show a different analysis result.

@is_unnecessary_check@
expression data;
identifier work;
identifier release =~ "^kz?free$";
position pos;
type t;
@@
 t work at pos(...)
 {
  ... when any
( if (data) release(data);
| if (likely(data)) release(data);
)
  ... when any
 }

Regards,
Markus

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

* [Cocci] Branch layout for if statements with SmPL disjunctions
  2014-02-26  7:25                   ` [Cocci] Branch layout for if statements with SmPL disjunctions SF Markus Elfring
@ 2014-02-26  9:39                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-26  9:39 UTC (permalink / raw)
  To: cocci

On Wed, 26 Feb 2014, SF Markus Elfring wrote:

> >> ( if (input) is
> >> | if (likely(input)) is
> >> )
> >>   else es
> >
> > This is not allowed.  Inside a disjunction you need to have complete terms.
>
> I imagine that it would be nice if parts from an if statement could be
> written in the shown way. Would such an extension be useful for the
> semantic patch language?

No, I think that simple rules are better.  Always use complete terms is a
simple rule.

julia

> I can easily adjust my simple pattern here because each if branch will be
> matched by a metavariable. I hope that the corresponding repetition of bigger
> subpatterns can be avoided in the future.
>
> Regards,
> Markus
>

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-25 20:20                         ` Julia Lawall
                                             ` (2 preceding siblings ...)
  2014-02-26  8:04                           ` SF Markus Elfring
@ 2014-02-26 11:30                           ` SF Markus Elfring
  2014-02-26 20:35                             ` Julia Lawall
                                               ` (2 more replies)
  3 siblings, 3 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-26 11:30 UTC (permalink / raw)
  To: cocci

> But it is not surprising that a regular expression with over 5000 options 
> exceeds its capacity.

A source code search with the following pattern found 893 functions which check
their single parameter.

@safety_check@
identifier work, input;
type data_type;
position pos;
statement is, es;
@@
 void work at pos(data_type input)
 {
  ... when any
( if (input) is else es
| if (likely(input)) is else es
)
  ... when any
 }


Such a name list could be integrated into the following pattern variant.

@Delete_unnecessary_checks@
expression x;
identifier release =~ "^(?x)
(?:
   (?:kz?|slob_)free
|
   (?:
      # alternation/disjunction of 893 strings ...
   )
)$";
@@
-if (x)
    release(x);


I get an interesting result for example. Do you find it useful?

elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
delete_unnecessary_checks3.cocci /usr/src/linux-stable/fs/btrfs/inode.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: /usr/src/linux-stable/fs/btrfs/inode.c
diff =
--- /usr/src/linux-stable/fs/btrfs/inode.c
+++ /tmp/cocci-output-5030-250c49-inode.c
@@ -819,8 +819,7 @@ static u64 get_extent_allocation_hint(st
                        em = search_extent_mapping(em_tree, 0, 0);
                        if (em && em->block_start < EXTENT_MAP_LAST_BYTE)
                                alloc_hint = em->block_start;
-                       if (em)
-                               free_extent_map(em);
+                       free_extent_map(em);
                } else {
                        alloc_hint = em->block_start;
                        free_extent_map(em);
@@ -5137,8 +5136,7 @@ static int btrfs_dentry_delete(const str

 static void btrfs_dentry_release(struct dentry *dentry)
 {
-       if (dentry->d_fsdata)
-               kfree(dentry->d_fsdata);
+       kfree(dentry->d_fsdata);
 }

 static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry,
@@ -6362,8 +6360,7 @@ out:

        trace_btrfs_get_extent(root, em);

-       if (path)
-               btrfs_free_path(path);
+       btrfs_free_path(path);
        if (trans) {
                ret = btrfs_end_transaction(trans, root);
                if (!err)


Does the following pattern variant show also around 70 update candidates on your
software development system?

@is_unnecessary_check@
expression data;
identifier work;
identifier release =~ "^(?x)
(?:
   # Big regular expression for a metavariable constraint ...
)$";
position pos;
type t;
@@
 t work at pos(...)
 {
  ... when any
( if (data) release(data);
| if (likely(data)) release(data);
)
  ... when any
 }

elfring at Sonne:~/Projekte/Coccinelle/janitor> date && spatch.opt --sp-file
list_functions_with_unnecessary_checks1.cocci --dir /usr/src/linux-stable >
list_functions_with_unnecessary_checks1.txt 2>
list_functions_with_unnecessary_checks1-errors.txt && date
Mi 26. Feb 11:38:14 CET 2014
Mi 26. Feb 12:13:47 CET 2014


The log file contains messages like 'EXN:Invalid_argument("equal: abstract
value")'. Do they need further considerations?


Is this intermediate source code analysis result good enough to expand the
constructive discussion to a mailing list like "kernel janitors"?

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-26 11:30                           ` SF Markus Elfring
@ 2014-02-26 20:35                             ` Julia Lawall
  2014-02-26 21:01                               ` SF Markus Elfring
                                                 ` (2 more replies)
  2014-03-01  8:16                             ` [Cocci] Improvements for passing of big regular expressions in SmPL constraints? SF Markus Elfring
  2014-03-08 12:30                             ` [Cocci] Determination of the number for named function parameters SF Markus Elfring
  2 siblings, 3 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-02-26 20:35 UTC (permalink / raw)
  To: cocci

> I get an interesting result for example. Do you find it useful?

I checks on the three examples.  They seem technically correct, in that 
the called function does immediately do a null test on the argument value.  
Personally, I still think that the null test at the call site conveys 
useful information, so I would rather have it there, but others may think 
differently.

On the other hand, you should not be using linux-stable when working on 
the Linux kernel.  Patches should apply to linux-next, ie the very latest 
version of all of the code.

If you are convinced that dropping the null tests is a good idea, then you 
can submit the patch that makes the change to the relevant maintainers and 
mailing lists.  Use scripts/get_maintainers.pl in the Linux kernel to find 
out who to sent it to.  And study the documentation on submitting patches 
very carefully.

> The log file contains messages like 'EXN:Invalid_argument("equal: abstract
> value")'. Do they need further considerations?

This is an unfortunate constraint on the use of PCRE regular expressions.  
I will try to track it down.  Thanks for the report.

> Is this intermediate source code analysis result good enough to expand the
> constructive discussion to a mailing list like "kernel janitors"?

I don't think people on the mailing list want to discuss the issue in a 
general sense.  They just want patches, and may comment on them.

julia

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-26 20:35                             ` Julia Lawall
@ 2014-02-26 21:01                               ` SF Markus Elfring
  2014-02-26 21:09                                 ` Julia Lawall
  2014-03-05 22:30                                 ` SF Markus Elfring
       [not found]                               ` <5317A59D.4@users.so urceforge.net>
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-02-26 21:01 UTC (permalink / raw)
  To: cocci


> On the other hand, you should not be using linux-stable when working on 
> the Linux kernel.  Patches should apply to linux-next, ie the very latest 
> version of all of the code.

The discussed semantic patches can be tried out with every version a
software developer or reviewer might be interested in. I am going to
retry them with the newest source files as you suggest.



> This is an unfortunate constraint on the use of PCRE regular expressions.  
> I will try to track it down.

Thanks for your feedback.

- Do you need any excerpt from my log files?
- Does the message 'EXN:Invalid_argument("equal: abstractvalue")'
indicate that the desired source code analysis is influenced in unwanted
ways?

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-26 21:01                               ` SF Markus Elfring
@ 2014-02-26 21:09                                 ` Julia Lawall
  2014-03-06  8:39                                   ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-02-26 21:09 UTC (permalink / raw)
  To: cocci

> - Do you need any excerpt from my log files?
> - Does the message 'EXN:Invalid_argument("equal: abstractvalue")'
> indicate that the desired source code analysis is influenced in unwanted
> ways?

No, the semantic patch should be enough to reproduce the problem.  If I 
need more information, I will ask.  The problem has no impact on the 
quality of the answers actually obtained.

julia

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

* [Cocci] Improvements for passing of big regular expressions in SmPL constraints?
  2014-02-26 11:30                           ` SF Markus Elfring
  2014-02-26 20:35                             ` Julia Lawall
@ 2014-03-01  8:16                             ` SF Markus Elfring
  2014-03-01 13:15                               ` Julia Lawall
  2014-03-08 12:30                             ` [Cocci] Determination of the number for named function parameters SF Markus Elfring
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-01  8:16 UTC (permalink / raw)
  To: cocci

> @Delete_unnecessary_checks@
> expression x;
> identifier release =~ "^(?x)
> (?:
>    (?:kz?|slob_)free
> |
>    (?:
>       # alternation/disjunction of 893 strings ...
>    )
> )$";
> @@
> -if (x)
>     release(x);

Would it be useful that the shown regular expression could be included from an
other source file?
How do you think about an extension for the semantic patch language so that such
a string could be assigned to a special metavariable with a type like "regex"?
Can it be passed from a "virtual" parameter?

Regards,
Markus

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

* [Cocci] Improvements for passing of big regular expressions in SmPL constraints?
  2014-03-01  8:16                             ` [Cocci] Improvements for passing of big regular expressions in SmPL constraints? SF Markus Elfring
@ 2014-03-01 13:15                               ` Julia Lawall
  2014-03-01 13:34                                 ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-01 13:15 UTC (permalink / raw)
  To: cocci

On Sat, 1 Mar 2014, SF Markus Elfring wrote:

> > @Delete_unnecessary_checks@
> > expression x;
> > identifier release =~ "^(?x)
> > (?:
> >    (?:kz?|slob_)free
> > |
> >    (?:
> >       # alternation/disjunction of 893 strings ...
> >    )
> > )$";
> > @@
> > -if (x)
> >     release(x);
>
> Would it be useful that the shown regular expression could be included
> from an other source file? How do you think about an extension for the
> semantic patch language so that such a string could be assigned to a
> special metavariable with a type like "regex"? Can it be passed from a
> "virtual" parameter?

A priori, I don't think regular expressions are a good idea at all.  It
reflects a lac of control over what is matched.  Furthermore, Coccinelle
doesn't do any optimizations based on regular expressions.  If you put a
regular expression match in your rule, Coccinelle is likely to have to try
(parse etc) every file, because it doesn't know whether the regular
expression matches or not.  It would be better to use virtual identifiers.
That way, if you also use some kind of indexing (glimpse or id-utils),
then very little work will be done in most cases.

julia

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

* [Cocci] Improvements for passing of big regular expressions in SmPL constraints?
  2014-03-01 13:15                               ` Julia Lawall
@ 2014-03-01 13:34                                 ` SF Markus Elfring
  2014-03-01 13:36                                   ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-01 13:34 UTC (permalink / raw)
  To: cocci

> It would be better to use virtual identifiers.

Can this SmPL interface be marked and used in the way that an identifier does
not contain "plain text" but should be handled as a long regular expression?

Regards,
Markus

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

* [Cocci] Improvements for passing of big regular expressions in SmPL constraints?
  2014-03-01 13:34                                 ` SF Markus Elfring
@ 2014-03-01 13:36                                   ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-03-01 13:36 UTC (permalink / raw)
  To: cocci

On Sat, 1 Mar 2014, SF Markus Elfring wrote:

> > It would be better to use virtual identifiers.
>
> Can this SmPL interface be marked and used in the way that an identifier does
> not contain "plain text" but should be handled as a long regular expression?

No.

julia

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

* Re: [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls
  2014-02-26 20:35                             ` Julia Lawall
  2014-02-26 21:01                               ` SF Markus Elfring
@ 2014-03-05 22:30                                 ` SF Markus Elfring
       [not found]                               ` <5317A59D.4@users.so urceforge.net>
  2 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coccinelle, kernel-janitors

> If you are convinced that dropping the null tests is a good idea, then you 
> can submit the patch that makes the change to the relevant maintainers and 
> mailing lists.

Hello,

A couple of functions perform input parameter validation before their
implementations will try further actions with side effects. Some calling
functions perform similar safety checks.

Functions which release a system resource are often documented in the way that
they tolerate the passing of a null pointer for example. I do not see a need
because of this fact that a function caller repeats a corresponding check.

Now I would like to propose such a change again.

1. Extension of the infrastructure for the analysis tool "coccicheck"
   Semantic patch patterns can help to identify update candidates also in the
Linux source file hierarchy.

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/scripts/coccinelle?id=79f0345fefaafb7cde301a830471edd21a37989b

2. Clarification for some automated update suggestions
   My source code search approach found seventy functions at least which might
need another review and corresponding corrections for Linux 3.14-rc5. Further
software development will point out even more potentially open issues.

Regards,
Markus

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

* Re: [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls
@ 2014-03-05 22:30                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:30 UTC (permalink / raw)
  To: cocci

> If you are convinced that dropping the null tests is a good idea, then you 
> can submit the patch that makes the change to the relevant maintainers and 
> mailing lists.

Hello,

A couple of functions perform input parameter validation before their
implementations will try further actions with side effects. Some calling
functions perform similar safety checks.

Functions which release a system resource are often documented in the way that
they tolerate the passing of a null pointer for example. I do not see a need
because of this fact that a function caller repeats a corresponding check.

Now I would like to propose such a change again.

1. Extension of the infrastructure for the analysis tool "coccicheck"
   Semantic patch patterns can help to identify update candidates also in the
Linux source file hierarchy.

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/scripts/coccinelle?idyf0345fefaafb7cde301a830471edd21a37989b

2. Clarification for some automated update suggestions
   My source code search approach found seventy functions at least which might
need another review and corresponding corrections for Linux 3.14-rc5. Further
software development will point out even more potentially open issues.

Regards,
Markus

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

* [Cocci] [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls
@ 2014-03-05 22:30                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:30 UTC (permalink / raw)
  To: cocci

> If you are convinced that dropping the null tests is a good idea, then you 
> can submit the patch that makes the change to the relevant maintainers and 
> mailing lists.

Hello,

A couple of functions perform input parameter validation before their
implementations will try further actions with side effects. Some calling
functions perform similar safety checks.

Functions which release a system resource are often documented in the way that
they tolerate the passing of a null pointer for example. I do not see a need
because of this fact that a function caller repeats a corresponding check.

Now I would like to propose such a change again.

1. Extension of the infrastructure for the analysis tool "coccicheck"
   Semantic patch patterns can help to identify update candidates also in the
Linux source file hierarchy.

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/scripts/coccinelle?id=79f0345fefaafb7cde301a830471edd21a37989b

2. Clarification for some automated update suggestions
   My source code search approach found seventy functions at least which might
need another review and corresponding corrections for Linux 3.14-rc5. Further
software development will point out even more potentially open issues.

Regards,
Markus

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

* Re: [coccicheck Linux 3.14-rc5 PATCH 1 of 5] Deletion of unnecessary checks before specific function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-03-05 22:48                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:48 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coccinelle, kernel-janitors

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From 48c9c4f61a7d7ea98538e02631a981a429281005 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:15:34 +0100
Subject: [PATCH 1/5] Addition of a semantic patch file for showing unnecessary
 checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../deletions/delete_unnecessary_checks_template1.cocci     | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..b092051
--- /dev/null
+++ b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
@@ -0,0 +1,13 @@
+@Delete_unnecessary_checks@
+expression x;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+@@
+-if (x)
+    release(x);
-- 
1.9.0



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

* Re: [coccicheck Linux 3.14-rc5 PATCH 1 of 5] Deletion of unnecessary checks before specific function
@ 2014-03-05 22:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:48 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

From 48c9c4f61a7d7ea98538e02631a981a429281005 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:15:34 +0100
Subject: [PATCH 1/5] Addition of a semantic patch file for showing unnecessary
 checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../deletions/delete_unnecessary_checks_template1.cocci     | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..b092051
--- /dev/null
+++ b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
@@ -0,0 +1,13 @@
+@Delete_unnecessary_checks@
+expression x;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+@@
+-if (x)
+    release(x);
-- 
1.9.0



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

* [Cocci] [coccicheck Linux 3.14-rc5 PATCH 1 of 5] Deletion of unnecessary checks before specific function calls
@ 2014-03-05 22:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:48 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From 48c9c4f61a7d7ea98538e02631a981a429281005 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:15:34 +0100
Subject: [PATCH 1/5] Addition of a semantic patch file for showing unnecessary
 checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../deletions/delete_unnecessary_checks_template1.cocci     | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..b092051
--- /dev/null
+++ b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
@@ -0,0 +1,13 @@
+ at Delete_unnecessary_checks@
+expression x;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+@@
+-if (x)
+    release(x);
-- 
1.9.0

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

* Re: [coccicheck Linux 3.14-rc5 PATCH 2 of 5] Deletion of unnecessary checks before specific function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-03-05 22:50                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coccinelle, kernel-janitors

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From 1d2de3c3cfa43cc3c78a91200c41cef438b26a8f Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:38:43 +0100
Subject: [PATCH 2/5] Addition of a semantic patch file for listing of
 functions that check their single parameter

This semantic patch pattern tries to find functions that check their single
parameter for usability.

Example:
Null pointer checks are often performed as input parameter validation.

It uses Python statements to write information about the found source code
places in a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../list_input_parameter_validation1.cocci         | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_input_parameter_validation1.cocci

diff --git a/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
new file mode 100644
index 0000000..b0a5a52
--- /dev/null
+++ b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
@@ -0,0 +1,55 @@
+@initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, typ, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        mark[1] = typ
+        fields.append(''.join(mark))
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+@safety_check@
+identifier work, input;
+type data_type;
+position pos;
+statement is, es;
+@@
+ void work@pos(data_type input)
+ {
+  ... when any
+( if (input) is else es
+| if (likely(input)) is else es
+)
+  ... when any
+ }
+
+@script:python collection depends on safety_check@
+typ << safety_check.data_type;
+fun << safety_check.work;
+point << safety_check.input;
+places << safety_check.pos;
+@@
+store_positions(fun, typ, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
'"source file"', "line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0



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

* Re: [coccicheck Linux 3.14-rc5 PATCH 2 of 5] Deletion of unnecessary checks before specific function
@ 2014-03-05 22:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:50 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

From 1d2de3c3cfa43cc3c78a91200c41cef438b26a8f Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:38:43 +0100
Subject: [PATCH 2/5] Addition of a semantic patch file for listing of
 functions that check their single parameter

This semantic patch pattern tries to find functions that check their single
parameter for usability.

Example:
Null pointer checks are often performed as input parameter validation.

It uses Python statements to write information about the found source code
places in a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../list_input_parameter_validation1.cocci         | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_input_parameter_validation1.cocci

diff --git a/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
new file mode 100644
index 0000000..b0a5a52
--- /dev/null
+++ b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
@@ -0,0 +1,55 @@
+@initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, typ, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        mark[1] = typ
+        fields.append(''.join(mark))
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+@safety_check@
+identifier work, input;
+type data_type;
+position pos;
+statement is, es;
+@@
+ void work@pos(data_type input)
+ {
+  ... when any
+( if (input) is else es
+| if (likely(input)) is else es
+)
+  ... when any
+ }
+
+@script:python collection depends on safety_check@
+typ << safety_check.data_type;
+fun << safety_check.work;
+point << safety_check.input;
+places << safety_check.pos;
+@@
+store_positions(fun, typ, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
'"source file"', "line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0



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

* [Cocci] [coccicheck Linux 3.14-rc5 PATCH 2 of 5] Deletion of unnecessary checks before specific function calls
@ 2014-03-05 22:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:50 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From 1d2de3c3cfa43cc3c78a91200c41cef438b26a8f Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:38:43 +0100
Subject: [PATCH 2/5] Addition of a semantic patch file for listing of
 functions that check their single parameter

This semantic patch pattern tries to find functions that check their single
parameter for usability.

Example:
Null pointer checks are often performed as input parameter validation.

It uses Python statements to write information about the found source code
places in a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../list_input_parameter_validation1.cocci         | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_input_parameter_validation1.cocci

diff --git a/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
new file mode 100644
index 0000000..b0a5a52
--- /dev/null
+++ b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
@@ -0,0 +1,55 @@
+ at initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, typ, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        mark[1] = typ
+        fields.append(''.join(mark))
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+ at safety_check@
+identifier work, input;
+type data_type;
+position pos;
+statement is, es;
+@@
+ void work at pos(data_type input)
+ {
+  ... when any
+( if (input) is else es
+| if (likely(input)) is else es
+)
+  ... when any
+ }
+
+ at script:python collection depends on safety_check@
+typ << safety_check.data_type;
+fun << safety_check.work;
+point << safety_check.input;
+places << safety_check.pos;
+@@
+store_positions(fun, typ, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
'"source file"', "line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0

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

* Re: [coccicheck Linux 3.14-rc5 PATCH 3 of 5] Deletion of unnecessary checks before specific function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-03-05 22:52                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:52 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coccinelle, kernel-janitors

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From f4608fceec40b2b94aa9b4abe3bbb6d98ed5eed9 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:58:30 +0100
Subject: [PATCH 3/5] Addition of a SQLite script for a text file import

A script was added so that a text file which was previously generated can be
imported into a SQLite data base table.
http://sqlite.org/sqlite.html

The shown file name can be adjusted by a make file for example.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/deletions/handle_function_list_template.sqlite    | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/handle_function_list_template.sqlite

diff --git a/scripts/coccinelle/deletions/handle_function_list_template.sqlite
b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
new file mode 100644
index 0000000..bec366c
--- /dev/null
+++ b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
@@ -0,0 +1,9 @@
+create table positions(function text,
+                       data_type text,
+                       parameter text,
+                       source_file text,
+                       line integer,
+                       column integer);
+.separator "|"
+.import list_input_pointer_validation1.txt positions
+.header OFF
-- 
1.9.0



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

* Re: [coccicheck Linux 3.14-rc5 PATCH 3 of 5] Deletion of unnecessary checks before specific function
@ 2014-03-05 22:52                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:52 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

From f4608fceec40b2b94aa9b4abe3bbb6d98ed5eed9 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:58:30 +0100
Subject: [PATCH 3/5] Addition of a SQLite script for a text file import

A script was added so that a text file which was previously generated can be
imported into a SQLite data base table.
http://sqlite.org/sqlite.html

The shown file name can be adjusted by a make file for example.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/deletions/handle_function_list_template.sqlite    | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/handle_function_list_template.sqlite

diff --git a/scripts/coccinelle/deletions/handle_function_list_template.sqlite
b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
new file mode 100644
index 0000000..bec366c
--- /dev/null
+++ b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
@@ -0,0 +1,9 @@
+create table positions(function text,
+                       data_type text,
+                       parameter text,
+                       source_file text,
+                       line integer,
+                       column integer);
+.separator "|"
+.import list_input_pointer_validation1.txt positions
+.header OFF
-- 
1.9.0



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

* [Cocci] [coccicheck Linux 3.14-rc5 PATCH 3 of 5] Deletion of unnecessary checks before specific function calls
@ 2014-03-05 22:52                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:52 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From f4608fceec40b2b94aa9b4abe3bbb6d98ed5eed9 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:58:30 +0100
Subject: [PATCH 3/5] Addition of a SQLite script for a text file import

A script was added so that a text file which was previously generated can be
imported into a SQLite data base table.
http://sqlite.org/sqlite.html

The shown file name can be adjusted by a make file for example.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/deletions/handle_function_list_template.sqlite    | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/handle_function_list_template.sqlite

diff --git a/scripts/coccinelle/deletions/handle_function_list_template.sqlite
b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
new file mode 100644
index 0000000..bec366c
--- /dev/null
+++ b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
@@ -0,0 +1,9 @@
+create table positions(function text,
+                       data_type text,
+                       parameter text,
+                       source_file text,
+                       line integer,
+                       column integer);
+.separator "|"
+.import list_input_pointer_validation1.txt positions
+.header OFF
-- 
1.9.0

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

* Re: [coccicheck Linux 3.14-rc5 PATCH 4 of 5] Deletion of unnecessary checks before specific function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-03-05 22:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coccinelle, kernel-janitors

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From e6a21b920fcca2f6f01c9528909dc036a9b3bc41 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:10:32 +0100
Subject: [PATCH 4/5] Addition of a semantic patch file for listing of
 unnecessary checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

It uses Python statements to write information about the found places in
a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 ...nctions_with_unnecessary_checks_template1.cocci | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..d2637e8
--- /dev/null
+++
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
@@ -0,0 +1,59 @@
+@initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+@is_unnecessary_check@
+expression data;
+identifier work;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+position pos;
+type t;
+@@
+ t work@pos(...)
+ {
+  ... when any
+( if (data) release(data);
+| if (likely(data)) release(data);
+)
+  ... when any
+ }
+
+@script:python collection depends on is_unnecessary_check@
+fun << is_unnecessary_check.work;
+point << is_unnecessary_check.data;
+places << is_unnecessary_check.pos;
+@@
+store_positions(fun, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"parameter"', '"source file"',
"line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0


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

* Re: [coccicheck Linux 3.14-rc5 PATCH 4 of 5] Deletion of unnecessary checks before specific function
@ 2014-03-05 22:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:55 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

From e6a21b920fcca2f6f01c9528909dc036a9b3bc41 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:10:32 +0100
Subject: [PATCH 4/5] Addition of a semantic patch file for listing of
 unnecessary checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

It uses Python statements to write information about the found places in
a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 ...nctions_with_unnecessary_checks_template1.cocci | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..d2637e8
--- /dev/null
+++
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
@@ -0,0 +1,59 @@
+@initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+@is_unnecessary_check@
+expression data;
+identifier work;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+position pos;
+type t;
+@@
+ t work@pos(...)
+ {
+  ... when any
+( if (data) release(data);
+| if (likely(data)) release(data);
+)
+  ... when any
+ }
+
+@script:python collection depends on is_unnecessary_check@
+fun << is_unnecessary_check.work;
+point << is_unnecessary_check.data;
+places << is_unnecessary_check.pos;
+@@
+store_positions(fun, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"parameter"', '"source file"',
"line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0


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

* [Cocci] [coccicheck Linux 3.14-rc5 PATCH 4 of 5] Deletion of unnecessary checks before specific function calls
@ 2014-03-05 22:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:55 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From e6a21b920fcca2f6f01c9528909dc036a9b3bc41 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:10:32 +0100
Subject: [PATCH 4/5] Addition of a semantic patch file for listing of
 unnecessary checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

It uses Python statements to write information about the found places in
a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 ...nctions_with_unnecessary_checks_template1.cocci | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..d2637e8
--- /dev/null
+++
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
@@ -0,0 +1,59 @@
+ at initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+ at is_unnecessary_check@
+expression data;
+identifier work;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+position pos;
+type t;
+@@
+ t work at pos(...)
+ {
+  ... when any
+( if (data) release(data);
+| if (likely(data)) release(data);
+)
+  ... when any
+ }
+
+ at script:python collection depends on is_unnecessary_check@
+fun << is_unnecessary_check.work;
+point << is_unnecessary_check.data;
+places << is_unnecessary_check.pos;
+@@
+store_positions(fun, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"parameter"', '"source file"',
"line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0

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

* Re: [coccicheck Linux 3.14-rc5 PATCH 5 of 5] Deletion of unnecessary checks before specific function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-03-05 22:58                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coccinelle, kernel-janitors

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From bedf1cb3ddd162ee3b4c31cbb98d97431f70103d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:40:43 +0100
Subject: [PATCH 5/5] Addition of a make file for build automation

This script can be used to combine some input files for the desired data output
which will eventually show update candidates for further source code review.
Some build targets were defined. Values for the used make variables can be
adjusted by parameters on the command line as usual.

A few implementation details might need more fine-tuning.
- Automatic determination of the Linux source directory from a calling
  make process

- Setting of an extra output directory for the generated files

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/deletions/makefile | 126 ++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 scripts/coccinelle/deletions/makefile

diff --git a/scripts/coccinelle/deletions/makefile
b/scripts/coccinelle/deletions/makefile
new file mode 100644
index 0000000..6464bae
--- /dev/null
+++ b/scripts/coccinelle/deletions/makefile
@@ -0,0 +1,126 @@
+SED=sed
+SPATCH=spatch.opt --sp-file
+RM=rm -f
+LINUX_SOURCE_DIR=/usr/src/linux-stable
+EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.cocci
+SQLITE=sqlite3
+SQLITE_IMPORT_SCRIPT=handle_function_list.sqlite
+SQLITE_IMPORT_SCRIPT_TEMPLATE=handle_function_list_template.sqlite
+RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.txt
+RESULT_SQL_DATA_BASE=result.db
+RESULT_FUNCTIONS_WITH_PREFIX=add_prefix-SQL.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST=list_functions_with_unnecessary_checks1.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH=functions_with_unnecessary_checks1.diff
+LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1-errors.txt
+LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS=list_functions_with_unnecessary_checks1-errors.txt
+LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS=functions_with_unnecessary_checks1-errors.txt
+LIST_PATTERN_TEMPLATE=list_functions_with_unnecessary_checks_template1.cocci
+LIST_PATTERN=list_functions_with_unnecessary_checks1.cocci
+PATCH_PATTERN_TEMPLATE=delete_unnecessary_checks_template1.cocci
+PATCH_PATTERN=delete_unnecessary_checks1.cocci
+ESCAPING=XY=$$(< $(RESULT_FUNCTIONS_WITH_PREFIX)) \
+         && XY=$${XY/|/ } \
+         && XY=$${XY//%/\\%} \
+         && $(SED) "s%\# Alternation placeholder%$${XY//$$'\n'/$$'\\\\\n'}%"
+TEXT1=A pattern file was built from which a
+TEXT2=was generated. Good luck with source code review!
+
+default: build_update_candidate_list
+
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER): \
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	$(SPATCH) $(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+-dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+# This replacement action is needed for the use case that the corresponding
+# variable was overridden.
+$(SQLITE_IMPORT_SCRIPT): $(SQLITE_IMPORT_SCRIPT_TEMPLATE)
+	$(SED) "s%import list_input_pointer_validation1\.txt%import $(subst
%,\%,$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER))%" \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) > $@
+
+$(RESULT_SQL_DATA_BASE) $(RESULT_FUNCTIONS_WITH_PREFIX): \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+	@$(RM) $(RESULT_SQL_DATA_BASE)
+	$(SQLITE) -init $(SQLITE_IMPORT_SCRIPT) $(RESULT_SQL_DATA_BASE) \
+'select '\''   |  '\'' || function from positions group by function order by
function desc;' \
+> $(RESULT_FUNCTIONS_WITH_PREFIX)
+
+$(LIST_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(LIST_PATTERN_TEMPLATE) > $@
+
+$(PATCH_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(PATCH_PATTERN_TEMPLATE) > $@
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST): $(LIST_PATTERN)
+	$(SPATCH) $(LIST_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH): $(PATCH_PATTERN)
+	$(SPATCH) $(PATCH_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+build_check_list generate_list_of_functions_which_check_their_single_parameter: \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	@echo 'The list of functions which check their single parameter was generated.'
+
+build_import_script: $(SQLITE_IMPORT_SCRIPT)
+	@echo 'A script was generated which should contain appropriate parameters for
a data base.'
+
+build_data_base: $(RESULT_SQL_DATA_BASE)
+	@echo 'A SQL data base was built.'
+
+build_alternation add_prefix_to_functions: build_data_base
+	@echo 'The function name list was converted to a component for a regular
expression.'
+
+build_list_pattern: $(LIST_PATTERN)
+	@echo '$(TEXT1) list can be generated.'
+
+build_patch_pattern: $(PATCH_PATTERN)
+	@echo '$(TEXT1) patch can be generated.'
+
+build_update_candidate_list show_list_of_update_candidates: build_list_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST)
+	@echo 'The list of update candidates $(TEXT2)'
+
+build_patch show_update_suggestion: build_patch_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH)
+	@echo 'A patch file $(TEXT2)'
+
+all: build_update_candidate_list build_patch
+
+clean:
+	$(RM) *-errors.txt \
+$(LIST_PATTERN) \
+$(PATCH_PATTERN) \
+$(RESULT_FUNCTIONS_WITH_PREFIX) \
+$(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+
+delete_data_base:
+	$(RM) $(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+.PHONY: all \
+build_check_list \
+build_data_base \
+build_import_script \
+build_list_pattern \
+build_patch \
+build_patch_pattern \
+build_update_candidate_list \
+clean \
+default \
+delete_data_base \
+generate_list_of_functions_which_check_their_single_parameter \
+show_list_of_update_candidates \
+show_update_suggestion
+
+
+# The following input files should not need further actions here.
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) \
+$(LIST_PATTERN_TEMPLATE) \
+$(PATCH_PATTERN_TEMPLATE): ;
-- 
1.9.0


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

* Re: [coccicheck Linux 3.14-rc5 PATCH 5 of 5] Deletion of unnecessary checks before specific function
@ 2014-03-05 22:58                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:58 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

From bedf1cb3ddd162ee3b4c31cbb98d97431f70103d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:40:43 +0100
Subject: [PATCH 5/5] Addition of a make file for build automation

This script can be used to combine some input files for the desired data output
which will eventually show update candidates for further source code review.
Some build targets were defined. Values for the used make variables can be
adjusted by parameters on the command line as usual.

A few implementation details might need more fine-tuning.
- Automatic determination of the Linux source directory from a calling
  make process

- Setting of an extra output directory for the generated files

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/deletions/makefile | 126 ++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 scripts/coccinelle/deletions/makefile

diff --git a/scripts/coccinelle/deletions/makefile
b/scripts/coccinelle/deletions/makefile
new file mode 100644
index 0000000..6464bae
--- /dev/null
+++ b/scripts/coccinelle/deletions/makefile
@@ -0,0 +1,126 @@
+SED=sed
+SPATCH=spatch.opt --sp-file
+RM=rm -f
+LINUX_SOURCE_DIR=/usr/src/linux-stable
+EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.cocci
+SQLITE=sqlite3
+SQLITE_IMPORT_SCRIPT=handle_function_list.sqlite
+SQLITE_IMPORT_SCRIPT_TEMPLATE=handle_function_list_template.sqlite
+RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.txt
+RESULT_SQL_DATA_BASE=result.db
+RESULT_FUNCTIONS_WITH_PREFIX­d_prefix-SQL.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST=list_functions_with_unnecessary_checks1.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH=functions_with_unnecessary_checks1.diff
+LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1-errors.txt
+LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS=list_functions_with_unnecessary_checks1-errors.txt
+LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS=functions_with_unnecessary_checks1-errors.txt
+LIST_PATTERN_TEMPLATE=list_functions_with_unnecessary_checks_template1.cocci
+LIST_PATTERN=list_functions_with_unnecessary_checks1.cocci
+PATCH_PATTERN_TEMPLATEÞlete_unnecessary_checks_template1.cocci
+PATCH_PATTERNÞlete_unnecessary_checks1.cocci
+ESCAPING=XY=$$(< $(RESULT_FUNCTIONS_WITH_PREFIX)) \
+         && XY=$${XY/|/ } \
+         && XY=$${XY//%/\\%} \
+         && $(SED) "s%\# Alternation placeholder%$${XY//$$'\n'/$$'\\\\\n'}%"
+TEXT1=A pattern file was built from which a
+TEXT2=was generated. Good luck with source code review!
+
+default: build_update_candidate_list
+
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER): \
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	$(SPATCH) $(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+-dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+# This replacement action is needed for the use case that the corresponding
+# variable was overridden.
+$(SQLITE_IMPORT_SCRIPT): $(SQLITE_IMPORT_SCRIPT_TEMPLATE)
+	$(SED) "s%import list_input_pointer_validation1\.txt%import $(subst
%,\%,$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER))%" \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) > $@
+
+$(RESULT_SQL_DATA_BASE) $(RESULT_FUNCTIONS_WITH_PREFIX): \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+	@$(RM) $(RESULT_SQL_DATA_BASE)
+	$(SQLITE) -init $(SQLITE_IMPORT_SCRIPT) $(RESULT_SQL_DATA_BASE) \
+'select '\''   |  '\'' || function from positions group by function order by
function desc;' \
+> $(RESULT_FUNCTIONS_WITH_PREFIX)
+
+$(LIST_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(LIST_PATTERN_TEMPLATE) > $@
+
+$(PATCH_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(PATCH_PATTERN_TEMPLATE) > $@
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST): $(LIST_PATTERN)
+	$(SPATCH) $(LIST_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH): $(PATCH_PATTERN)
+	$(SPATCH) $(PATCH_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+build_check_list generate_list_of_functions_which_check_their_single_parameter: \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	@echo 'The list of functions which check their single parameter was generated.'
+
+build_import_script: $(SQLITE_IMPORT_SCRIPT)
+	@echo 'A script was generated which should contain appropriate parameters for
a data base.'
+
+build_data_base: $(RESULT_SQL_DATA_BASE)
+	@echo 'A SQL data base was built.'
+
+build_alternation add_prefix_to_functions: build_data_base
+	@echo 'The function name list was converted to a component for a regular
expression.'
+
+build_list_pattern: $(LIST_PATTERN)
+	@echo '$(TEXT1) list can be generated.'
+
+build_patch_pattern: $(PATCH_PATTERN)
+	@echo '$(TEXT1) patch can be generated.'
+
+build_update_candidate_list show_list_of_update_candidates: build_list_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST)
+	@echo 'The list of update candidates $(TEXT2)'
+
+build_patch show_update_suggestion: build_patch_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH)
+	@echo 'A patch file $(TEXT2)'
+
+all: build_update_candidate_list build_patch
+
+clean:
+	$(RM) *-errors.txt \
+$(LIST_PATTERN) \
+$(PATCH_PATTERN) \
+$(RESULT_FUNCTIONS_WITH_PREFIX) \
+$(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+
+delete_data_base:
+	$(RM) $(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+.PHONY: all \
+build_check_list \
+build_data_base \
+build_import_script \
+build_list_pattern \
+build_patch \
+build_patch_pattern \
+build_update_candidate_list \
+clean \
+default \
+delete_data_base \
+generate_list_of_functions_which_check_their_single_parameter \
+show_list_of_update_candidates \
+show_update_suggestion
+
+
+# The following input files should not need further actions here.
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) \
+$(LIST_PATTERN_TEMPLATE) \
+$(PATCH_PATTERN_TEMPLATE): ;
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [Cocci] [coccicheck Linux 3.14-rc5 PATCH 5 of 5] Deletion of unnecessary checks before specific function calls
@ 2014-03-05 22:58                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-05 22:58 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From bedf1cb3ddd162ee3b4c31cbb98d97431f70103d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:40:43 +0100
Subject: [PATCH 5/5] Addition of a make file for build automation

This script can be used to combine some input files for the desired data output
which will eventually show update candidates for further source code review.
Some build targets were defined. Values for the used make variables can be
adjusted by parameters on the command line as usual.

A few implementation details might need more fine-tuning.
- Automatic determination of the Linux source directory from a calling
  make process

- Setting of an extra output directory for the generated files

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/deletions/makefile | 126 ++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 scripts/coccinelle/deletions/makefile

diff --git a/scripts/coccinelle/deletions/makefile
b/scripts/coccinelle/deletions/makefile
new file mode 100644
index 0000000..6464bae
--- /dev/null
+++ b/scripts/coccinelle/deletions/makefile
@@ -0,0 +1,126 @@
+SED=sed
+SPATCH=spatch.opt --sp-file
+RM=rm -f
+LINUX_SOURCE_DIR=/usr/src/linux-stable
+EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.cocci
+SQLITE=sqlite3
+SQLITE_IMPORT_SCRIPT=handle_function_list.sqlite
+SQLITE_IMPORT_SCRIPT_TEMPLATE=handle_function_list_template.sqlite
+RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.txt
+RESULT_SQL_DATA_BASE=result.db
+RESULT_FUNCTIONS_WITH_PREFIX=add_prefix-SQL.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST=list_functions_with_unnecessary_checks1.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH=functions_with_unnecessary_checks1.diff
+LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1-errors.txt
+LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS=list_functions_with_unnecessary_checks1-errors.txt
+LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS=functions_with_unnecessary_checks1-errors.txt
+LIST_PATTERN_TEMPLATE=list_functions_with_unnecessary_checks_template1.cocci
+LIST_PATTERN=list_functions_with_unnecessary_checks1.cocci
+PATCH_PATTERN_TEMPLATE=delete_unnecessary_checks_template1.cocci
+PATCH_PATTERN=delete_unnecessary_checks1.cocci
+ESCAPING=XY=$$(< $(RESULT_FUNCTIONS_WITH_PREFIX)) \
+         && XY=$${XY/|/ } \
+         && XY=$${XY//%/\\%} \
+         && $(SED) "s%\# Alternation placeholder%$${XY//$$'\n'/$$'\\\\\n'}%"
+TEXT1=A pattern file was built from which a
+TEXT2=was generated. Good luck with source code review!
+
+default: build_update_candidate_list
+
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER): \
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	$(SPATCH) $(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+-dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+# This replacement action is needed for the use case that the corresponding
+# variable was overridden.
+$(SQLITE_IMPORT_SCRIPT): $(SQLITE_IMPORT_SCRIPT_TEMPLATE)
+	$(SED) "s%import list_input_pointer_validation1\.txt%import $(subst
%,\%,$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER))%" \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) > $@
+
+$(RESULT_SQL_DATA_BASE) $(RESULT_FUNCTIONS_WITH_PREFIX): \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+	@$(RM) $(RESULT_SQL_DATA_BASE)
+	$(SQLITE) -init $(SQLITE_IMPORT_SCRIPT) $(RESULT_SQL_DATA_BASE) \
+'select '\''   |  '\'' || function from positions group by function order by
function desc;' \
+> $(RESULT_FUNCTIONS_WITH_PREFIX)
+
+$(LIST_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(LIST_PATTERN_TEMPLATE) > $@
+
+$(PATCH_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(PATCH_PATTERN_TEMPLATE) > $@
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST): $(LIST_PATTERN)
+	$(SPATCH) $(LIST_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH): $(PATCH_PATTERN)
+	$(SPATCH) $(PATCH_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+build_check_list generate_list_of_functions_which_check_their_single_parameter: \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	@echo 'The list of functions which check their single parameter was generated.'
+
+build_import_script: $(SQLITE_IMPORT_SCRIPT)
+	@echo 'A script was generated which should contain appropriate parameters for
a data base.'
+
+build_data_base: $(RESULT_SQL_DATA_BASE)
+	@echo 'A SQL data base was built.'
+
+build_alternation add_prefix_to_functions: build_data_base
+	@echo 'The function name list was converted to a component for a regular
expression.'
+
+build_list_pattern: $(LIST_PATTERN)
+	@echo '$(TEXT1) list can be generated.'
+
+build_patch_pattern: $(PATCH_PATTERN)
+	@echo '$(TEXT1) patch can be generated.'
+
+build_update_candidate_list show_list_of_update_candidates: build_list_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST)
+	@echo 'The list of update candidates $(TEXT2)'
+
+build_patch show_update_suggestion: build_patch_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH)
+	@echo 'A patch file $(TEXT2)'
+
+all: build_update_candidate_list build_patch
+
+clean:
+	$(RM) *-errors.txt \
+$(LIST_PATTERN) \
+$(PATCH_PATTERN) \
+$(RESULT_FUNCTIONS_WITH_PREFIX) \
+$(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+
+delete_data_base:
+	$(RM) $(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+.PHONY: all \
+build_check_list \
+build_data_base \
+build_import_script \
+build_list_pattern \
+build_patch \
+build_patch_pattern \
+build_update_candidate_list \
+clean \
+default \
+delete_data_base \
+generate_list_of_functions_which_check_their_single_parameter \
+show_list_of_update_candidates \
+show_update_suggestion
+
+
+# The following input files should not need further actions here.
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) \
+$(LIST_PATTERN_TEMPLATE) \
+$(PATCH_PATTERN_TEMPLATE): ;
-- 
1.9.0

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-26 21:09                                 ` Julia Lawall
@ 2014-03-06  8:39                                   ` SF Markus Elfring
  2014-03-06 16:24                                     ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-06  8:39 UTC (permalink / raw)
  To: cocci

>> - Does the message 'EXN:Invalid_argument("equal: abstractvalue")'
>> indicate that the desired source code analysis is influenced in unwanted
>> ways?
> 
> No, the semantic patch should be enough to reproduce the problem.  If I 
> need more information, I will ask.

I have looked into my log files once more so that I can give you another
feedback for a "regexp problem".


> The problem has no impact on the quality of the answers actually obtained.

Now I make a different observation for the processing of SmPL constraints with a
long function name list in the regular expression.

elfring at Sonne:~/Projekte/Coccinelle/janitor> OCAMLRUNPARAM=b spatch.opt
--sp-file delete_unnecessary_checks3.cocci
/usr/src/linux-stable/fs/proc/proc_sysctl.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: /usr/src/linux-stable/fs/proc/proc_sysctl.c
diff =
--- /usr/src/linux-stable/fs/proc/proc_sysctl.c
+++ /tmp/cocci-output-5200-eacf04-proc_sysctl.c
@@ -470,8 +470,7 @@ static struct dentry *proc_sys_lookup(st
        d_add(dentry, inode);

 out:
-       if (h)
-               sysctl_head_finish(h);
+       sysctl_head_finish(h);
        sysctl_head_finish(head);
        return err;
 }
elfring at Sonne:~/Projekte/Coccinelle/janitor> OCAMLRUNPARAM=b spatch.opt
--sp-file list_functions_with_unnecessary_checks1.cocci
/usr/src/linux-stable/fs/proc/proc_sysctl.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: /usr/src/linux-stable/fs/proc/proc_sysctl.c
Fatal error: exception Invalid_argument("equal: abstract value")
Called from file "list.ml", line 86, characters 24-34
Called from file "list.ml", line 86, characters 24-34
Called from file "list.ml", line 86, characters 24-34
Called from file "list.ml", line 57, characters 20-23


Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-03-06  8:39                                   ` SF Markus Elfring
@ 2014-03-06 16:24                                     ` Julia Lawall
  2014-03-06 17:04                                       ` SF Markus Elfring
  2014-09-30 13:24                                       ` [Cocci] Fix for "lexing: empty token" needed? SF Markus Elfring
  0 siblings, 2 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-03-06 16:24 UTC (permalink / raw)
  To: cocci

On Thu, 6 Mar 2014, SF Markus Elfring wrote:

> >> - Does the message 'EXN:Invalid_argument("equal: abstractvalue")'
> >> indicate that the desired source code analysis is influenced in unwanted
> >> ways?
> >
> > No, the semantic patch should be enough to reproduce the problem.  If I
> > need more information, I will ask.
>
> I have looked into my log files once more so that I can give you another
> feedback for a "regexp problem".

I can't reproduce this.  I need the semantic patch.

julia

>
>
> > The problem has no impact on the quality of the answers actually obtained.
>
> Now I make a different observation for the processing of SmPL constraints with a
> long function name list in the regular expression.
>
> elfring at Sonne:~/Projekte/Coccinelle/janitor> OCAMLRUNPARAM=b spatch.opt
> --sp-file delete_unnecessary_checks3.cocci
> /usr/src/linux-stable/fs/proc/proc_sysctl.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: /usr/src/linux-stable/fs/proc/proc_sysctl.c
> diff =
> --- /usr/src/linux-stable/fs/proc/proc_sysctl.c
> +++ /tmp/cocci-output-5200-eacf04-proc_sysctl.c
> @@ -470,8 +470,7 @@ static struct dentry *proc_sys_lookup(st
>         d_add(dentry, inode);
>
>  out:
> -       if (h)
> -               sysctl_head_finish(h);
> +       sysctl_head_finish(h);
>         sysctl_head_finish(head);
>         return err;
>  }
> elfring at Sonne:~/Projekte/Coccinelle/janitor> OCAMLRUNPARAM=b spatch.opt
> --sp-file list_functions_with_unnecessary_checks1.cocci
> /usr/src/linux-stable/fs/proc/proc_sysctl.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: /usr/src/linux-stable/fs/proc/proc_sysctl.c
> Fatal error: exception Invalid_argument("equal: abstract value")
> Called from file "list.ml", line 86, characters 24-34
> Called from file "list.ml", line 86, characters 24-34
> Called from file "list.ml", line 86, characters 24-34
> Called from file "list.ml", line 57, characters 20-23
>
>
> Regards,
> Markus
>

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-03-06 16:24                                     ` Julia Lawall
@ 2014-03-06 17:04                                       ` SF Markus Elfring
  2014-09-30 13:24                                       ` [Cocci] Fix for "lexing: empty token" needed? SF Markus Elfring
  1 sibling, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-06 17:04 UTC (permalink / raw)
  To: cocci

> I can't reproduce this.  I need the semantic patch.

How do you think about to try out the scripts which I published yesterday evening?

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-02-26 11:30                           ` SF Markus Elfring
  2014-02-26 20:35                             ` Julia Lawall
  2014-03-01  8:16                             ` [Cocci] Improvements for passing of big regular expressions in SmPL constraints? SF Markus Elfring
@ 2014-03-08 12:30                             ` SF Markus Elfring
  2014-03-08 14:16                               ` Julia Lawall
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-08 12:30 UTC (permalink / raw)
  To: cocci

> A source code search with the following pattern found 893 functions which check
> their single parameter.

I am also interested to generate statistics for the declaration of function
parameters and their use.
Is it possible to analyse the function parameter list by interfaces from the
semantic patch language? Can any useful numbers be extracted at this place?

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-08 12:30                             ` [Cocci] Determination of the number for named function parameters SF Markus Elfring
@ 2014-03-08 14:16                               ` Julia Lawall
  2014-03-08 15:10                                 ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-08 14:16 UTC (permalink / raw)
  To: cocci

On Sat, 8 Mar 2014, SF Markus Elfring wrote:

> > A source code search with the following pattern found 893 functions which check
> > their single parameter.
>
> I am also interested to generate statistics for the declaration of function
> parameters and their use.
> Is it possible to analyse the function parameter list by interfaces from the
> semantic patch language? Can any useful numbers be extracted at this place?

The question is not very precise.  I don't know what you mean by analyse,
nor what you mean by interfaces, nor what you mean by useful.  You can
write things like:

f(...,T i,...) { ... }
where T is a type and i is an identifier

or

f(...,p,...) { ... }
where p is a parameter

or

f(ps,p,...) { ... }
where ps is a parameter list and p is a parameter.

In declaratin a parameter list, you can also say;

parameter list[n] ps;

and then n is the number of parameters that are matched.

julia

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

* [Cocci] Determination of the number for named function parameters
  2014-03-08 14:16                               ` Julia Lawall
@ 2014-03-08 15:10                                 ` SF Markus Elfring
  2014-03-08 20:01                                   ` SF Markus Elfring
  2014-03-08 21:59                                   ` [Cocci] Determination of the number for named function parameters Julia Lawall
  0 siblings, 2 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-08 15:10 UTC (permalink / raw)
  To: cocci

> In declaratin a parameter list, you can also say;
> 
> parameter list[n] ps;
> 
> and then n is the number of parameters that are matched.

Thanks for your interesting details.

I find the use of the element "n" (the name in square brackets) not obvious from
the Coccinelle manual so far.

But I would like to try more analysis with the data that is passed by the
metavariable type "parameter list". I have started to look a bit into it by the
function "pickle.dumps". This kind of display is not so useful for me yet.
I am missing documentation for corresponding data structures I can depend on in
further reports.

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-08 15:10                                 ` SF Markus Elfring
@ 2014-03-08 20:01                                   ` SF Markus Elfring
  2014-03-08 21:41                                     ` Julia Lawall
  2014-03-08 21:59                                   ` [Cocci] Determination of the number for named function parameters Julia Lawall
  1 sibling, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-08 20:01 UTC (permalink / raw)
  To: cocci

> I am missing documentation for corresponding data structures I can depend on in
> further reports.

The display from the function "pprint.pformat" shows another implementation
detail in my simple script.
http://docs.python.org/2/library/pprint.html

Would you like to clarify data analysis according to the current situation
around "coccilib.elems.TermList instance"?

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-08 20:01                                   ` SF Markus Elfring
@ 2014-03-08 21:41                                     ` Julia Lawall
  2014-03-09  8:00                                       ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-08 21:41 UTC (permalink / raw)
  To: cocci

On Sat, 8 Mar 2014, SF Markus Elfring wrote:

> > I am missing documentation for corresponding data structures I can depend on in
> > further reports.
> 
> The display from the function "pprint.pformat" shows another implementation
> detail in my simple script.
> http://docs.python.org/2/library/pprint.html
> 
> Would you like to clarify data analysis according to the current situation
> around "coccilib.elems.TermList instance"?

I know nothing about this.  Maybe look at the python code and see what it 
does.  But I am not sure that using it is the best way to do whjat you 
want, although I also don't know what you want to do.

julia

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

* [Cocci] Determination of the number for named function parameters
  2014-03-08 15:10                                 ` SF Markus Elfring
  2014-03-08 20:01                                   ` SF Markus Elfring
@ 2014-03-08 21:59                                   ` Julia Lawall
  2014-03-09  7:01                                     ` SF Markus Elfring
  1 sibling, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-08 21:59 UTC (permalink / raw)
  To: cocci

On Sat, 8 Mar 2014, SF Markus Elfring wrote:

> > In declaratin a parameter list, you can also say;
> > 
> > parameter list[n] ps;
> > 
> > and then n is the number of parameters that are matched.
> 
> Thanks for your interesting details.
> 
> I find the use of the element "n" (the name in square brackets) not obvious from
> the Coccinelle manual so far.

It is the number of elements that have been matched.  You can use it in 
python code (as a string, I think), in ocaml code (as an integer), or 
inherit it into another list-typed metavariable.

> But I would like to try more analysis with the data that is passed by the
> metavariable type "parameter list". I have started to look a bit into it by the
> function "pickle.dumps". This kind of display is not so useful for me yet.
> I am missing documentation for corresponding data structures I can depend on in
> further reports.

What analysis do you want to do?  If you write an ocaml script, you can 
have access to the comple abstract syntax trees.  Python code only 
receives a string representation.

julia

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

* [Cocci] Determination of the number for named function parameters
  2014-03-08 21:59                                   ` [Cocci] Determination of the number for named function parameters Julia Lawall
@ 2014-03-09  7:01                                     ` SF Markus Elfring
  2014-03-09  7:13                                       ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-09  7:01 UTC (permalink / raw)
  To: cocci

>> I find the use of the element "n" (the name in square brackets) not obvious from
>> the Coccinelle manual so far.
> 
> It is the number of elements that have been matched.

A part of my difficulty with interpretation of the grammar for the semantic
patch language came from this notation.

"metadecl ::= ...
            | parameter [list] ids ;
            | parameter list [ id ] ids ;
..."


Do square brackets indicate in one line that an information is optional while in
the other line they should be used as literals?


> What analysis do you want to do?

If I try out the following script ...

@initialize:python@
@@
import sys
result = []
mark = ['"', '', '"']
delimiter = '|'

def store_positions(fun, count, places):
    """Add source code positions to an internal list."""
    for place in places:
        fields = []
        fields.append(fun)

        fields.append(count)

        mark[1] = place.file.replace('"', '""')
        fields.append(''.join(mark))

        fields.append(place.line)
        fields.append(str(int(place.column) + 1))
        result.append(delimiter.join(fields))

@skeleton@
identifier fun;
parameter list [count] pl;
position pos;
@@
 fun at pos(pl)
 {
  ...
 }

@script:python collection depends on skeleton@
fun << skeleton.fun;
count << skeleton.count;
places << skeleton.pos;
@@
store_positions(fun, count, places)

@finalize:python@
@@
if result:
   result.insert(0, delimiter.join(("function", '"parameter count"', '"source
file"', "line", "column")))
   print("\r\n".join(result))
else:
   sys.stderr.write("No result for this analysis!\n")


... on this source code example, ...

void my_log(char const * text)
{
  /* Write something ... */
}

int my_safe_log(char const * text)
{
  if (!text)
    return 1;

  my_log(text);
  return 0;
}

char const * const my_message(void)
{
  return "Surprise!";
}

int my_status(void)
{
  return 1;
}

int my_addition(char a, char b)
{
  return a + b;
}

int main(void)
{
  struct my_operations
  {
    void (*log)(char const * t);
    int (*safe_log)(char const * t);
    char const * const (*get_message)(void);
    int (*is_ready)(void);
    int (*add)(char a, char b);
  } mo = {my_log, my_safe_log, my_message, my_status, my_addition}, * mop = &mo;

  char const * const x = mo.get_message();
  int y = mop->is_ready();
  y = mop->add(1, 2);
  y = mo.add(3, 4);
  mo.log(mo.get_message());
  mo.is_ready();
  my_safe_log(0);
  mo.safe_log(0);
  mop->safe_log(0);
}


... I get a result that is a bit interesting.

elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch --sp-file
list_function_parameters2.cocci ../Probe/f-ptr-test1.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: ../Probe/f-ptr-test1.c
function|"parameter count"|"source file"|line|column
main|1|"../Probe/f-ptr-test1.c"|30|5
my_log|1|"../Probe/f-ptr-test1.c"|1|6
my_message|1|"../Probe/f-ptr-test1.c"|15|20
my_safe_log|1|"../Probe/f-ptr-test1.c"|6|5
my_status|1|"../Probe/f-ptr-test1.c"|20|5
my_addition|2|"../Probe/f-ptr-test1.c"|25|5


I guess that I want to exclude matches for my use case where where the parameter
type is "void". I would like to show the distribution of parameter numbers in a
source code base.

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-09  7:01                                     ` SF Markus Elfring
@ 2014-03-09  7:13                                       ` Julia Lawall
  2014-03-09  7:18                                         ` [Cocci] Improvements for the SmPL grammar description? SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-09  7:13 UTC (permalink / raw)
  To: cocci



On Sun, 9 Mar 2014, SF Markus Elfring wrote:

> >> I find the use of the element "n" (the name in square brackets) not obvious from
> >> the Coccinelle manual so far.
> > 
> > It is the number of elements that have been matched.
> 
> A part of my difficulty with interpretation of the grammar for the semantic
> patch language came from this notation.
> 
> "metadecl ::= ...
>             | parameter [list] ids ;
>             | parameter list [ id ] ids ;
> ..."
> 
> 
> Do square brackets indicate in one line that an information is optional while in
> the other line they should be used as literals?

Yes.  The spaces around the [ ] means that they are tokens.

julia

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

* [Cocci] Improvements for the SmPL grammar description?
  2014-03-09  7:13                                       ` Julia Lawall
@ 2014-03-09  7:18                                         ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-09  7:18 UTC (permalink / raw)
  To: cocci

> The spaces around the [ ] means that they are tokens.

I would appreciate if the distinction will become easier for such characters.

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-08 21:41                                     ` Julia Lawall
@ 2014-03-09  8:00                                       ` SF Markus Elfring
  2014-03-09  8:12                                         ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-09  8:00 UTC (permalink / raw)
  To: cocci

>> Would you like to clarify data analysis according to the current situation
>> around "coccilib.elems.TermList instance"?
> 
> I know nothing about this.

I am surprised by this feedback.

I assume that a corresponding interface description would be nice if I look at
"man 3cocci Coccilib". How are the chances to improve the mapping from the OCaml
API to the Python binding?


> But I am not sure that using it is the best way to do whjat you 
> want, although I also don't know what you want to do.

The tool "spatch" counts all elements in a metavariable of the type "parameter
list". I would like to treat list elements that have got the function parameter
type "void" or no name differently.
- How can I assign the number "zero" (instead of "1") in this case?
- Should I generally exclude parameters without names from another report variant?

I am also interested a bit in run time optimisation. A passed list should be
sufficient for further computations. I do not really need a count in another
variable which was specified between square brackets of a SmPL rule.

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-09  8:00                                       ` SF Markus Elfring
@ 2014-03-09  8:12                                         ` Julia Lawall
  2014-03-09  8:50                                           ` SF Markus Elfring
                                                             ` (2 more replies)
  0 siblings, 3 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-03-09  8:12 UTC (permalink / raw)
  To: cocci

On Sun, 9 Mar 2014, SF Markus Elfring wrote:

> >> Would you like to clarify data analysis according to the current situation
> >> around "coccilib.elems.TermList instance"?
> > 
> > I know nothing about this.
> 
> I am surprised by this feedback.

I didn't implement it, and I never use python.  The thing you are citing 
was implemented by a masters student for his masters thesis project, and 
it contains whatever he found useful.

> I assume that a corresponding interface description would be nice if I 
> look at "man 3cocci Coccilib". How are the chances to improve the 
> mapping from the OCaml API to the Python binding?

If you would like to have such a thing you are welcome to implement.  In 
my experience the AST is very rarely useful.

> > But I am not sure that using it is the best way to do whjat you 
> > want, although I also don't know what you want to do.
> 
> The tool "spatch" counts all elements in a metavariable of the type 
> "parameter list". I would like to treat list elements that have got the 
> function parameter type "void" or no name differently.
> - How can I assign the number "zero" (instead of "1") in this case?

Have a special rule for such functions and use position variables to 
prevent the rule that matches interesting parameter lists from matching 
functions that have satisfied this case:

@r@
position p;
identifier f;
@@

f at p(void} { ... }

@goodfunctions@
position p != r.p;
parameter list[n] ps;
identifier f;
@@

f at p(ps) { ... }

Or you can just use your python code to see if ps is just the string 
"void".

> I am also interested a bit in run time optimisation. A passed list should be
> sufficient for further computations. I do not really need a count in another
> variable which was specified between square brackets of a SmPL rule.

It is hard to imagine why converting all the elements of a list to strings 
as is done in the interface to python would be more efficient than just 
passing a single number.

Anyway, the runtime cost is not here, in either case.  The runtime cost 
will be that you have to parse every function of every file.

julia

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

* [Cocci] Determination of the number for named function parameters
  2014-03-09  8:12                                         ` Julia Lawall
@ 2014-03-09  8:50                                           ` SF Markus Elfring
  2014-03-14 14:25                                             ` SF Markus Elfring
  2014-03-09 12:51                                           ` SF Markus Elfring
  2014-03-10 18:00                                           ` [Cocci] Selection of class libraries ...? SF Markus Elfring
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-09  8:50 UTC (permalink / raw)
  To: cocci

> I didn't implement it, and I never use python.

I would struggle with OCaml script development more so far.


> Have a special rule for such functions and use position variables to 
> prevent the rule that matches interesting parameter lists from matching 
> functions that have satisfied this case:

Thanks for your SmPL pattern suggestion.


> @r@
> position p;
> identifier f;
> @@
> 
> f at p(void} { ... }
> 
> @goodfunctions@
> position p != r.p;
> parameter list[n] ps;
> identifier f;
> @@
> 
> f at p(ps) { ... }

I would prefer to specify a meaningful constraint for the metavariable "ps" somehow.


> Or you can just use your python code to see if ps is just the string 
> "void".

I thought also in a similar direction. But I would like to be sure about the
passed data structures. I imagine that I would need to inspect the class
"coccilib.elems.TermList" if the corresponding documentation is unclear.


> 
>> I am also interested a bit in run time optimisation. A passed list should be
>> sufficient for further computations. I do not really need a count in another
>> variable which was specified between square brackets of a SmPL rule.
> 
> It is hard to imagine why converting all the elements of a list to strings 
> as is done in the interface to python would be more efficient than just 
> passing a single number.

I would like to try out two reports at least.

1. What is the maximum number of named function parameters in a source code base?
   I need only the value "n" (without the additional data from the related
metavariable).

2. Comparison for the incidence of unnamed function parameters to all of them
   The parameter count could be determined from the list of parameter names
alone, couldn't it?

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-09  8:12                                         ` Julia Lawall
  2014-03-09  8:50                                           ` SF Markus Elfring
@ 2014-03-09 12:51                                           ` SF Markus Elfring
  2014-03-09 13:06                                             ` Julia Lawall
  2014-03-10 18:00                                           ` [Cocci] Selection of class libraries ...? SF Markus Elfring
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-09 12:51 UTC (permalink / raw)
  To: cocci

> Have a special rule for such functions and use position variables to 
> prevent the rule that matches interesting parameter lists from matching 
> functions that have satisfied this case:

I have adjusted your suggestion a little bit here.

@no_input@
identifier fun;
position pos;
@@
 fun at pos(void) { ... }

@input depends on no_input@
identifier fun;
parameter list [count] pl;
position pos != no_input.pos;
@@
 fun at pos(pl) { ... }

@script:python collection depends on input@
fun << input.fun;
count << input.count;
places << input.pos;
@@
store_positions(fun, count, places)


This pattern variant works as expected for a source code example that was
already mentioned before.

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
list_function_parameters2.cocci ../Probe/f-ptr-test1.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: ../Probe/f-ptr-test1.c
function|"parameter count"|"source file"|line|column
my_log|1|"../Probe/f-ptr-test1.c"|1|6
my_safe_log|1|"../Probe/f-ptr-test1.c"|6|5
my_addition|2|"../Probe/f-ptr-test1.c"|25|5


But I wonder about the processing for the following small source file.

void my_log(char const * format, ...)
{
  /* Write something ... */
}

elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
list_function_parameters2.cocci ../Probe/ellipsis-test1.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: ../Probe/ellipsis-test1.c
No result for this analysis!


I would appreciate your advices.

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-09 12:51                                           ` SF Markus Elfring
@ 2014-03-09 13:06                                             ` Julia Lawall
  2014-03-09 13:36                                               ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-09 13:06 UTC (permalink / raw)
  To: cocci

On Sun, 9 Mar 2014, SF Markus Elfring wrote:

> > Have a special rule for such functions and use position variables to
> > prevent the rule that matches interesting parameter lists from matching
> > functions that have satisfied this case:
>
> I have adjusted your suggestion a little bit here.
>
> @no_input@
> identifier fun;
> position pos;
> @@
>  fun at pos(void) { ... }
>
> @input depends on no_input@
> identifier fun;
> parameter list [count] pl;
> position pos != no_input.pos;
> @@
>  fun at pos(pl) { ... }
>
> @script:python collection depends on input@

No need for depends on input.  For a python rule, all metavariables have
to be bound before anything happens.

> fun << input.fun;
> count << input.count;
> places << input.pos;
> @@
> store_positions(fun, count, places)
>
>
> This pattern variant works as expected for a source code example that was
> already mentioned before.
>
> elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
> list_function_parameters2.cocci ../Probe/f-ptr-test1.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: ../Probe/f-ptr-test1.c
> function|"parameter count"|"source file"|line|column
> my_log|1|"../Probe/f-ptr-test1.c"|1|6
> my_safe_log|1|"../Probe/f-ptr-test1.c"|6|5
> my_addition|2|"../Probe/f-ptr-test1.c"|25|5
>
>
> But I wonder about the processing for the following small source file.
>
> void my_log(char const * format, ...)
> {
>   /* Write something ... */
> }
>
> elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
> list_function_parameters2.cocci ../Probe/ellipsis-test1.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: ../Probe/ellipsis-test1.c
> No result for this analysis!
>
>
> I would appreciate your advices.

I have no idea.  I would have sort of expected that it would return a
length of 2, but I guess it is reasonable, and even desirable, that it
does not.  What answer would you like?

julia

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

* [Cocci] Determination of the number for named function parameters
  2014-03-09 13:06                                             ` Julia Lawall
@ 2014-03-09 13:36                                               ` SF Markus Elfring
  2014-03-09 13:40                                                 ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-09 13:36 UTC (permalink / raw)
  To: cocci

> I have no idea.  I would have sort of expected that it would return a
> length of 2, but I guess it is reasonable, and even desirable, that it
> does not.  What answer would you like?

I would expect that it will be treated by the SmPL pattern as a function with a
single named parameter at least. I am unsure how the "ellipsis" should be
counted and matched in the signature eventually.

Does this small source file indicate that there might be further difficulties
for data analysis of variadic functions?

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-09 13:36                                               ` SF Markus Elfring
@ 2014-03-09 13:40                                                 ` Julia Lawall
  2014-03-09 13:51                                                   ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-09 13:40 UTC (permalink / raw)
  To: cocci

On Sun, 9 Mar 2014, SF Markus Elfring wrote:

> > I have no idea.  I would have sort of expected that it would return a
> > length of 2, but I guess it is reasonable, and even desirable, that it
> > does not.  What answer would you like?
>
> I would expect that it will be treated by the SmPL pattern as a function with a
> single named parameter at least. I am unsure how the "ellipsis" should be
> counted and matched in the signature eventually.
>
> Does this small source file indicate that there might be further difficulties
> for data analysis of variadic functions?

Without knowing what you mean by "data analysis" it is impossible to tell.
It is clear that there is some problem with ... matching a parameter-typed
metavariable.  This could be considered reasonable, because ... is not a
(single) parameter.

julia

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

* [Cocci] Determination of the number for named function parameters
  2014-03-09 13:40                                                 ` Julia Lawall
@ 2014-03-09 13:51                                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-09 13:51 UTC (permalink / raw)
  To: cocci

> Without knowing what you mean by "data analysis" it is impossible to tell.

I mean the existence check for a parameter like "format" or extraction of a
position for the function signature.


> It is clear that there is some problem with ... matching a parameter-typed metavariable.

Thanks that you agree to this detail. Would you like to test the handling of
variadic macros and functions also in other situations?


> This could be considered reasonable, because ... is not a (single) parameter.

Is there any special mapping of the "ellipsis" at this place in the semantic
patch language needed?

Regards,
Markus

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

* [Cocci] Selection of class libraries ...?
  2014-03-09  8:12                                         ` Julia Lawall
  2014-03-09  8:50                                           ` SF Markus Elfring
  2014-03-09 12:51                                           ` SF Markus Elfring
@ 2014-03-10 18:00                                           ` SF Markus Elfring
  2014-03-10 18:19                                             ` Julia Lawall
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-10 18:00 UTC (permalink / raw)
  To: cocci

> I didn't implement it, and I never use python.

Would you like to suggest any references for class libraries which work in OCaml
with popular data structures in a way I am used to from other programming languages?
Is the "convenience" and software speed similar there?

Regards,
Markus

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

* [Cocci] Selection of class libraries ...?
  2014-03-10 18:00                                           ` [Cocci] Selection of class libraries ...? SF Markus Elfring
@ 2014-03-10 18:19                                             ` Julia Lawall
  2014-03-10 18:30                                               ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-10 18:19 UTC (permalink / raw)
  To: cocci

On Mon, 10 Mar 2014, SF Markus Elfring wrote:

> > I didn't implement it, and I never use python.
>
> Would you like to suggest any references for class libraries which work in OCaml
> with popular data structures in a way I am used to from other programming languages?
> Is the "convenience" and software speed similar there?

I have no idea what you are asking for.

julia

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

* [Cocci] Selection of class libraries ...?
  2014-03-10 18:19                                             ` Julia Lawall
@ 2014-03-10 18:30                                               ` SF Markus Elfring
  2014-03-10 19:24                                                 ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-10 18:30 UTC (permalink / raw)
  To: cocci

>> Would you like to suggest any references for class libraries which work in OCaml
>> with popular data structures in a way I am used to from other programming languages?
>> Is the "convenience" and software speed similar there?
> 
> I have no idea what you are asking for.

The programming language "OCaml" has got the property that values from standard
data types are immutable. Now I am looking for a well-known OCaml class library
which supports the modification of data structures like strings and lists in
place. I would prefer to reuse an existing one instead of developing another
variation for my experiments.

Regards,
Markus

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

* [Cocci] Selection of class libraries ...?
  2014-03-10 18:30                                               ` SF Markus Elfring
@ 2014-03-10 19:24                                                 ` Julia Lawall
  2014-03-10 21:10                                                   ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-10 19:24 UTC (permalink / raw)
  To: cocci

On Mon, 10 Mar 2014, SF Markus Elfring wrote:

> >> Would you like to suggest any references for class libraries which work in OCaml
> >> with popular data structures in a way I am used to from other programming languages?
> >> Is the "convenience" and software speed similar there?
> > 
> > I have no idea what you are asking for.
> 
> The programming language "OCaml" has got the property that values from standard
> data types are immutable. Now I am looking for a well-known OCaml class library
> which supports the modification of data structures like strings and lists in
> place. I would prefer to reuse an existing one instead of developing another
> variation for my experiments.

Why do you want to do this?  There is a String.set function that allows 
you to modify a character of a string.  For a list, if you need to modify 
an element then it should be a list of reference cells.  But I think that 
in practice it would be strange for either operation to be necessary.

julia

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

* [Cocci] Selection of class libraries ...?
  2014-03-10 19:24                                                 ` Julia Lawall
@ 2014-03-10 21:10                                                   ` SF Markus Elfring
  2014-03-10 21:15                                                     ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-10 21:10 UTC (permalink / raw)
  To: cocci

> Why do you want to do this?  There is a String.set function that allows 
> you to modify a character of a string.  For a list, if you need to modify 
> an element then it should be a list of reference cells.  But I think that 
> in practice it would be strange for either operation to be necessary.

I would like to avoid unwanted run time behaviour because of unnecessary data
copying when I will append text lines to a growing list.
http://ocaml.org/learn/tutorials/comparison_of_standard_containers.html#Listsimmutablesinglylinkedlists

I imagine that in-place modification will be a more efficient approach for my
use case. Is a kind of list buffer available?

Regards,
Markus

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

* [Cocci] Selection of class libraries ...?
  2014-03-10 21:10                                                   ` SF Markus Elfring
@ 2014-03-10 21:15                                                     ` Julia Lawall
  2014-03-10 21:26                                                       ` SF Markus Elfring
  2014-03-12 10:10                                                       ` [Cocci] Clarification for OCaml scripts in SmPL SF Markus Elfring
  0 siblings, 2 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-03-10 21:15 UTC (permalink / raw)
  To: cocci



On Mon, 10 Mar 2014, SF Markus Elfring wrote:

> > Why do you want to do this?  There is a String.set function that allows 
> > you to modify a character of a string.  For a list, if you need to modify 
> > an element then it should be a list of reference cells.  But I think that 
> > in practice it would be strange for either operation to be necessary.
> 
> I would like to avoid unwanted run time behaviour because of unnecessary data
> copying when I will append text lines to a growing list.
> http://ocaml.org/learn/tutorials/comparison_of_standard_containers.html#Listsimmutablesinglylinkedlists
> 
> I imagine that in-place modification will be a more efficient approach for my
> use case. Is a kind of list buffer available?

You can just add information to the front of the list, and then reverse it 
at the end if that is needed.

julia

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

* [Cocci] Selection of class libraries ...?
  2014-03-10 21:15                                                     ` Julia Lawall
@ 2014-03-10 21:26                                                       ` SF Markus Elfring
  2014-03-12 10:10                                                       ` [Cocci] Clarification for OCaml scripts in SmPL SF Markus Elfring
  1 sibling, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-10 21:26 UTC (permalink / raw)
  To: cocci

> You can just add information to the front of the list, and then reverse it 
> at the end if that is needed.

I would like to avoid even insertion at some list heads and a corresponding
element reordering because of software efficiency considerations.
Is a data structure available for OCaml which is similar to a standard buffer?
http://ocaml.org/learn/tutorials/comparison_of_standard_containers.html#Bufferextensiblestrings

Regards,
Markus

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-10 21:15                                                     ` Julia Lawall
  2014-03-10 21:26                                                       ` SF Markus Elfring
@ 2014-03-12 10:10                                                       ` SF Markus Elfring
  2014-03-12 12:10                                                         ` SF Markus Elfring
                                                                           ` (2 more replies)
  1 sibling, 3 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-12 10:10 UTC (permalink / raw)
  To: cocci

>> I imagine that in-place modification will be a more efficient approach for my
>> use case. Is a kind of list buffer available?
> 
> You can just add information to the front of the list, and then reverse it 
> at the end if that is needed.

I am trying to convert Python statements into similar OCaml functionality for
one of my semantic patch examples.

@initialize:ocaml@
@@
let result = Queue.create ()

let current_function = ref ""
let current_count = ref ""
let empty = ""
let delimiter = "|"
let quote = "\""
let quote2 = "\"\""
let mark text = String.concat empty [quote; text; quote]

let replace text =
    let length = String.length text in
    let part = Buffer.create length in
    for x = 0 to length - 1 do
        if text.[x] = '"' then
           Buffer.add_string part quote2
        else
           Buffer.add_char part text.[x]
    done;
    Buffer.contents part


(* Add a source code position to an internal list. *)
let append place =
    Queue.add (String.concat delimiter [!current_function;
                                        !current_count;
                                        mark (replace place.file);
                                        string_of_int place.line;
                                        string_of_int (place.column + 1)]) result

let store_positions fun count places =
    current_function := fun;
    current_count := string_of_int count;
    List.iter append places

@no_input@
identifier fun;
position pos;
@@
 fun at pos(void) { ... }

@input depends on no_input@
identifier fun;
parameter list [count] pl;
position pos != no_input.pos;
@@
 fun at pos(pl) { ... }

@script:ocaml collection@
fun << input.fun;
count << input.count;
places << input.pos;
@@
store_positions fun count places

@finalize:ocaml@
@@
if Queue.is_empty result then
   Printf.eprintf "No result for this analysis!\n"
else
   let output text = Printf.printf "%s\r\n" text in
   Printf.printf "%s\r\n" (String.concat delimiter ["function";
                                                    "\"parameter count\"";
                                                    "\"source file\"";
                                                    "line";
                                                    "column"]);
   Queue.iter output result



The source code from this SmPL finalisation rule works as expected in a OCaml
command line interface. Now I wonder about the following error message.

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
list_function_parameters3.cocci ../Probe/f-ptr-test1.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
File "list_function_parameters3.cocci", line 69, column 27,  charpos = 1914
    around = '', whole content =    Queue.iter output result
Fatal error: exception Failure("lexing: empty token")


I would appreciate your advices.

Regards,
Markus

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-12 10:10                                                       ` [Cocci] Clarification for OCaml scripts in SmPL SF Markus Elfring
@ 2014-03-12 12:10                                                         ` SF Markus Elfring
  2014-03-14  0:19                                                           ` Julia Lawall
  2014-03-13 23:56                                                         ` Julia Lawall
  2014-03-14  0:09                                                         ` Julia Lawall
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-12 12:10 UTC (permalink / raw)
  To: cocci

> let store_positions fun count places =
>     current_function := fun;

Does OCaml not like my name selection here?
Do I accidentally stumble on another software development "surprise" with
reserved key words?
http://ocaml.org/learn/faq.html

  let store_positions fu count places =
      current_fu := fu;
      current_count := string_of_int count;
      List.iter append places

Regards,
Markus

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-12 10:10                                                       ` [Cocci] Clarification for OCaml scripts in SmPL SF Markus Elfring
  2014-03-12 12:10                                                         ` SF Markus Elfring
@ 2014-03-13 23:56                                                         ` Julia Lawall
  2014-03-13 23:58                                                           ` Julia Lawall
  2014-03-14  0:09                                                         ` Julia Lawall
  2 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-13 23:56 UTC (permalink / raw)
  To: cocci

>    let output text = Printf.printf "%s\r\n" text in

It's not related to the problem, but I'm not sure to understand "let
output text = ..."  Normally the left hand side of a let has only one
variable.

julia

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-13 23:56                                                         ` Julia Lawall
@ 2014-03-13 23:58                                                           ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-03-13 23:58 UTC (permalink / raw)
  To: cocci



On Thu, 13 Mar 2014, Julia Lawall wrote:

> >    let output text = Printf.printf "%s\r\n" text in
>
> It's not related to the problem, but I'm not sure to understand "let
> output text = ..."  Normally the left hand side of a let has only one
> variable.

I'm sorry.  That was a stupid comment :)  It is the definition fo a
function.

julia

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-12 10:10                                                       ` [Cocci] Clarification for OCaml scripts in SmPL SF Markus Elfring
  2014-03-12 12:10                                                         ` SF Markus Elfring
  2014-03-13 23:56                                                         ` Julia Lawall
@ 2014-03-14  0:09                                                         ` Julia Lawall
  2014-03-14  7:14                                                           ` SF Markus Elfring
  2 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-14  0:09 UTC (permalink / raw)
  To: cocci

I think that the problem is in the use of \" and perhaps especially '"'.
I'm not sure that what you are doing is the normal ocaml way to do what
you want to do.  Could you explain in words what replace is supposed to
do, for example?  I never use either for loops or Buffers.

julia

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-12 12:10                                                         ` SF Markus Elfring
@ 2014-03-14  0:19                                                           ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-03-14  0:19 UTC (permalink / raw)
  To: cocci

On Wed, 12 Mar 2014, SF Markus Elfring wrote:

> > let store_positions fun count places =
> >     current_function := fun;
>
> Does OCaml not like my name selection here?
> Do I accidentally stumble on another software development "surprise" with
> reserved key words?

Well, it is not really a surprise.  Fun is indeed a reserved keyword in
ocaml.

julia

> http://ocaml.org/learn/faq.html
>
>   let store_positions fu count places =
>       current_fu := fu;
>       current_count := string_of_int count;
>       List.iter append places
>
> Regards,
> Markus
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-14  0:09                                                         ` Julia Lawall
@ 2014-03-14  7:14                                                           ` SF Markus Elfring
  2014-03-14  8:29                                                             ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-14  7:14 UTC (permalink / raw)
  To: cocci

> Could you explain in words what replace is supposed to do, for example?

Yes, of course.

It should replace each quotation mark in a string by two of this character.
(Quotes should become duplicated.)


> I never use either for loops or Buffers.

Which elements would you prefer to reuse from the programming language "OCaml"
for the shown use case?

Regards,
Markus

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-14  7:14                                                           ` SF Markus Elfring
@ 2014-03-14  8:29                                                             ` Julia Lawall
  2014-03-14  8:39                                                               ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-14  8:29 UTC (permalink / raw)
  To: cocci

On Fri, 14 Mar 2014, SF Markus Elfring wrote:

> > Could you explain in words what replace is supposed to do, for example?
>
> Yes, of course.
>
> It should replace each quotation mark in a string by two of this character.
> (Quotes should become duplicated.)

The string in question is the file name from a position variable.  A file
name does not contain a quote character.  When you print a string, it
appears as eg "foo", but the only characters in the string are f o and o.
If you want to put a quote character before and after, The simplest would
be: Printf.sprintf "\"%s\"" place.file.

julia

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-14  8:29                                                             ` Julia Lawall
@ 2014-03-14  8:39                                                               ` SF Markus Elfring
  2014-03-14  8:48                                                                 ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-14  8:39 UTC (permalink / raw)
  To: cocci

> The string in question is the file name from a position variable.  A file
> name does not contain a quote character.

I would prefer to handle also the general case that such strings contain
quotation marks eventually.

It depends on the analysis area if corresponding safety checks for special
characters will matter, doesn't it?

Other example:
https://github.com/coccinelle/coccinelle/issues/5

Regards,
Markus

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-14  8:39                                                               ` SF Markus Elfring
@ 2014-03-14  8:48                                                                 ` Julia Lawall
  2014-03-14  9:01                                                                   ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-14  8:48 UTC (permalink / raw)
  To: cocci

On Fri, 14 Mar 2014, SF Markus Elfring wrote:

> > The string in question is the file name from a position variable.  A file
> > name does not contain a quote character.
>
> I would prefer to handle also the general case that such strings contain
> quotation marks eventually.

Why would a file name contain a quote character.  And if it does, what
good will adding exxtra ones do you.  If the name is

foo\"bar

you will have

"foo\""bar"

and your string will be misparsed by your database.

julia

> It depends on the analysis area if corresponding safety checks for special
> characters will matter, doesn't it?
>
> Other example:
> https://github.com/coccinelle/coccinelle/issues/5
>
> Regards,
> Markus
>

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

* [Cocci] Clarification for OCaml scripts in SmPL
  2014-03-14  8:48                                                                 ` Julia Lawall
@ 2014-03-14  9:01                                                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-14  9:01 UTC (permalink / raw)
  To: cocci

> Why would a file name contain a quote character.

I do not really know how often this case happens in the world of detailed data
processing.


> And if it does, what good will adding exxtra ones do you.

I hope to ensure constraints for the used data formats.


> ... and your string will be misparsed by your database.

I do not think so. I try to achieve quoting by the discussed function
implementation so that a column/field in a CSV file will be generally treated as
a text string.

Regards,
Markus

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

* [Cocci] Determination of the number for named function parameters
  2014-03-09  8:50                                           ` SF Markus Elfring
@ 2014-03-14 14:25                                             ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-14 14:25 UTC (permalink / raw)
  To: cocci

> 2. Comparison for the incidence of unnamed function parameters to all of them

I am trying out a bit more preparation with OCaml script development for this
report variant.


@initialize:ocaml@
@@
module My_map = Map.Make(Int64)

let m = ref My_map.empty

let counting dir =
    let d = Unix.opendir dir in
    try while true do
        let name = Unix.readdir d in
        let length = Int64.of_int (String.length name) in

        if My_map.mem length (! m) then
           ignore (m := My_map.add length (Int64.add (My_map.find length (! m))
Int64.one) (! m))
        else
           ignore (m := My_map.add length Int64.one (! m))
        done
    with End_of_file -> Unix.closedir d

@find@
identifier fu;
@@
*fu(...)
 { ... }

@script:ocaml collection@
area << virtual.folder;
@@
if area = "" then
   counting "/"
else
   counting area

@finalize:ocaml@
@@
if My_map.is_empty (! m) then
   prerr_endline "No result for this analysis!"
else
   let delimiter = '|' in
   let output key count = Printf.printf "%Li%c%Li\r\n" key delimiter count in
   Printf.printf "length%cincidence\r\n" delimiter;
   My_map.iter output (! m)


elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
list_file_name_lengths1.cocci ../Probe/f-ptr-test1.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
Using native version of ocamlc/ocamlopt/ocamldep
ocamlopt.opt -shared -o /tmp/list_file_name_lengths1f3bae5.cmxs -g -I
/usr/lib64/ocaml  -I /usr/local/share/coccinelle/ocaml
/tmp/list_file_name_lengths1f3bae5.ml
Compilation OK!
Loading ML code of the SP...
HANDLING: ../Probe/f-ptr-test1.c
...
No result for this analysis!


How do you think about such a semantic patch approach?

Regards,
Markus

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-02-21 22:27 ` Julia Lawall
  2014-02-22  8:09   ` SF Markus Elfring
  2014-02-23 14:40   ` SF Markus Elfring
@ 2014-03-27 13:41   ` SF Markus Elfring
  2014-03-27 18:10     ` Julia Lawall
  2 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-27 13:41 UTC (permalink / raw)
  To: cocci

> Not sure what you mean by extended.  There are indeed some other functions 
> in Linux that perform NULL tests before doing anything, and thus they 
> don't really need a null test around them.

I have got another concern for a corresponding implementation detail.
How can a constraint be specified for the filter in the semantic patch
so that the expression refers only to non-volatile data?
Is it a software development challenge to exclude accesses on volatile
data elements eventually from the suggested deletion of condition checks?
https://en.wikipedia.org/wiki/Volatile_variable#In_C_and_C.2B.2B

Regards,
Markus

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-03-27 13:41   ` [Cocci] How to exclude volatile data accesses in expressions with SmPL? SF Markus Elfring
@ 2014-03-27 18:10     ` Julia Lawall
  2014-03-27 18:39       ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-03-27 18:10 UTC (permalink / raw)
  To: cocci



On Thu, 27 Mar 2014, SF Markus Elfring wrote:

> > Not sure what you mean by extended.  There are indeed some other functions
> > in Linux that perform NULL tests before doing anything, and thus they
> > don't really need a null test around them.
>
> I have got another concern for a corresponding implementation detail.
> How can a constraint be specified for the filter in the semantic patch
> so that the expression refers only to non-volatile data?
> Is it a software development challenge to exclude accesses on volatile
> data elements eventually from the suggested deletion of condition checks?
> https://en.wikipedia.org/wiki/Volatile_variable#In_C_and_C.2B.2B

Perhaps it is possible to write:

@@
volatile x;
@@

* x == NULL

Or maybe

@@
type T;
volatile T x;
@@

* x == NULL

Or at worst:

@@
type T;
identifier i;
@@

volatile T i;
...
*i == NULL

I don't know if this would find much.  Intuitively, one might expect such
problems to be detected easily by testing or developers to know better in
thw first place, but who knows.

julia

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-03-27 18:10     ` Julia Lawall
@ 2014-03-27 18:39       ` SF Markus Elfring
  2014-03-27 18:43         ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-27 18:39 UTC (permalink / raw)
  To: cocci

> I don't know if this would find much.  Intuitively, one might expect such
> problems to be detected easily by testing or developers to know better in
> thw first place, but who knows.

I see the software development challenge in the analysis of the
expression which is used in a condition check. Such an expression could
be constructed out of several elements.
I am still unsure on how a data type property like "volatile" can be
safely determined by the semantic patch language for each used element.
I would be able to specify a filter for a single element as you suggest.
But is the combination of some elements more interesting for the general
use case?

Regards,
Markus

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-03-27 18:39       ` SF Markus Elfring
@ 2014-03-27 18:43         ` Julia Lawall
  2014-03-27 18:59           ` SF Markus Elfring
  2014-04-07 15:07           ` SF Markus Elfring
  0 siblings, 2 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-03-27 18:43 UTC (permalink / raw)
  To: cocci

On Thu, 27 Mar 2014, SF Markus Elfring wrote:

> > I don't know if this would find much.  Intuitively, one might expect such
> > problems to be detected easily by testing or developers to know better in
> > thw first place, but who knows.
>
> I see the software development challenge in the analysis of the
> expression which is used in a condition check. Such an expression could
> be constructed out of several elements.
> I am still unsure on how a data type property like "volatile" can be
> safely determined by the semantic patch language for each used element.
> I would be able to specify a filter for a single element as you suggest.
> But is the combination of some elements more interesting for the general
> use case?

Coccinelle makes an effort to infer types.  YOu may need to use eg
--recursive-includes and --relax-include-path to get the most possible
type information.

julia

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-03-27 18:43         ` Julia Lawall
@ 2014-03-27 18:59           ` SF Markus Elfring
  2014-04-07 15:07           ` SF Markus Elfring
  1 sibling, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-03-27 18:59 UTC (permalink / raw)
  To: cocci

> Coccinelle makes an effort to infer types.  YOu may need to use eg
> --recursive-includes and --relax-include-path to get the most possible
> type information.

It is nice when a simple filter pattern works in principle. A filter
pattern which needs the knowledge about all data type details to
consider relevant constraints will need more time for the data analysis.
I hope that the corresponding execution speed can also be improved.

Regards,
Markus

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-03-27 18:43         ` Julia Lawall
  2014-03-27 18:59           ` SF Markus Elfring
@ 2014-04-07 15:07           ` SF Markus Elfring
  2014-04-07 15:16             ` Julia Lawall
  1 sibling, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-04-07 15:07 UTC (permalink / raw)
  To: cocci

> Coccinelle makes an effort to infer types.  YOu may need to use eg
> --recursive-includes and --relax-include-path to get the most possible
> type information.

How do you think about to make it possible to check attributes for expressions
in SmPL constraints?

Regards,
Markus

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-04-07 15:07           ` SF Markus Elfring
@ 2014-04-07 15:16             ` Julia Lawall
  2014-04-07 15:28               ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-04-07 15:16 UTC (permalink / raw)
  To: cocci



On Mon, 7 Apr 2014, SF Markus Elfring wrote:

> > Coccinelle makes an effort to infer types.  YOu may need to use eg
> > --recursive-includes and --relax-include-path to get the most possible
> > type information.
>
> How do you think about to make it possible to check attributes for expressions
> in SmPL constraints?

I tried to do this at one point, but it introduced a lot of parsing
problems, because attributes can appear in a variety of places.  The
benefit didn't seem to be worth the risk.

julia

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-04-07 15:16             ` Julia Lawall
@ 2014-04-07 15:28               ` SF Markus Elfring
  2014-04-07 15:34                 ` Julia Lawall
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-04-07 15:28 UTC (permalink / raw)
  To: cocci

>> How do you think about to make it possible to check attributes for expressions
>> in SmPL constraints?
> 
> I tried to do this at one point, but it introduced a lot of parsing
> problems, because attributes can appear in a variety of places.

Which kind of syntax had you got in mind for such a functionality?

Is there a need to distinguish property checks from support for extensions from
a popular compiler implementation?
http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/Type-Attributes.html


> The benefit didn't seem to be worth the risk.

Can we clarify your concerns a bit more here?

Regards,
Markus

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-04-07 15:28               ` SF Markus Elfring
@ 2014-04-07 15:34                 ` Julia Lawall
  2014-04-07 15:40                   ` SF Markus Elfring
  0 siblings, 1 reply; 3633+ messages in thread
From: Julia Lawall @ 2014-04-07 15:34 UTC (permalink / raw)
  To: cocci



On Mon, 7 Apr 2014, SF Markus Elfring wrote:

> >> How do you think about to make it possible to check attributes for expressions
> >> in SmPL constraints?
> >
> > I tried to do this at one point, but it introduced a lot of parsing
> > problems, because attributes can appear in a variety of places.
>
> Which kind of syntax had you got in mind for such a functionality?
>
> Is there a need to distinguish property checks from support for extensions from
> a popular compiler implementation?
> http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/Type-Attributes.html
>
>
> > The benefit didn't seem to be worth the risk.
>
> Can we clarify your concerns a bit more here?

To my recollection, there were problems of ambiguity in the parser.
Also, I think it made the abstract syntax tree unwieldy, because
attributes had to be taken into account in many positions.

julia

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

* [Cocci] How to exclude volatile data accesses in expressions with SmPL?
  2014-04-07 15:34                 ` Julia Lawall
@ 2014-04-07 15:40                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-04-07 15:40 UTC (permalink / raw)
  To: cocci

> To my recollection, there were problems of ambiguity in the parser.
> Also, I think it made the abstract syntax tree unwieldy, because
> attributes had to be taken into account in many positions.

Would you like to give it another try?

Regards,
Markus

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

* [Cocci] Fix for "lexing: empty token" needed?
  2014-03-06 16:24                                     ` Julia Lawall
  2014-03-06 17:04                                       ` SF Markus Elfring
@ 2014-09-30 13:24                                       ` SF Markus Elfring
  1 sibling, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-09-30 13:24 UTC (permalink / raw)
  To: cocci

>> I have looked into my log files once more so that I can give you another
>> feedback for a "regexp problem".
> 
> I can't reproduce this.  I need the semantic patch.

It seems that you could fix this issue with the software release "1.0.0-rc22".

I have tried out the discussed approach on the source files for the operating
system "Linux 3.16.3" once more. Now I stumble on another error message.

elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --version &&
OCAMLRUNPARAM=b spatch.opt --sp-file
list_functions_with_unnecessary_checks1.cocci /usr/src/linux-stable/crypto/fcrypt.c
spatch version 1.0.0-rc22 with Python support and with PCRE support
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: /usr/src/linux-stable/crypto/fcrypt.c
Fatal error: exception Failure("lexing: empty token")
Raised at file "lexing.ml", line 65, characters 15-37


Can this detail also be improved?

Regards,
Markus

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

* Re: [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-10-01 13:01                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 13:01 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton, Stephen Rothwell
  Cc: Coccinelle, kernel-janitors, Michal Marek, Chi Pham,
	Fabian Frederick, Joe Perches

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Hello,

A couple of functions perform input parameter validation before their
implementations will try further actions with side effects. Some calling
functions perform similar safety checks.

Functions which release a system resource are occasionally documented in the way
that they tolerate the passing of a null pointer for example.
I do not see a need because of this fact that a function caller repeats a
corresponding check.

Now I would like to propose such a change again.

1. Extension of the infrastructure for the analysis tool "coccicheck"
   Semantic patch patterns can help to identify update candidates also in the
Linux source file hierarchy.

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/scripts/coccinelle?id=79f0345fefaafb7cde301a830471edd21a37989b

   Would you like to reconsider an approach which was discussed with a subject
like "scripts/coccinelle/free: Delete NULL test before freeing functions?" a
while ago?
   https://lkml.org/lkml/2014/8/9/36
   https://groups.google.com/d/msg/linux.kernel/rIWfYsRRW6I/cTs6y0STf2cJ


2. Clarification for some automated update suggestions
   My source code search approach found 227 functions with the help of the
software "Coccinelle 1.0.0-rc22" at least which might need another review and
corresponding corrections for Linux 3.16.3. Further software development will
point out even more potentially open issues.

Regards,
Markus


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

* Re: [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 13:01                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 13:01 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Hello,

A couple of functions perform input parameter validation before their
implementations will try further actions with side effects. Some calling
functions perform similar safety checks.

Functions which release a system resource are occasionally documented in the way
that they tolerate the passing of a null pointer for example.
I do not see a need because of this fact that a function caller repeats a
corresponding check.

Now I would like to propose such a change again.

1. Extension of the infrastructure for the analysis tool "coccicheck"
   Semantic patch patterns can help to identify update candidates also in the
Linux source file hierarchy.

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/scripts/coccinelle?idyf0345fefaafb7cde301a830471edd21a37989b

   Would you like to reconsider an approach which was discussed with a subject
like "scripts/coccinelle/free: Delete NULL test before freeing functions?" a
while ago?
   https://lkml.org/lkml/2014/8/9/36
   https://groups.google.com/d/msg/linux.kernel/rIWfYsRRW6I/cTs6y0STf2cJ


2. Clarification for some automated update suggestions
   My source code search approach found 227 functions with the help of the
software "Coccinelle 1.0.0-rc22" at least which might need another review and
corresponding corrections for Linux 3.16.3. Further software development will
point out even more potentially open issues.

Regards,
Markus


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

* [Cocci] [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 13:01                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 13:01 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Hello,

A couple of functions perform input parameter validation before their
implementations will try further actions with side effects. Some calling
functions perform similar safety checks.

Functions which release a system resource are occasionally documented in the way
that they tolerate the passing of a null pointer for example.
I do not see a need because of this fact that a function caller repeats a
corresponding check.

Now I would like to propose such a change again.

1. Extension of the infrastructure for the analysis tool "coccicheck"
   Semantic patch patterns can help to identify update candidates also in the
Linux source file hierarchy.

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/scripts/coccinelle?id=79f0345fefaafb7cde301a830471edd21a37989b

   Would you like to reconsider an approach which was discussed with a subject
like "scripts/coccinelle/free: Delete NULL test before freeing functions?" a
while ago?
   https://lkml.org/lkml/2014/8/9/36
   https://groups.google.com/d/msg/linux.kernel/rIWfYsRRW6I/cTs6y0STf2cJ


2. Clarification for some automated update suggestions
   My source code search approach found 227 functions with the help of the
software "Coccinelle 1.0.0-rc22" at least which might need another review and
corresponding corrections for Linux 3.16.3. Further software development will
point out even more potentially open issues.

Regards,
Markus

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

* Re: [coccicheck PATCH 1/5] Deletion of unnecessary checks before specific function calls
  2014-10-01 13:01                                   ` SF Markus Elfring
  (?)
@ 2014-10-01 14:06                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:06 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton, Stephen Rothwell
  Cc: Coccinelle, kernel-janitors, Michal Marek, Chi Pham,
	Fabian Frederick, Joe Perches

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From 48c9c4f61a7d7ea98538e02631a981a429281005 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:15:34 +0100
Subject: [PATCH 1/5] Addition of a semantic patch file for showing unnecessary
 checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../deletions/delete_unnecessary_checks_template1.cocci     | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..b092051
--- /dev/null
+++ b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
@@ -0,0 +1,13 @@
+@Delete_unnecessary_checks@
+expression x;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+@@
+-if (x)
+    release(x);
-- 
1.9.0



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

* Re: [coccicheck PATCH 1/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:06                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:06 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

From 48c9c4f61a7d7ea98538e02631a981a429281005 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:15:34 +0100
Subject: [PATCH 1/5] Addition of a semantic patch file for showing unnecessary
 checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../deletions/delete_unnecessary_checks_template1.cocci     | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..b092051
--- /dev/null
+++ b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
@@ -0,0 +1,13 @@
+@Delete_unnecessary_checks@
+expression x;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+@@
+-if (x)
+    release(x);
-- 
1.9.0



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

* [Cocci] [coccicheck PATCH 1/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:06                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:06 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From 48c9c4f61a7d7ea98538e02631a981a429281005 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:15:34 +0100
Subject: [PATCH 1/5] Addition of a semantic patch file for showing unnecessary
 checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../deletions/delete_unnecessary_checks_template1.cocci     | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..b092051
--- /dev/null
+++ b/scripts/coccinelle/deletions/delete_unnecessary_checks_template1.cocci
@@ -0,0 +1,13 @@
+ at Delete_unnecessary_checks@
+expression x;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+@@
+-if (x)
+    release(x);
-- 
1.9.0

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

* Re: [coccicheck PATCH 2/5] Deletion of unnecessary checks before specific function calls
  2014-10-01 13:01                                   ` SF Markus Elfring
  (?)
@ 2014-10-01 14:06                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:06 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton, Stephen Rothwell
  Cc: Coccinelle, kernel-janitors, Michal Marek, Chi Pham,
	Fabian Frederick, Joe Perches

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From 1d2de3c3cfa43cc3c78a91200c41cef438b26a8f Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:38:43 +0100
Subject: [PATCH 2/5] Addition of a semantic patch file for listing of
 functions that check their single parameter

This semantic patch pattern tries to find functions that check their single
parameter for usability.

Example:
Null pointer checks are often performed as input parameter validation.

It uses Python statements to write information about the found source code
places in a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../list_input_parameter_validation1.cocci         | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_input_parameter_validation1.cocci

diff --git a/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
new file mode 100644
index 0000000..b0a5a52
--- /dev/null
+++ b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
@@ -0,0 +1,55 @@
+@initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, typ, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        mark[1] = typ
+        fields.append(''.join(mark))
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+@safety_check@
+identifier work, input;
+type data_type;
+position pos;
+statement is, es;
+@@
+ void work@pos(data_type input)
+ {
+  ... when any
+( if (input) is else es
+| if (likely(input)) is else es
+)
+  ... when any
+ }
+
+@script:python collection depends on safety_check@
+typ << safety_check.data_type;
+fun << safety_check.work;
+point << safety_check.input;
+places << safety_check.pos;
+@@
+store_positions(fun, typ, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
'"source file"', "line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0



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

* Re: [coccicheck PATCH 2/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:06                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:06 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

From 1d2de3c3cfa43cc3c78a91200c41cef438b26a8f Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:38:43 +0100
Subject: [PATCH 2/5] Addition of a semantic patch file for listing of
 functions that check their single parameter

This semantic patch pattern tries to find functions that check their single
parameter for usability.

Example:
Null pointer checks are often performed as input parameter validation.

It uses Python statements to write information about the found source code
places in a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../list_input_parameter_validation1.cocci         | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_input_parameter_validation1.cocci

diff --git a/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
new file mode 100644
index 0000000..b0a5a52
--- /dev/null
+++ b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
@@ -0,0 +1,55 @@
+@initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, typ, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        mark[1] = typ
+        fields.append(''.join(mark))
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+@safety_check@
+identifier work, input;
+type data_type;
+position pos;
+statement is, es;
+@@
+ void work@pos(data_type input)
+ {
+  ... when any
+( if (input) is else es
+| if (likely(input)) is else es
+)
+  ... when any
+ }
+
+@script:python collection depends on safety_check@
+typ << safety_check.data_type;
+fun << safety_check.work;
+point << safety_check.input;
+places << safety_check.pos;
+@@
+store_positions(fun, typ, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
'"source file"', "line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0



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

* [Cocci] [coccicheck PATCH 2/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:06                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:06 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From 1d2de3c3cfa43cc3c78a91200c41cef438b26a8f Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:38:43 +0100
Subject: [PATCH 2/5] Addition of a semantic patch file for listing of
 functions that check their single parameter

This semantic patch pattern tries to find functions that check their single
parameter for usability.

Example:
Null pointer checks are often performed as input parameter validation.

It uses Python statements to write information about the found source code
places in a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../list_input_parameter_validation1.cocci         | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_input_parameter_validation1.cocci

diff --git a/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
new file mode 100644
index 0000000..b0a5a52
--- /dev/null
+++ b/scripts/coccinelle/deletions/list_input_parameter_validation1.cocci
@@ -0,0 +1,55 @@
+ at initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, typ, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        mark[1] = typ
+        fields.append(''.join(mark))
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+ at safety_check@
+identifier work, input;
+type data_type;
+position pos;
+statement is, es;
+@@
+ void work at pos(data_type input)
+ {
+  ... when any
+( if (input) is else es
+| if (likely(input)) is else es
+)
+  ... when any
+ }
+
+ at script:python collection depends on safety_check@
+typ << safety_check.data_type;
+fun << safety_check.work;
+point << safety_check.input;
+places << safety_check.pos;
+@@
+store_positions(fun, typ, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"data type"', '"parameter"',
'"source file"', "line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0

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

* Re: [coccicheck PATCH 3/5] Deletion of unnecessary checks before specific function calls
  2014-10-01 13:01                                   ` SF Markus Elfring
  (?)
@ 2014-10-01 14:06                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:06 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton, Stephen Rothwell
  Cc: Coccinelle, kernel-janitors, Michal Marek, Chi Pham,
	Fabian Frederick, Joe Perches

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From f4608fceec40b2b94aa9b4abe3bbb6d98ed5eed9 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:58:30 +0100
Subject: [PATCH 3/5] Addition of a SQLite script for a text file import

A script was added so that a text file which was previously generated can be
imported into a SQLite data base table.
http://sqlite.org/sqlite.html

The shown file name can be adjusted by a make file for example.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/deletions/handle_function_list_template.sqlite    | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/handle_function_list_template.sqlite

diff --git a/scripts/coccinelle/deletions/handle_function_list_template.sqlite
b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
new file mode 100644
index 0000000..bec366c
--- /dev/null
+++ b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
@@ -0,0 +1,9 @@
+create table positions(function text,
+                       data_type text,
+                       parameter text,
+                       source_file text,
+                       line integer,
+                       column integer);
+.separator "|"
+.import list_input_pointer_validation1.txt positions
+.header OFF
-- 
1.9.0




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

* Re: [coccicheck PATCH 3/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:06                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:06 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

From f4608fceec40b2b94aa9b4abe3bbb6d98ed5eed9 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:58:30 +0100
Subject: [PATCH 3/5] Addition of a SQLite script for a text file import

A script was added so that a text file which was previously generated can be
imported into a SQLite data base table.
http://sqlite.org/sqlite.html

The shown file name can be adjusted by a make file for example.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/deletions/handle_function_list_template.sqlite    | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/handle_function_list_template.sqlite

diff --git a/scripts/coccinelle/deletions/handle_function_list_template.sqlite
b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
new file mode 100644
index 0000000..bec366c
--- /dev/null
+++ b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
@@ -0,0 +1,9 @@
+create table positions(function text,
+                       data_type text,
+                       parameter text,
+                       source_file text,
+                       line integer,
+                       column integer);
+.separator "|"
+.import list_input_pointer_validation1.txt positions
+.header OFF
-- 
1.9.0




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

* [Cocci] [coccicheck PATCH 3/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:06                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:06 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From f4608fceec40b2b94aa9b4abe3bbb6d98ed5eed9 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 18:58:30 +0100
Subject: [PATCH 3/5] Addition of a SQLite script for a text file import

A script was added so that a text file which was previously generated can be
imported into a SQLite data base table.
http://sqlite.org/sqlite.html

The shown file name can be adjusted by a make file for example.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/deletions/handle_function_list_template.sqlite    | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/handle_function_list_template.sqlite

diff --git a/scripts/coccinelle/deletions/handle_function_list_template.sqlite
b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
new file mode 100644
index 0000000..bec366c
--- /dev/null
+++ b/scripts/coccinelle/deletions/handle_function_list_template.sqlite
@@ -0,0 +1,9 @@
+create table positions(function text,
+                       data_type text,
+                       parameter text,
+                       source_file text,
+                       line integer,
+                       column integer);
+.separator "|"
+.import list_input_pointer_validation1.txt positions
+.header OFF
-- 
1.9.0

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

* Re: [coccicheck PATCH 4/5] Deletion of unnecessary checks before specific function calls
  2014-10-01 13:01                                   ` SF Markus Elfring
  (?)
@ 2014-10-01 14:07                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:07 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton, Stephen Rothwell
  Cc: Coccinelle, kernel-janitors, Michal Marek, Chi Pham,
	Fabian Frederick, Joe Perches

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From e6a21b920fcca2f6f01c9528909dc036a9b3bc41 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:10:32 +0100
Subject: [PATCH 4/5] Addition of a semantic patch file for listing of
 unnecessary checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

It uses Python statements to write information about the found places in
a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 ...nctions_with_unnecessary_checks_template1.cocci | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..d2637e8
--- /dev/null
+++
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
@@ -0,0 +1,59 @@
+@initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+@is_unnecessary_check@
+expression data;
+identifier work;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+position pos;
+type t;
+@@
+ t work@pos(...)
+ {
+  ... when any
+( if (data) release(data);
+| if (likely(data)) release(data);
+)
+  ... when any
+ }
+
+@script:python collection depends on is_unnecessary_check@
+fun << is_unnecessary_check.work;
+point << is_unnecessary_check.data;
+places << is_unnecessary_check.pos;
+@@
+store_positions(fun, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"parameter"', '"source file"',
"line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0




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

* Re: [coccicheck PATCH 4/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:07                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:07 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

From e6a21b920fcca2f6f01c9528909dc036a9b3bc41 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:10:32 +0100
Subject: [PATCH 4/5] Addition of a semantic patch file for listing of
 unnecessary checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

It uses Python statements to write information about the found places in
a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 ...nctions_with_unnecessary_checks_template1.cocci | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..d2637e8
--- /dev/null
+++
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
@@ -0,0 +1,59 @@
+@initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+@is_unnecessary_check@
+expression data;
+identifier work;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+position pos;
+type t;
+@@
+ t work@pos(...)
+ {
+  ... when any
+( if (data) release(data);
+| if (likely(data)) release(data);
+)
+  ... when any
+ }
+
+@script:python collection depends on is_unnecessary_check@
+fun << is_unnecessary_check.work;
+point << is_unnecessary_check.data;
+places << is_unnecessary_check.pos;
+@@
+store_positions(fun, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"parameter"', '"source file"',
"line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0




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

* [Cocci] [coccicheck PATCH 4/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:07                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:07 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From e6a21b920fcca2f6f01c9528909dc036a9b3bc41 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:10:32 +0100
Subject: [PATCH 4/5] Addition of a semantic patch file for listing of
 unnecessary checks before a few known functions

This semantic patch pattern tries to find source code places where a check
is performed for an expression that is passed to a function (like "kfree")
which checks this single parameter itself for usability.
Redundant value or pointer checks can be avoided here.

The pattern contains a special comment in a regular expression for a SmPL
constraint which supports extensions.

It uses Python statements to write information about the found places in
a data format that is a variant of a CSV text file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 ...nctions_with_unnecessary_checks_template1.cocci | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644
scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci

diff --git
a/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
new file mode 100644
index 0000000..d2637e8
--- /dev/null
+++
b/scripts/coccinelle/deletions/list_functions_with_unnecessary_checks_template1.cocci
@@ -0,0 +1,59 @@
+ at initialize:python@
+@@
+import sys
+result = []
+mark = ['"', '', '"']
+delimiter = '|'
+
+def store_positions(fun, point, places):
+    """Add source code positions to an internal list."""
+    for place in places:
+        fields = []
+        fields.append(fun)
+
+        fields.append(point)
+
+        mark[1] = place.file.replace('"', '""')
+        fields.append(''.join(mark))
+
+        fields.append(place.line)
+        fields.append(str(int(place.column) + 1))
+        result.append(delimiter.join(fields))
+
+ at is_unnecessary_check@
+expression data;
+identifier work;
+identifier release =~ "^(?x)
+(?:
+   (?:kz?|slob_)free
+|
+   (?:
+# Alternation placeholder
+   )
+)$";
+position pos;
+type t;
+@@
+ t work at pos(...)
+ {
+  ... when any
+( if (data) release(data);
+| if (likely(data)) release(data);
+)
+  ... when any
+ }
+
+ at script:python collection depends on is_unnecessary_check@
+fun << is_unnecessary_check.work;
+point << is_unnecessary_check.data;
+places << is_unnecessary_check.pos;
+@@
+store_positions(fun, point, places)
+
+@finalize:python@
+@@
+if result:
+   result.insert(0, delimiter.join(("function", '"parameter"', '"source file"',
"line", "column")))
+   print("\r\n".join(result))
+else:
+   sys.stderr.write("No result for this analysis!\n")
-- 
1.9.0

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

* Re: [coccicheck PATCH 5/5] Deletion of unnecessary checks before specific function calls
  2014-10-01 13:01                                   ` SF Markus Elfring
  (?)
@ 2014-10-01 14:07                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:07 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton, Stephen Rothwell
  Cc: Coccinelle, kernel-janitors, Michal Marek, Chi Pham,
	Fabian Frederick, Joe Perches

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From bedf1cb3ddd162ee3b4c31cbb98d97431f70103d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:40:43 +0100
Subject: [PATCH 5/5] Addition of a make file for build automation

This script can be used to combine some input files for the desired data output
which will eventually show update candidates for further source code review.
Some build targets were defined. Values for the used make variables can be
adjusted by parameters on the command line as usual.

A few implementation details might need more fine-tuning.
- Automatic determination of the Linux source directory from a calling
  make process

- Setting of an extra output directory for the generated files

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/deletions/makefile | 126 ++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 scripts/coccinelle/deletions/makefile

diff --git a/scripts/coccinelle/deletions/makefile
b/scripts/coccinelle/deletions/makefile
new file mode 100644
index 0000000..6464bae
--- /dev/null
+++ b/scripts/coccinelle/deletions/makefile
@@ -0,0 +1,126 @@
+SED=sed
+SPATCH=spatch.opt --sp-file
+RM=rm -f
+LINUX_SOURCE_DIR=/usr/src/linux-stable
+EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.cocci
+SQLITE=sqlite3
+SQLITE_IMPORT_SCRIPT=handle_function_list.sqlite
+SQLITE_IMPORT_SCRIPT_TEMPLATE=handle_function_list_template.sqlite
+RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.txt
+RESULT_SQL_DATA_BASE=result.db
+RESULT_FUNCTIONS_WITH_PREFIX=add_prefix-SQL.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST=list_functions_with_unnecessary_checks1.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH=functions_with_unnecessary_checks1.diff
+LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1-errors.txt
+LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS=list_functions_with_unnecessary_checks1-errors.txt
+LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS=functions_with_unnecessary_checks1-errors.txt
+LIST_PATTERN_TEMPLATE=list_functions_with_unnecessary_checks_template1.cocci
+LIST_PATTERN=list_functions_with_unnecessary_checks1.cocci
+PATCH_PATTERN_TEMPLATE=delete_unnecessary_checks_template1.cocci
+PATCH_PATTERN=delete_unnecessary_checks1.cocci
+ESCAPING=XY=$$(< $(RESULT_FUNCTIONS_WITH_PREFIX)) \
+         && XY=$${XY/|/ } \
+         && XY=$${XY//%/\\%} \
+         && $(SED) "s%\# Alternation placeholder%$${XY//$$'\n'/$$'\\\\\n'}%"
+TEXT1=A pattern file was built from which a
+TEXT2=was generated. Good luck with source code review!
+
+default: build_update_candidate_list
+
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER): \
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	$(SPATCH) $(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+-dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+# This replacement action is needed for the use case that the corresponding
+# variable was overridden.
+$(SQLITE_IMPORT_SCRIPT): $(SQLITE_IMPORT_SCRIPT_TEMPLATE)
+	$(SED) "s%import list_input_pointer_validation1\.txt%import $(subst
%,\%,$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER))%" \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) > $@
+
+$(RESULT_SQL_DATA_BASE) $(RESULT_FUNCTIONS_WITH_PREFIX): \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+	@$(RM) $(RESULT_SQL_DATA_BASE)
+	$(SQLITE) -init $(SQLITE_IMPORT_SCRIPT) $(RESULT_SQL_DATA_BASE) \
+'select '\''   |  '\'' || function from positions group by function order by
function desc;' \
+> $(RESULT_FUNCTIONS_WITH_PREFIX)
+
+$(LIST_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(LIST_PATTERN_TEMPLATE) > $@
+
+$(PATCH_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(PATCH_PATTERN_TEMPLATE) > $@
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST): $(LIST_PATTERN)
+	$(SPATCH) $(LIST_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH): $(PATCH_PATTERN)
+	$(SPATCH) $(PATCH_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+build_check_list generate_list_of_functions_which_check_their_single_parameter: \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	@echo 'The list of functions which check their single parameter was generated.'
+
+build_import_script: $(SQLITE_IMPORT_SCRIPT)
+	@echo 'A script was generated which should contain appropriate parameters for
a data base.'
+
+build_data_base: $(RESULT_SQL_DATA_BASE)
+	@echo 'A SQL data base was built.'
+
+build_alternation add_prefix_to_functions: build_data_base
+	@echo 'The function name list was converted to a component for a regular
expression.'
+
+build_list_pattern: $(LIST_PATTERN)
+	@echo '$(TEXT1) list can be generated.'
+
+build_patch_pattern: $(PATCH_PATTERN)
+	@echo '$(TEXT1) patch can be generated.'
+
+build_update_candidate_list show_list_of_update_candidates: build_list_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST)
+	@echo 'The list of update candidates $(TEXT2)'
+
+build_patch show_update_suggestion: build_patch_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH)
+	@echo 'A patch file $(TEXT2)'
+
+all: build_update_candidate_list build_patch
+
+clean:
+	$(RM) *-errors.txt \
+$(LIST_PATTERN) \
+$(PATCH_PATTERN) \
+$(RESULT_FUNCTIONS_WITH_PREFIX) \
+$(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+
+delete_data_base:
+	$(RM) $(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+.PHONY: all \
+build_check_list \
+build_data_base \
+build_import_script \
+build_list_pattern \
+build_patch \
+build_patch_pattern \
+build_update_candidate_list \
+clean \
+default \
+delete_data_base \
+generate_list_of_functions_which_check_their_single_parameter \
+show_list_of_update_candidates \
+show_update_suggestion
+
+
+# The following input files should not need further actions here.
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) \
+$(LIST_PATTERN_TEMPLATE) \
+$(PATCH_PATTERN_TEMPLATE): ;
-- 
1.9.0



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

* Re: [coccicheck PATCH 5/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:07                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:07 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

From bedf1cb3ddd162ee3b4c31cbb98d97431f70103d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:40:43 +0100
Subject: [PATCH 5/5] Addition of a make file for build automation

This script can be used to combine some input files for the desired data output
which will eventually show update candidates for further source code review.
Some build targets were defined. Values for the used make variables can be
adjusted by parameters on the command line as usual.

A few implementation details might need more fine-tuning.
- Automatic determination of the Linux source directory from a calling
  make process

- Setting of an extra output directory for the generated files

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/deletions/makefile | 126 ++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 scripts/coccinelle/deletions/makefile

diff --git a/scripts/coccinelle/deletions/makefile
b/scripts/coccinelle/deletions/makefile
new file mode 100644
index 0000000..6464bae
--- /dev/null
+++ b/scripts/coccinelle/deletions/makefile
@@ -0,0 +1,126 @@
+SED=sed
+SPATCH=spatch.opt --sp-file
+RM=rm -f
+LINUX_SOURCE_DIR=/usr/src/linux-stable
+EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.cocci
+SQLITE=sqlite3
+SQLITE_IMPORT_SCRIPT=handle_function_list.sqlite
+SQLITE_IMPORT_SCRIPT_TEMPLATE=handle_function_list_template.sqlite
+RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.txt
+RESULT_SQL_DATA_BASE=result.db
+RESULT_FUNCTIONS_WITH_PREFIX­d_prefix-SQL.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST=list_functions_with_unnecessary_checks1.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH=functions_with_unnecessary_checks1.diff
+LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1-errors.txt
+LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS=list_functions_with_unnecessary_checks1-errors.txt
+LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS=functions_with_unnecessary_checks1-errors.txt
+LIST_PATTERN_TEMPLATE=list_functions_with_unnecessary_checks_template1.cocci
+LIST_PATTERN=list_functions_with_unnecessary_checks1.cocci
+PATCH_PATTERN_TEMPLATEÞlete_unnecessary_checks_template1.cocci
+PATCH_PATTERNÞlete_unnecessary_checks1.cocci
+ESCAPING=XY=$$(< $(RESULT_FUNCTIONS_WITH_PREFIX)) \
+         && XY=$${XY/|/ } \
+         && XY=$${XY//%/\\%} \
+         && $(SED) "s%\# Alternation placeholder%$${XY//$$'\n'/$$'\\\\\n'}%"
+TEXT1=A pattern file was built from which a
+TEXT2=was generated. Good luck with source code review!
+
+default: build_update_candidate_list
+
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER): \
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	$(SPATCH) $(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+-dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+# This replacement action is needed for the use case that the corresponding
+# variable was overridden.
+$(SQLITE_IMPORT_SCRIPT): $(SQLITE_IMPORT_SCRIPT_TEMPLATE)
+	$(SED) "s%import list_input_pointer_validation1\.txt%import $(subst
%,\%,$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER))%" \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) > $@
+
+$(RESULT_SQL_DATA_BASE) $(RESULT_FUNCTIONS_WITH_PREFIX): \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+	@$(RM) $(RESULT_SQL_DATA_BASE)
+	$(SQLITE) -init $(SQLITE_IMPORT_SCRIPT) $(RESULT_SQL_DATA_BASE) \
+'select '\''   |  '\'' || function from positions group by function order by
function desc;' \
+> $(RESULT_FUNCTIONS_WITH_PREFIX)
+
+$(LIST_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(LIST_PATTERN_TEMPLATE) > $@
+
+$(PATCH_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(PATCH_PATTERN_TEMPLATE) > $@
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST): $(LIST_PATTERN)
+	$(SPATCH) $(LIST_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH): $(PATCH_PATTERN)
+	$(SPATCH) $(PATCH_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+build_check_list generate_list_of_functions_which_check_their_single_parameter: \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	@echo 'The list of functions which check their single parameter was generated.'
+
+build_import_script: $(SQLITE_IMPORT_SCRIPT)
+	@echo 'A script was generated which should contain appropriate parameters for
a data base.'
+
+build_data_base: $(RESULT_SQL_DATA_BASE)
+	@echo 'A SQL data base was built.'
+
+build_alternation add_prefix_to_functions: build_data_base
+	@echo 'The function name list was converted to a component for a regular
expression.'
+
+build_list_pattern: $(LIST_PATTERN)
+	@echo '$(TEXT1) list can be generated.'
+
+build_patch_pattern: $(PATCH_PATTERN)
+	@echo '$(TEXT1) patch can be generated.'
+
+build_update_candidate_list show_list_of_update_candidates: build_list_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST)
+	@echo 'The list of update candidates $(TEXT2)'
+
+build_patch show_update_suggestion: build_patch_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH)
+	@echo 'A patch file $(TEXT2)'
+
+all: build_update_candidate_list build_patch
+
+clean:
+	$(RM) *-errors.txt \
+$(LIST_PATTERN) \
+$(PATCH_PATTERN) \
+$(RESULT_FUNCTIONS_WITH_PREFIX) \
+$(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+
+delete_data_base:
+	$(RM) $(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+.PHONY: all \
+build_check_list \
+build_data_base \
+build_import_script \
+build_list_pattern \
+build_patch \
+build_patch_pattern \
+build_update_candidate_list \
+clean \
+default \
+delete_data_base \
+generate_list_of_functions_which_check_their_single_parameter \
+show_list_of_update_candidates \
+show_update_suggestion
+
+
+# The following input files should not need further actions here.
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) \
+$(LIST_PATTERN_TEMPLATE) \
+$(PATCH_PATTERN_TEMPLATE): ;
-- 
1.9.0


--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [Cocci] [coccicheck PATCH 5/5] Deletion of unnecessary checks before specific function calls
@ 2014-10-01 14:07                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-01 14:07 UTC (permalink / raw)
  To: cocci

>>> If you are convinced that dropping the null tests is a good idea, then you 
>>> can submit the patch that makes the change to the relevant maintainers and 
>>> mailing lists.

>From bedf1cb3ddd162ee3b4c31cbb98d97431f70103d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2014 19:40:43 +0100
Subject: [PATCH 5/5] Addition of a make file for build automation

This script can be used to combine some input files for the desired data output
which will eventually show update candidates for further source code review.
Some build targets were defined. Values for the used make variables can be
adjusted by parameters on the command line as usual.

A few implementation details might need more fine-tuning.
- Automatic determination of the Linux source directory from a calling
  make process

- Setting of an extra output directory for the generated files

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/deletions/makefile | 126 ++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 scripts/coccinelle/deletions/makefile

diff --git a/scripts/coccinelle/deletions/makefile
b/scripts/coccinelle/deletions/makefile
new file mode 100644
index 0000000..6464bae
--- /dev/null
+++ b/scripts/coccinelle/deletions/makefile
@@ -0,0 +1,126 @@
+SED=sed
+SPATCH=spatch.opt --sp-file
+RM=rm -f
+LINUX_SOURCE_DIR=/usr/src/linux-stable
+EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.cocci
+SQLITE=sqlite3
+SQLITE_IMPORT_SCRIPT=handle_function_list.sqlite
+SQLITE_IMPORT_SCRIPT_TEMPLATE=handle_function_list_template.sqlite
+RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1.txt
+RESULT_SQL_DATA_BASE=result.db
+RESULT_FUNCTIONS_WITH_PREFIX=add_prefix-SQL.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST=list_functions_with_unnecessary_checks1.txt
+RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH=functions_with_unnecessary_checks1.diff
+LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER=list_input_parameter_validation1-errors.txt
+LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS=list_functions_with_unnecessary_checks1-errors.txt
+LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS=functions_with_unnecessary_checks1-errors.txt
+LIST_PATTERN_TEMPLATE=list_functions_with_unnecessary_checks_template1.cocci
+LIST_PATTERN=list_functions_with_unnecessary_checks1.cocci
+PATCH_PATTERN_TEMPLATE=delete_unnecessary_checks_template1.cocci
+PATCH_PATTERN=delete_unnecessary_checks1.cocci
+ESCAPING=XY=$$(< $(RESULT_FUNCTIONS_WITH_PREFIX)) \
+         && XY=$${XY/|/ } \
+         && XY=$${XY//%/\\%} \
+         && $(SED) "s%\# Alternation placeholder%$${XY//$$'\n'/$$'\\\\\n'}%"
+TEXT1=A pattern file was built from which a
+TEXT2=was generated. Good luck with source code review!
+
+default: build_update_candidate_list
+
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER): \
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	$(SPATCH) $(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+-dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+# This replacement action is needed for the use case that the corresponding
+# variable was overridden.
+$(SQLITE_IMPORT_SCRIPT): $(SQLITE_IMPORT_SCRIPT_TEMPLATE)
+	$(SED) "s%import list_input_pointer_validation1\.txt%import $(subst
%,\%,$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER))%" \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) > $@
+
+$(RESULT_SQL_DATA_BASE) $(RESULT_FUNCTIONS_WITH_PREFIX): \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+	@$(RM) $(RESULT_SQL_DATA_BASE)
+	$(SQLITE) -init $(SQLITE_IMPORT_SCRIPT) $(RESULT_SQL_DATA_BASE) \
+'select '\''   |  '\'' || function from positions group by function order by
function desc;' \
+> $(RESULT_FUNCTIONS_WITH_PREFIX)
+
+$(LIST_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(LIST_PATTERN_TEMPLATE) > $@
+
+$(PATCH_PATTERN): $(RESULT_FUNCTIONS_WITH_PREFIX)
+	$(ESCAPING) $(PATCH_PATTERN_TEMPLATE) > $@
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST): $(LIST_PATTERN)
+	$(SPATCH) $(LIST_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_LIST_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH): $(PATCH_PATTERN)
+	$(SPATCH) $(PATCH_PATTERN) -dir $(LINUX_SOURCE_DIR) \
+> $@ 2> $(LOG_PATCH_FUNCTIONS_WITH_UNNECESSARY_CHECKS)
+
+build_check_list generate_list_of_functions_which_check_their_single_parameter: \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+	@echo 'The list of functions which check their single parameter was generated.'
+
+build_import_script: $(SQLITE_IMPORT_SCRIPT)
+	@echo 'A script was generated which should contain appropriate parameters for
a data base.'
+
+build_data_base: $(RESULT_SQL_DATA_BASE)
+	@echo 'A SQL data base was built.'
+
+build_alternation add_prefix_to_functions: build_data_base
+	@echo 'The function name list was converted to a component for a regular
expression.'
+
+build_list_pattern: $(LIST_PATTERN)
+	@echo '$(TEXT1) list can be generated.'
+
+build_patch_pattern: $(PATCH_PATTERN)
+	@echo '$(TEXT1) patch can be generated.'
+
+build_update_candidate_list show_list_of_update_candidates: build_list_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_LIST)
+	@echo 'The list of update candidates $(TEXT2)'
+
+build_patch show_update_suggestion: build_patch_pattern \
+$(RESULT_FUNCTIONS_WITH_UNNECESSARY_CHECKS_AS_PATCH)
+	@echo 'A patch file $(TEXT2)'
+
+all: build_update_candidate_list build_patch
+
+clean:
+	$(RM) *-errors.txt \
+$(LIST_PATTERN) \
+$(PATCH_PATTERN) \
+$(RESULT_FUNCTIONS_WITH_PREFIX) \
+$(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT)
+
+delete_data_base:
+	$(RM) $(RESULT_SQL_DATA_BASE) \
+$(RESULT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER)
+
+.PHONY: all \
+build_check_list \
+build_data_base \
+build_import_script \
+build_list_pattern \
+build_patch \
+build_patch_pattern \
+build_update_candidate_list \
+clean \
+default \
+delete_data_base \
+generate_list_of_functions_which_check_their_single_parameter \
+show_list_of_update_candidates \
+show_update_suggestion
+
+
+# The following input files should not need further actions here.
+$(EXTRACT_FUNCTIONS_THAT_CHECK_THEIR_SINGLE_PARAMETER) \
+$(SQLITE_IMPORT_SCRIPT_TEMPLATE) \
+$(LIST_PATTERN_TEMPLATE) \
+$(PATCH_PATTERN_TEMPLATE): ;
-- 
1.9.0

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

* Re: [PATCH 1/1] GPU-DRM-nouveau: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-10-22 14:30                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 14:30 UTC (permalink / raw)
  To: David Airlie, dri-devel
  Cc: Ben Skeggs, Ilia Mirkin, Alexandre Courbot, Thierry Reding,
	linux-kernel, kernel-janitors, trivial, Coccinelle

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Would you like to integrate the following proposal into your source code repository?

Regards,
Markus


>From 29e61d5ccc44cd5e5961acff61b6938e0705044d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 15:45:22 +0200
Subject: [PATCH] GPU-DRM-nouveau: Deletion of unnecessary checks before two
 function calls

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/nouveau/core/core/handle.c | 3 +--
 drivers/gpu/drm/nouveau/nouveau_drm.c      | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/handle.c
b/drivers/gpu/drm/nouveau/core/core/handle.c
index a490b80..75d0c2c 100644
--- a/drivers/gpu/drm/nouveau/core/core/handle.c
+++ b/drivers/gpu/drm/nouveau/core/core/handle.c
@@ -219,8 +219,7 @@ nouveau_handle_get_cinst(struct nouveau_object *engctx, u32
cinst)
 void
 nouveau_handle_put(struct nouveau_handle *handle)
 {
-	if (handle)
-		nouveau_namedb_put(handle);
+	nouveau_namedb_put(handle);
 }

 int
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 5723807..5c29079 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -512,8 +512,7 @@ nouveau_drm_unload(struct drm_device *dev)
 	nouveau_vga_fini(drm);

 	nvif_device_fini(&drm->device);
-	if (drm->hdmi_device)
-		pci_dev_put(drm->hdmi_device);
+	pci_dev_put(drm->hdmi_device);
 	nouveau_cli_destroy(&drm->client);
 	return 0;
 }
-- 
2.1.2



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

* Re: [PATCH 1/1] GPU-DRM-nouveau: Deletion of unnecessary checks before two function calls
@ 2014-10-22 14:30                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 14:30 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Would you like to integrate the following proposal into your source code repository?

Regards,
Markus


From 29e61d5ccc44cd5e5961acff61b6938e0705044d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 15:45:22 +0200
Subject: [PATCH] GPU-DRM-nouveau: Deletion of unnecessary checks before two
 function calls

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/nouveau/core/core/handle.c | 3 +--
 drivers/gpu/drm/nouveau/nouveau_drm.c      | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/handle.c
b/drivers/gpu/drm/nouveau/core/core/handle.c
index a490b80..75d0c2c 100644
--- a/drivers/gpu/drm/nouveau/core/core/handle.c
+++ b/drivers/gpu/drm/nouveau/core/core/handle.c
@@ -219,8 +219,7 @@ nouveau_handle_get_cinst(struct nouveau_object *engctx, u32
cinst)
 void
 nouveau_handle_put(struct nouveau_handle *handle)
 {
-	if (handle)
-		nouveau_namedb_put(handle);
+	nouveau_namedb_put(handle);
 }

 int
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 5723807..5c29079 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -512,8 +512,7 @@ nouveau_drm_unload(struct drm_device *dev)
 	nouveau_vga_fini(drm);

 	nvif_device_fini(&drm->device);
-	if (drm->hdmi_device)
-		pci_dev_put(drm->hdmi_device);
+	pci_dev_put(drm->hdmi_device);
 	nouveau_cli_destroy(&drm->client);
 	return 0;
 }
-- 
2.1.2



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

* [Cocci] [PATCH 1/1] GPU-DRM-nouveau: Deletion of unnecessary checks before two function calls
@ 2014-10-22 14:30                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 14:30 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Would you like to integrate the following proposal into your source code repository?

Regards,
Markus


>From 29e61d5ccc44cd5e5961acff61b6938e0705044d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 15:45:22 +0200
Subject: [PATCH] GPU-DRM-nouveau: Deletion of unnecessary checks before two
 function calls

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/nouveau/core/core/handle.c | 3 +--
 drivers/gpu/drm/nouveau/nouveau_drm.c      | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/handle.c
b/drivers/gpu/drm/nouveau/core/core/handle.c
index a490b80..75d0c2c 100644
--- a/drivers/gpu/drm/nouveau/core/core/handle.c
+++ b/drivers/gpu/drm/nouveau/core/core/handle.c
@@ -219,8 +219,7 @@ nouveau_handle_get_cinst(struct nouveau_object *engctx, u32
cinst)
 void
 nouveau_handle_put(struct nouveau_handle *handle)
 {
-	if (handle)
-		nouveau_namedb_put(handle);
+	nouveau_namedb_put(handle);
 }

 int
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 5723807..5c29079 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -512,8 +512,7 @@ nouveau_drm_unload(struct drm_device *dev)
 	nouveau_vga_fini(drm);

 	nvif_device_fini(&drm->device);
-	if (drm->hdmi_device)
-		pci_dev_put(drm->hdmi_device);
+	pci_dev_put(drm->hdmi_device);
 	nouveau_cli_destroy(&drm->client);
 	return 0;
 }
-- 
2.1.2

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

* Re: [PATCH 1/1] GPU-DRM-nouveau: Deletion of unnecessary checks before two function calls
@ 2014-10-22 14:30                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 14:30 UTC (permalink / raw)
  To: David Airlie, dri-devel
  Cc: Ben Skeggs, Ilia Mirkin, Alexandre Courbot, Thierry Reding,
	linux-kernel, kernel-janitors, trivial, Coccinelle

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Would you like to integrate the following proposal into your source code repository?

Regards,
Markus


>From 29e61d5ccc44cd5e5961acff61b6938e0705044d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 15:45:22 +0200
Subject: [PATCH] GPU-DRM-nouveau: Deletion of unnecessary checks before two
 function calls

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/nouveau/core/core/handle.c | 3 +--
 drivers/gpu/drm/nouveau/nouveau_drm.c      | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/handle.c
b/drivers/gpu/drm/nouveau/core/core/handle.c
index a490b80..75d0c2c 100644
--- a/drivers/gpu/drm/nouveau/core/core/handle.c
+++ b/drivers/gpu/drm/nouveau/core/core/handle.c
@@ -219,8 +219,7 @@ nouveau_handle_get_cinst(struct nouveau_object *engctx, u32
cinst)
 void
 nouveau_handle_put(struct nouveau_handle *handle)
 {
-	if (handle)
-		nouveau_namedb_put(handle);
+	nouveau_namedb_put(handle);
 }

 int
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 5723807..5c29079 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -512,8 +512,7 @@ nouveau_drm_unload(struct drm_device *dev)
 	nouveau_vga_fini(drm);

 	nvif_device_fini(&drm->device);
-	if (drm->hdmi_device)
-		pci_dev_put(drm->hdmi_device);
+	pci_dev_put(drm->hdmi_device);
 	nouveau_cli_destroy(&drm->client);
 	return 0;
 }
-- 
2.1.2



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

* Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-10-22 16:48                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 16:48 UTC (permalink / raw)
  To: David Airlie, dri-devel
  Cc: Daniel Vetter, Matt Roper, David Herrmann, Thomas Wood,
	Rob Clark, Patrik Jakobsson, Arthur Borsboom, Thierry Reding,
	Benoit Taine, linux-kernel, kernel-janitors, trivial, Coccinelle

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Would you like to integrate the following proposal into your source code repository?

Regards,
Markus


>From e61965bbcb143a54696fbd468989110519e41497 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 18:28:12 +0200
Subject: [PATCH] GPU-DRM-GMA500: Deletion of unnecessary checks before two
 function calls

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/cdv_intel_hdmi.c | 3 +--
 drivers/gpu/drm/gma500/cdv_intel_lvds.c | 9 +++------
 drivers/gpu/drm/gma500/oaktrail_lvds.c  | 3 +--
 drivers/gpu/drm/gma500/psb_drv.c        | 3 +--
 drivers/gpu/drm/gma500/psb_intel_lvds.c | 9 +++------
 5 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
index 4268bf2..0d69624 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
@@ -246,8 +246,7 @@ static void cdv_hdmi_destroy(struct drm_connector *connector)
 {
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);

-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
diff --git a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
index 0b77039..8f24013 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
@@ -444,8 +444,7 @@ static void cdv_intel_lvds_destroy(struct drm_connector
*connector)
 {
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);

-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
@@ -780,12 +779,10 @@ out:
 failed_find:
 	mutex_unlock(&dev->mode_config.mutex);
 	printk(KERN_ERR "Failed find\n");
-	if (gma_encoder->ddc_bus)
-		psb_intel_i2c_destroy(gma_encoder->ddc_bus);
+	psb_intel_i2c_destroy(gma_encoder->ddc_bus);
 failed_ddc:
 	printk(KERN_ERR "Failed DDC\n");
-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 failed_blc_i2c:
 	printk(KERN_ERR "Failed BLC\n");
 	drm_encoder_cleanup(encoder);
diff --git a/drivers/gpu/drm/gma500/oaktrail_lvds.c
b/drivers/gpu/drm/gma500/oaktrail_lvds.c
index 0d39da6..49c5c415 100644
--- a/drivers/gpu/drm/gma500/oaktrail_lvds.c
+++ b/drivers/gpu/drm/gma500/oaktrail_lvds.c
@@ -411,8 +411,7 @@ failed_find:
 	mutex_unlock(&dev->mode_config.mutex);

 	dev_dbg(dev->dev, "No LVDS modes found, disabling.\n");
-	if (gma_encoder->ddc_bus)
-		psb_intel_i2c_destroy(gma_encoder->ddc_bus);
+	psb_intel_i2c_destroy(gma_encoder->ddc_bus);

 /* failed_ddc: */

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 6ec3a90..0efe165 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -210,8 +210,7 @@ static int psb_driver_unload(struct drm_device *dev)
 			iounmap(dev_priv->aux_reg);
 			dev_priv->aux_reg = NULL;
 		}
-		if (dev_priv->aux_pdev)
-			pci_dev_put(dev_priv->aux_pdev);
+		pci_dev_put(dev_priv->aux_pdev);

 		/* Destroy VBT data */
 		psb_intel_destroy_bios(dev);
diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c
b/drivers/gpu/drm/gma500/psb_intel_lvds.c
index 88aad95..e73c3f9 100644
--- a/drivers/gpu/drm/gma500/psb_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c
@@ -561,8 +561,7 @@ void psb_intel_lvds_destroy(struct drm_connector *connector)
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
 	struct psb_intel_lvds_priv *lvds_priv = gma_encoder->dev_priv;

-	if (lvds_priv->ddc_bus)
-		psb_intel_i2c_destroy(lvds_priv->ddc_bus);
+	psb_intel_i2c_destroy(lvds_priv->ddc_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
@@ -834,11 +833,9 @@ out:

 failed_find:
 	mutex_unlock(&dev->mode_config.mutex);
-	if (lvds_priv->ddc_bus)
-		psb_intel_i2c_destroy(lvds_priv->ddc_bus);
+	psb_intel_i2c_destroy(lvds_priv->ddc_bus);
 failed_ddc:
-	if (lvds_priv->i2c_bus)
-		psb_intel_i2c_destroy(lvds_priv->i2c_bus);
+	psb_intel_i2c_destroy(lvds_priv->i2c_bus);
 failed_blc_i2c:
 	drm_encoder_cleanup(encoder);
 	drm_connector_cleanup(connector);
-- 
2.1.2



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

* Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
@ 2014-10-22 16:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 16:48 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Would you like to integrate the following proposal into your source code repository?

Regards,
Markus


From e61965bbcb143a54696fbd468989110519e41497 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 18:28:12 +0200
Subject: [PATCH] GPU-DRM-GMA500: Deletion of unnecessary checks before two
 function calls

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/cdv_intel_hdmi.c | 3 +--
 drivers/gpu/drm/gma500/cdv_intel_lvds.c | 9 +++------
 drivers/gpu/drm/gma500/oaktrail_lvds.c  | 3 +--
 drivers/gpu/drm/gma500/psb_drv.c        | 3 +--
 drivers/gpu/drm/gma500/psb_intel_lvds.c | 9 +++------
 5 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
index 4268bf2..0d69624 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
@@ -246,8 +246,7 @@ static void cdv_hdmi_destroy(struct drm_connector *connector)
 {
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);

-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
diff --git a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
index 0b77039..8f24013 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
@@ -444,8 +444,7 @@ static void cdv_intel_lvds_destroy(struct drm_connector
*connector)
 {
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);

-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
@@ -780,12 +779,10 @@ out:
 failed_find:
 	mutex_unlock(&dev->mode_config.mutex);
 	printk(KERN_ERR "Failed find\n");
-	if (gma_encoder->ddc_bus)
-		psb_intel_i2c_destroy(gma_encoder->ddc_bus);
+	psb_intel_i2c_destroy(gma_encoder->ddc_bus);
 failed_ddc:
 	printk(KERN_ERR "Failed DDC\n");
-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 failed_blc_i2c:
 	printk(KERN_ERR "Failed BLC\n");
 	drm_encoder_cleanup(encoder);
diff --git a/drivers/gpu/drm/gma500/oaktrail_lvds.c
b/drivers/gpu/drm/gma500/oaktrail_lvds.c
index 0d39da6..49c5c415 100644
--- a/drivers/gpu/drm/gma500/oaktrail_lvds.c
+++ b/drivers/gpu/drm/gma500/oaktrail_lvds.c
@@ -411,8 +411,7 @@ failed_find:
 	mutex_unlock(&dev->mode_config.mutex);

 	dev_dbg(dev->dev, "No LVDS modes found, disabling.\n");
-	if (gma_encoder->ddc_bus)
-		psb_intel_i2c_destroy(gma_encoder->ddc_bus);
+	psb_intel_i2c_destroy(gma_encoder->ddc_bus);

 /* failed_ddc: */

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 6ec3a90..0efe165 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -210,8 +210,7 @@ static int psb_driver_unload(struct drm_device *dev)
 			iounmap(dev_priv->aux_reg);
 			dev_priv->aux_reg = NULL;
 		}
-		if (dev_priv->aux_pdev)
-			pci_dev_put(dev_priv->aux_pdev);
+		pci_dev_put(dev_priv->aux_pdev);

 		/* Destroy VBT data */
 		psb_intel_destroy_bios(dev);
diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c
b/drivers/gpu/drm/gma500/psb_intel_lvds.c
index 88aad95..e73c3f9 100644
--- a/drivers/gpu/drm/gma500/psb_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c
@@ -561,8 +561,7 @@ void psb_intel_lvds_destroy(struct drm_connector *connector)
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
 	struct psb_intel_lvds_priv *lvds_priv = gma_encoder->dev_priv;

-	if (lvds_priv->ddc_bus)
-		psb_intel_i2c_destroy(lvds_priv->ddc_bus);
+	psb_intel_i2c_destroy(lvds_priv->ddc_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
@@ -834,11 +833,9 @@ out:

 failed_find:
 	mutex_unlock(&dev->mode_config.mutex);
-	if (lvds_priv->ddc_bus)
-		psb_intel_i2c_destroy(lvds_priv->ddc_bus);
+	psb_intel_i2c_destroy(lvds_priv->ddc_bus);
 failed_ddc:
-	if (lvds_priv->i2c_bus)
-		psb_intel_i2c_destroy(lvds_priv->i2c_bus);
+	psb_intel_i2c_destroy(lvds_priv->i2c_bus);
 failed_blc_i2c:
 	drm_encoder_cleanup(encoder);
 	drm_connector_cleanup(connector);
-- 
2.1.2



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

* [Cocci] [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
@ 2014-10-22 16:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 16:48 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Would you like to integrate the following proposal into your source code repository?

Regards,
Markus


>From e61965bbcb143a54696fbd468989110519e41497 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 18:28:12 +0200
Subject: [PATCH] GPU-DRM-GMA500: Deletion of unnecessary checks before two
 function calls

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/cdv_intel_hdmi.c | 3 +--
 drivers/gpu/drm/gma500/cdv_intel_lvds.c | 9 +++------
 drivers/gpu/drm/gma500/oaktrail_lvds.c  | 3 +--
 drivers/gpu/drm/gma500/psb_drv.c        | 3 +--
 drivers/gpu/drm/gma500/psb_intel_lvds.c | 9 +++------
 5 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
index 4268bf2..0d69624 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
@@ -246,8 +246,7 @@ static void cdv_hdmi_destroy(struct drm_connector *connector)
 {
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);

-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
diff --git a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
index 0b77039..8f24013 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
@@ -444,8 +444,7 @@ static void cdv_intel_lvds_destroy(struct drm_connector
*connector)
 {
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);

-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
@@ -780,12 +779,10 @@ out:
 failed_find:
 	mutex_unlock(&dev->mode_config.mutex);
 	printk(KERN_ERR "Failed find\n");
-	if (gma_encoder->ddc_bus)
-		psb_intel_i2c_destroy(gma_encoder->ddc_bus);
+	psb_intel_i2c_destroy(gma_encoder->ddc_bus);
 failed_ddc:
 	printk(KERN_ERR "Failed DDC\n");
-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 failed_blc_i2c:
 	printk(KERN_ERR "Failed BLC\n");
 	drm_encoder_cleanup(encoder);
diff --git a/drivers/gpu/drm/gma500/oaktrail_lvds.c
b/drivers/gpu/drm/gma500/oaktrail_lvds.c
index 0d39da6..49c5c415 100644
--- a/drivers/gpu/drm/gma500/oaktrail_lvds.c
+++ b/drivers/gpu/drm/gma500/oaktrail_lvds.c
@@ -411,8 +411,7 @@ failed_find:
 	mutex_unlock(&dev->mode_config.mutex);

 	dev_dbg(dev->dev, "No LVDS modes found, disabling.\n");
-	if (gma_encoder->ddc_bus)
-		psb_intel_i2c_destroy(gma_encoder->ddc_bus);
+	psb_intel_i2c_destroy(gma_encoder->ddc_bus);

 /* failed_ddc: */

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 6ec3a90..0efe165 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -210,8 +210,7 @@ static int psb_driver_unload(struct drm_device *dev)
 			iounmap(dev_priv->aux_reg);
 			dev_priv->aux_reg = NULL;
 		}
-		if (dev_priv->aux_pdev)
-			pci_dev_put(dev_priv->aux_pdev);
+		pci_dev_put(dev_priv->aux_pdev);

 		/* Destroy VBT data */
 		psb_intel_destroy_bios(dev);
diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c
b/drivers/gpu/drm/gma500/psb_intel_lvds.c
index 88aad95..e73c3f9 100644
--- a/drivers/gpu/drm/gma500/psb_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c
@@ -561,8 +561,7 @@ void psb_intel_lvds_destroy(struct drm_connector *connector)
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
 	struct psb_intel_lvds_priv *lvds_priv = gma_encoder->dev_priv;

-	if (lvds_priv->ddc_bus)
-		psb_intel_i2c_destroy(lvds_priv->ddc_bus);
+	psb_intel_i2c_destroy(lvds_priv->ddc_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
@@ -834,11 +833,9 @@ out:

 failed_find:
 	mutex_unlock(&dev->mode_config.mutex);
-	if (lvds_priv->ddc_bus)
-		psb_intel_i2c_destroy(lvds_priv->ddc_bus);
+	psb_intel_i2c_destroy(lvds_priv->ddc_bus);
 failed_ddc:
-	if (lvds_priv->i2c_bus)
-		psb_intel_i2c_destroy(lvds_priv->i2c_bus);
+	psb_intel_i2c_destroy(lvds_priv->i2c_bus);
 failed_blc_i2c:
 	drm_encoder_cleanup(encoder);
 	drm_connector_cleanup(connector);
-- 
2.1.2

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

* Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
@ 2014-10-22 16:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 16:48 UTC (permalink / raw)
  To: David Airlie, dri-devel
  Cc: Daniel Vetter, Matt Roper, David Herrmann, Thomas Wood,
	Rob Clark, Patrik Jakobsson, Arthur Borsboom, Thierry Reding,
	Benoit Taine, linux-kernel, kernel-janitors, trivial, Coccinelle

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

Would you like to integrate the following proposal into your source code repository?

Regards,
Markus


>From e61965bbcb143a54696fbd468989110519e41497 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 18:28:12 +0200
Subject: [PATCH] GPU-DRM-GMA500: Deletion of unnecessary checks before two
 function calls

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/cdv_intel_hdmi.c | 3 +--
 drivers/gpu/drm/gma500/cdv_intel_lvds.c | 9 +++------
 drivers/gpu/drm/gma500/oaktrail_lvds.c  | 3 +--
 drivers/gpu/drm/gma500/psb_drv.c        | 3 +--
 drivers/gpu/drm/gma500/psb_intel_lvds.c | 9 +++------
 5 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
index 4268bf2..0d69624 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
@@ -246,8 +246,7 @@ static void cdv_hdmi_destroy(struct drm_connector *connector)
 {
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);

-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
diff --git a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
index 0b77039..8f24013 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
@@ -444,8 +444,7 @@ static void cdv_intel_lvds_destroy(struct drm_connector
*connector)
 {
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);

-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
@@ -780,12 +779,10 @@ out:
 failed_find:
 	mutex_unlock(&dev->mode_config.mutex);
 	printk(KERN_ERR "Failed find\n");
-	if (gma_encoder->ddc_bus)
-		psb_intel_i2c_destroy(gma_encoder->ddc_bus);
+	psb_intel_i2c_destroy(gma_encoder->ddc_bus);
 failed_ddc:
 	printk(KERN_ERR "Failed DDC\n");
-	if (gma_encoder->i2c_bus)
-		psb_intel_i2c_destroy(gma_encoder->i2c_bus);
+	psb_intel_i2c_destroy(gma_encoder->i2c_bus);
 failed_blc_i2c:
 	printk(KERN_ERR "Failed BLC\n");
 	drm_encoder_cleanup(encoder);
diff --git a/drivers/gpu/drm/gma500/oaktrail_lvds.c
b/drivers/gpu/drm/gma500/oaktrail_lvds.c
index 0d39da6..49c5c415 100644
--- a/drivers/gpu/drm/gma500/oaktrail_lvds.c
+++ b/drivers/gpu/drm/gma500/oaktrail_lvds.c
@@ -411,8 +411,7 @@ failed_find:
 	mutex_unlock(&dev->mode_config.mutex);

 	dev_dbg(dev->dev, "No LVDS modes found, disabling.\n");
-	if (gma_encoder->ddc_bus)
-		psb_intel_i2c_destroy(gma_encoder->ddc_bus);
+	psb_intel_i2c_destroy(gma_encoder->ddc_bus);

 /* failed_ddc: */

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 6ec3a90..0efe165 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -210,8 +210,7 @@ static int psb_driver_unload(struct drm_device *dev)
 			iounmap(dev_priv->aux_reg);
 			dev_priv->aux_reg = NULL;
 		}
-		if (dev_priv->aux_pdev)
-			pci_dev_put(dev_priv->aux_pdev);
+		pci_dev_put(dev_priv->aux_pdev);

 		/* Destroy VBT data */
 		psb_intel_destroy_bios(dev);
diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c
b/drivers/gpu/drm/gma500/psb_intel_lvds.c
index 88aad95..e73c3f9 100644
--- a/drivers/gpu/drm/gma500/psb_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c
@@ -561,8 +561,7 @@ void psb_intel_lvds_destroy(struct drm_connector *connector)
 	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
 	struct psb_intel_lvds_priv *lvds_priv = gma_encoder->dev_priv;

-	if (lvds_priv->ddc_bus)
-		psb_intel_i2c_destroy(lvds_priv->ddc_bus);
+	psb_intel_i2c_destroy(lvds_priv->ddc_bus);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
@@ -834,11 +833,9 @@ out:

 failed_find:
 	mutex_unlock(&dev->mode_config.mutex);
-	if (lvds_priv->ddc_bus)
-		psb_intel_i2c_destroy(lvds_priv->ddc_bus);
+	psb_intel_i2c_destroy(lvds_priv->ddc_bus);
 failed_ddc:
-	if (lvds_priv->i2c_bus)
-		psb_intel_i2c_destroy(lvds_priv->i2c_bus);
+	psb_intel_i2c_destroy(lvds_priv->i2c_bus);
 failed_blc_i2c:
 	drm_encoder_cleanup(encoder);
 	drm_connector_cleanup(connector);
-- 
2.1.2

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

* Re: [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-10-22 18:00                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 18:00 UTC (permalink / raw)
  To: Jörg Rödel, iommu
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From af73fb59d5d4b2c2890000fb236d0752522b6b38 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 19:39:21 +0200
Subject: [PATCH] IOMMU-MSM: Deletion of unnecessary checks before the function
 call "clk_disable"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iommu/msm_iommu.c     | 3 +--
 drivers/iommu/msm_iommu_dev.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 6e3dcc28..3e4d888 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -73,8 +73,7 @@ fail:

 static void __disable_clocks(struct msm_iommu_drvdata *drvdata)
 {
-	if (drvdata->clk)
-		clk_disable(drvdata->clk);
+	clk_disable(drvdata->clk);
 	clk_disable(drvdata->pclk);
 }

diff --git a/drivers/iommu/msm_iommu_dev.c b/drivers/iommu/msm_iommu_dev.c
index 61def7cb..9574d21 100644
--- a/drivers/iommu/msm_iommu_dev.c
+++ b/drivers/iommu/msm_iommu_dev.c
@@ -224,8 +224,7 @@ static int msm_iommu_probe(struct platform_device *pdev)

 	platform_set_drvdata(pdev, drvdata);

-	if (iommu_clk)
-		clk_disable(iommu_clk);
+	clk_disable(iommu_clk);

 	clk_disable(iommu_pclk);

@@ -323,8 +322,7 @@ static int msm_iommu_ctx_probe(struct platform_device *pdev)
 		SET_NSCFG(drvdata->base, mid, 3);
 	}

-	if (drvdata->clk)
-		clk_disable(drvdata->clk);
+	clk_disable(drvdata->clk);
 	clk_disable(drvdata->pclk);

 	dev_info(&pdev->dev, "context %s using bank %d\n", c->name, c->num);
-- 
2.1.2



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

* Re: [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable"
@ 2014-10-22 18:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 18:00 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

From af73fb59d5d4b2c2890000fb236d0752522b6b38 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 19:39:21 +0200
Subject: [PATCH] IOMMU-MSM: Deletion of unnecessary checks before the function
 call "clk_disable"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iommu/msm_iommu.c     | 3 +--
 drivers/iommu/msm_iommu_dev.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 6e3dcc28..3e4d888 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -73,8 +73,7 @@ fail:

 static void __disable_clocks(struct msm_iommu_drvdata *drvdata)
 {
-	if (drvdata->clk)
-		clk_disable(drvdata->clk);
+	clk_disable(drvdata->clk);
 	clk_disable(drvdata->pclk);
 }

diff --git a/drivers/iommu/msm_iommu_dev.c b/drivers/iommu/msm_iommu_dev.c
index 61def7cb..9574d21 100644
--- a/drivers/iommu/msm_iommu_dev.c
+++ b/drivers/iommu/msm_iommu_dev.c
@@ -224,8 +224,7 @@ static int msm_iommu_probe(struct platform_device *pdev)

 	platform_set_drvdata(pdev, drvdata);

-	if (iommu_clk)
-		clk_disable(iommu_clk);
+	clk_disable(iommu_clk);

 	clk_disable(iommu_pclk);

@@ -323,8 +322,7 @@ static int msm_iommu_ctx_probe(struct platform_device *pdev)
 		SET_NSCFG(drvdata->base, mid, 3);
 	}

-	if (drvdata->clk)
-		clk_disable(drvdata->clk);
+	clk_disable(drvdata->clk);
 	clk_disable(drvdata->pclk);

 	dev_info(&pdev->dev, "context %s using bank %d\n", c->name, c->num);
-- 
2.1.2



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

* Re: [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable"
@ 2014-10-22 18:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 18:00 UTC (permalink / raw)
  To: Jörg Rödel, iommu
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From af73fb59d5d4b2c2890000fb236d0752522b6b38 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 19:39:21 +0200
Subject: [PATCH] IOMMU-MSM: Deletion of unnecessary checks before the function
 call "clk_disable"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iommu/msm_iommu.c     | 3 +--
 drivers/iommu/msm_iommu_dev.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 6e3dcc28..3e4d888 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -73,8 +73,7 @@ fail:

 static void __disable_clocks(struct msm_iommu_drvdata *drvdata)
 {
-	if (drvdata->clk)
-		clk_disable(drvdata->clk);
+	clk_disable(drvdata->clk);
 	clk_disable(drvdata->pclk);
 }

diff --git a/drivers/iommu/msm_iommu_dev.c b/drivers/iommu/msm_iommu_dev.c
index 61def7cb..9574d21 100644
--- a/drivers/iommu/msm_iommu_dev.c
+++ b/drivers/iommu/msm_iommu_dev.c
@@ -224,8 +224,7 @@ static int msm_iommu_probe(struct platform_device *pdev)

 	platform_set_drvdata(pdev, drvdata);

-	if (iommu_clk)
-		clk_disable(iommu_clk);
+	clk_disable(iommu_clk);

 	clk_disable(iommu_pclk);

@@ -323,8 +322,7 @@ static int msm_iommu_ctx_probe(struct platform_device *pdev)
 		SET_NSCFG(drvdata->base, mid, 3);
 	}

-	if (drvdata->clk)
-		clk_disable(drvdata->clk);
+	clk_disable(drvdata->clk);
 	clk_disable(drvdata->pclk);

 	dev_info(&pdev->dev, "context %s using bank %d\n", c->name, c->num);
-- 
2.1.2

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

* [Cocci] [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable"
@ 2014-10-22 18:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 18:00 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From af73fb59d5d4b2c2890000fb236d0752522b6b38 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 19:39:21 +0200
Subject: [PATCH] IOMMU-MSM: Deletion of unnecessary checks before the function
 call "clk_disable"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iommu/msm_iommu.c     | 3 +--
 drivers/iommu/msm_iommu_dev.c | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 6e3dcc28..3e4d888 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -73,8 +73,7 @@ fail:

 static void __disable_clocks(struct msm_iommu_drvdata *drvdata)
 {
-	if (drvdata->clk)
-		clk_disable(drvdata->clk);
+	clk_disable(drvdata->clk);
 	clk_disable(drvdata->pclk);
 }

diff --git a/drivers/iommu/msm_iommu_dev.c b/drivers/iommu/msm_iommu_dev.c
index 61def7cb..9574d21 100644
--- a/drivers/iommu/msm_iommu_dev.c
+++ b/drivers/iommu/msm_iommu_dev.c
@@ -224,8 +224,7 @@ static int msm_iommu_probe(struct platform_device *pdev)

 	platform_set_drvdata(pdev, drvdata);

-	if (iommu_clk)
-		clk_disable(iommu_clk);
+	clk_disable(iommu_clk);

 	clk_disable(iommu_pclk);

@@ -323,8 +322,7 @@ static int msm_iommu_ctx_probe(struct platform_device *pdev)
 		SET_NSCFG(drvdata->base, mid, 3);
 	}

-	if (drvdata->clk)
-		clk_disable(drvdata->clk);
+	clk_disable(drvdata->clk);
 	clk_disable(drvdata->pclk);

 	dev_info(&pdev->dev, "context %s using bank %d\n", c->name, c->num);
-- 
2.1.2

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

* Re: [PATCH 1/1] SCSI-QLA2XXX: Deletion of unnecessary checks before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-10-22 18:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 18:55 UTC (permalink / raw)
  To: James E. J. Bottomley, qla2xxx-upstream, linux-scsi
  Cc: trivial, kernel-janitors, linux-kernel, Coccinelle

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From ff44962f88ac2dae9324e30819629da4fb33f0ff Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 20:40:31 +0200
Subject: [PATCH] SCSI-QLA2XXX: Deletion of unnecessary checks before the
 function call "vfree"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/qla2xxx/qla_attr.c |  6 ++----
 drivers/scsi/qla2xxx/qla_init.c | 18 ++++++------------
 drivers/scsi/qla2xxx/qla_os.c   |  6 ++----
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 82b92c4..95c4c09 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -175,10 +175,8 @@ qla2x00_sysfs_write_fw_dump_template(struct file *filp,
struct kobject *kobj,
 	uint32_t size;

 	if (off == 0) {
-		if (ha->fw_dump)
-			vfree(ha->fw_dump);
-		if (ha->fw_dump_template)
-			vfree(ha->fw_dump_template);
+		vfree(ha->fw_dump);
+		vfree(ha->fw_dump_template);

 		ha->fw_dump = NULL;
 		ha->fw_dump_len = 0;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a4dde7e..8da3d4f 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5256,8 +5256,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5307,8 +5306,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,

 default_template:
 	ql_log(ql_log_warn, vha, 0x0168, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5342,8 +5340,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x016d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
@@ -5559,8 +5556,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5609,8 +5605,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)

 default_template:
 	ql_log(ql_log_warn, vha, 0x0178, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5644,8 +5639,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x017d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index db3dbd9..0f9c378 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3676,10 +3676,8 @@ qla2x00_free_fw_dump(struct qla_hw_data *ha)
 		dma_free_coherent(&ha->pdev->dev,
 		    EFT_SIZE, ha->eft, ha->eft_dma);

-	if (ha->fw_dump)
-		vfree(ha->fw_dump);
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump);
+	vfree(ha->fw_dump_template);

 	ha->fce = NULL;
 	ha->fce_dma = 0;
-- 
2.1.2

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

* [Cocci] [PATCH 1/1] SCSI-QLA2XXX: Deletion of unnecessary checks before the function call "vfree"
@ 2014-10-22 18:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 18:55 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

>From ff44962f88ac2dae9324e30819629da4fb33f0ff Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 20:40:31 +0200
Subject: [PATCH] SCSI-QLA2XXX: Deletion of unnecessary checks before the
 function call "vfree"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/qla2xxx/qla_attr.c |  6 ++----
 drivers/scsi/qla2xxx/qla_init.c | 18 ++++++------------
 drivers/scsi/qla2xxx/qla_os.c   |  6 ++----
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 82b92c4..95c4c09 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -175,10 +175,8 @@ qla2x00_sysfs_write_fw_dump_template(struct file *filp,
struct kobject *kobj,
 	uint32_t size;

 	if (off == 0) {
-		if (ha->fw_dump)
-			vfree(ha->fw_dump);
-		if (ha->fw_dump_template)
-			vfree(ha->fw_dump_template);
+		vfree(ha->fw_dump);
+		vfree(ha->fw_dump_template);

 		ha->fw_dump = NULL;
 		ha->fw_dump_len = 0;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a4dde7e..8da3d4f 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5256,8 +5256,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5307,8 +5306,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,

 default_template:
 	ql_log(ql_log_warn, vha, 0x0168, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5342,8 +5340,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x016d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
@@ -5559,8 +5556,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5609,8 +5605,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)

 default_template:
 	ql_log(ql_log_warn, vha, 0x0178, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5644,8 +5639,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x017d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index db3dbd9..0f9c378 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3676,10 +3676,8 @@ qla2x00_free_fw_dump(struct qla_hw_data *ha)
 		dma_free_coherent(&ha->pdev->dev,
 		    EFT_SIZE, ha->eft, ha->eft_dma);

-	if (ha->fw_dump)
-		vfree(ha->fw_dump);
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump);
+	vfree(ha->fw_dump_template);

 	ha->fce = NULL;
 	ha->fce_dma = 0;
-- 
2.1.2

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

* Re: [PATCH 1/1] SCSI-QLA2...: Deletion of unnecessary checks before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-10-22 19:10                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 19:10 UTC (permalink / raw)
  To: James E. J. Bottomley, qla2xxx-upstream, linux-scsi
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

I resent the request once more because another "Triple-X" software development
adventure might follow ...?

Regards,
Markus


>From ff44962f88ac2dae9324e30819629da4fb33f0ff Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 20:40:31 +0200
Subject: [PATCH] SCSI-QLA2XXX: Deletion of unnecessary checks before the
 function call "vfree"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/qla2xxx/qla_attr.c |  6 ++----
 drivers/scsi/qla2xxx/qla_init.c | 18 ++++++------------
 drivers/scsi/qla2xxx/qla_os.c   |  6 ++----
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 82b92c4..95c4c09 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -175,10 +175,8 @@ qla2x00_sysfs_write_fw_dump_template(struct file *filp,
struct kobject *kobj,
 	uint32_t size;

 	if (off == 0) {
-		if (ha->fw_dump)
-			vfree(ha->fw_dump);
-		if (ha->fw_dump_template)
-			vfree(ha->fw_dump_template);
+		vfree(ha->fw_dump);
+		vfree(ha->fw_dump_template);

 		ha->fw_dump = NULL;
 		ha->fw_dump_len = 0;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a4dde7e..8da3d4f 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5256,8 +5256,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5307,8 +5306,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,

 default_template:
 	ql_log(ql_log_warn, vha, 0x0168, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5342,8 +5340,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x016d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
@@ -5559,8 +5556,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5609,8 +5605,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)

 default_template:
 	ql_log(ql_log_warn, vha, 0x0178, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5644,8 +5639,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x017d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index db3dbd9..0f9c378 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3676,10 +3676,8 @@ qla2x00_free_fw_dump(struct qla_hw_data *ha)
 		dma_free_coherent(&ha->pdev->dev,
 		    EFT_SIZE, ha->eft, ha->eft_dma);

-	if (ha->fw_dump)
-		vfree(ha->fw_dump);
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump);
+	vfree(ha->fw_dump_template);

 	ha->fce = NULL;
 	ha->fce_dma = 0;
-- 
2.1.2



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

* Re: [PATCH 1/1] SCSI-QLA2...: Deletion of unnecessary checks before the function call "vfree"
@ 2014-10-22 19:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 19:10 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

I resent the request once more because another "Triple-X" software development
adventure might follow ...?

Regards,
Markus


From ff44962f88ac2dae9324e30819629da4fb33f0ff Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 20:40:31 +0200
Subject: [PATCH] SCSI-QLA2XXX: Deletion of unnecessary checks before the
 function call "vfree"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/qla2xxx/qla_attr.c |  6 ++----
 drivers/scsi/qla2xxx/qla_init.c | 18 ++++++------------
 drivers/scsi/qla2xxx/qla_os.c   |  6 ++----
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 82b92c4..95c4c09 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -175,10 +175,8 @@ qla2x00_sysfs_write_fw_dump_template(struct file *filp,
struct kobject *kobj,
 	uint32_t size;

 	if (off = 0) {
-		if (ha->fw_dump)
-			vfree(ha->fw_dump);
-		if (ha->fw_dump_template)
-			vfree(ha->fw_dump_template);
+		vfree(ha->fw_dump);
+		vfree(ha->fw_dump_template);

 		ha->fw_dump = NULL;
 		ha->fw_dump_len = 0;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a4dde7e..8da3d4f 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5256,8 +5256,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5307,8 +5306,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,

 default_template:
 	ql_log(ql_log_warn, vha, 0x0168, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5342,8 +5340,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x016d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
@@ -5559,8 +5556,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5609,8 +5605,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)

 default_template:
 	ql_log(ql_log_warn, vha, 0x0178, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5644,8 +5639,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x017d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index db3dbd9..0f9c378 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3676,10 +3676,8 @@ qla2x00_free_fw_dump(struct qla_hw_data *ha)
 		dma_free_coherent(&ha->pdev->dev,
 		    EFT_SIZE, ha->eft, ha->eft_dma);

-	if (ha->fw_dump)
-		vfree(ha->fw_dump);
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump);
+	vfree(ha->fw_dump_template);

 	ha->fce = NULL;
 	ha->fce_dma = 0;
-- 
2.1.2



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

* Re: [PATCH 1/1] SCSI-QLA2...: Deletion of unnecessary checks before the function call "vfree"
@ 2014-10-22 19:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 19:10 UTC (permalink / raw)
  To: James E. J. Bottomley, qla2xxx-upstream, linux-scsi
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

I resent the request once more because another "Triple-X" software development
adventure might follow ...?

Regards,
Markus


>From ff44962f88ac2dae9324e30819629da4fb33f0ff Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 20:40:31 +0200
Subject: [PATCH] SCSI-QLA2XXX: Deletion of unnecessary checks before the
 function call "vfree"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/qla2xxx/qla_attr.c |  6 ++----
 drivers/scsi/qla2xxx/qla_init.c | 18 ++++++------------
 drivers/scsi/qla2xxx/qla_os.c   |  6 ++----
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 82b92c4..95c4c09 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -175,10 +175,8 @@ qla2x00_sysfs_write_fw_dump_template(struct file *filp,
struct kobject *kobj,
 	uint32_t size;

 	if (off == 0) {
-		if (ha->fw_dump)
-			vfree(ha->fw_dump);
-		if (ha->fw_dump_template)
-			vfree(ha->fw_dump_template);
+		vfree(ha->fw_dump);
+		vfree(ha->fw_dump_template);

 		ha->fw_dump = NULL;
 		ha->fw_dump_len = 0;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a4dde7e..8da3d4f 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5256,8 +5256,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5307,8 +5306,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,

 default_template:
 	ql_log(ql_log_warn, vha, 0x0168, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5342,8 +5340,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x016d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
@@ -5559,8 +5556,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5609,8 +5605,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)

 default_template:
 	ql_log(ql_log_warn, vha, 0x0178, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5644,8 +5639,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x017d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index db3dbd9..0f9c378 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3676,10 +3676,8 @@ qla2x00_free_fw_dump(struct qla_hw_data *ha)
 		dma_free_coherent(&ha->pdev->dev,
 		    EFT_SIZE, ha->eft, ha->eft_dma);

-	if (ha->fw_dump)
-		vfree(ha->fw_dump);
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump);
+	vfree(ha->fw_dump_template);

 	ha->fce = NULL;
 	ha->fce_dma = 0;
-- 
2.1.2

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

* [Cocci] [PATCH 1/1] SCSI-QLA2...: Deletion of unnecessary checks before the function call "vfree"
@ 2014-10-22 19:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-22 19:10 UTC (permalink / raw)
  To: cocci

>> If you are convinced that dropping the null tests is a good idea, then you 
>> can submit the patch that makes the change to the relevant maintainers and 
>> mailing lists.

I resent the request once more because another "Triple-X" software development
adventure might follow ...?

Regards,
Markus


>From ff44962f88ac2dae9324e30819629da4fb33f0ff Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 22 Oct 2014 20:40:31 +0200
Subject: [PATCH] SCSI-QLA2XXX: Deletion of unnecessary checks before the
 function call "vfree"

A semantic patch approach was proposed with the subject "[PATCH with
Coccinelle?] Deletion of unnecessary checks before specific function calls"
on 2014-03-05.
https://lkml.org/lkml/2014/3/5/344
http://article.gmane.org/gmane.comp.version-control.coccinelle/3513/

This patch pattern application was repeated with the help of the software
"Coccinelle 1.0.0-rc22" on the source files for Linux 3.17.1. An extract
of the automatically generated update suggestions is shown here.

It was determined that the affected source code places call functions
which perform input parameter validation already. It is therefore not
needed that a similar safety check is repeated at the call site.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/qla2xxx/qla_attr.c |  6 ++----
 drivers/scsi/qla2xxx/qla_init.c | 18 ++++++------------
 drivers/scsi/qla2xxx/qla_os.c   |  6 ++----
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 82b92c4..95c4c09 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -175,10 +175,8 @@ qla2x00_sysfs_write_fw_dump_template(struct file *filp,
struct kobject *kobj,
 	uint32_t size;

 	if (off == 0) {
-		if (ha->fw_dump)
-			vfree(ha->fw_dump);
-		if (ha->fw_dump_template)
-			vfree(ha->fw_dump_template);
+		vfree(ha->fw_dump);
+		vfree(ha->fw_dump_template);

 		ha->fw_dump = NULL;
 		ha->fw_dump_len = 0;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a4dde7e..8da3d4f 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5256,8 +5256,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5307,8 +5306,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t
*srisc_addr,

 default_template:
 	ql_log(ql_log_warn, vha, 0x0168, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5342,8 +5340,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x016d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
@@ -5559,8 +5556,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)
 	if (!IS_QLA27XX(ha))
 		return rval;

-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5609,8 +5605,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t
*srisc_addr)

 default_template:
 	ql_log(ql_log_warn, vha, 0x0178, "Using default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;

@@ -5644,8 +5639,7 @@ default_template:

 failed_template:
 	ql_log(ql_log_warn, vha, 0x017d, "Failed default fwdump template\n");
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump_template);
 	ha->fw_dump_template = NULL;
 	ha->fw_dump_template_len = 0;
 	return rval;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index db3dbd9..0f9c378 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3676,10 +3676,8 @@ qla2x00_free_fw_dump(struct qla_hw_data *ha)
 		dma_free_coherent(&ha->pdev->dev,
 		    EFT_SIZE, ha->eft, ha->eft_dma);

-	if (ha->fw_dump)
-		vfree(ha->fw_dump);
-	if (ha->fw_dump_template)
-		vfree(ha->fw_dump_template);
+	vfree(ha->fw_dump);
+	vfree(ha->fw_dump_template);

 	ha->fce = NULL;
 	ha->fce_dma = 0;
-- 
2.1.2

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

* Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
  2014-10-22 16:48                                   ` SF Markus Elfring
  (?)
@ 2014-10-23 11:26                                     ` One Thousand Gnomes
  -1 siblings, 0 replies; 3633+ messages in thread
From: One Thousand Gnomes @ 2014-10-23 11:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David Airlie, dri-devel, Daniel Vetter, Matt Roper,
	David Herrmann, Thomas Wood, Rob Clark, Patrik Jakobsson,
	Arthur Borsboom, Thierry Reding, Benoit Taine, linux-kernel,
	kernel-janitors, trivial, Coccinelle

On Wed, 22 Oct 2014 18:48:21 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> >> If you are convinced that dropping the null tests is a good idea, then you 
> >> can submit the patch that makes the change to the relevant maintainers and 
> >> mailing lists.
> 
> Would you like to integrate the following proposal into your source code repository?

What platforms have you tested the code on at this point ?

Alan

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

* Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
@ 2014-10-23 11:26                                     ` One Thousand Gnomes
  0 siblings, 0 replies; 3633+ messages in thread
From: One Thousand Gnomes @ 2014-10-23 11:26 UTC (permalink / raw)
  To: cocci

On Wed, 22 Oct 2014 18:48:21 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> >> If you are convinced that dropping the null tests is a good idea, then you 
> >> can submit the patch that makes the change to the relevant maintainers and 
> >> mailing lists.
> 
> Would you like to integrate the following proposal into your source code repository?

What platforms have you tested the code on at this point ?

Alan

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

* [Cocci] [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
@ 2014-10-23 11:26                                     ` One Thousand Gnomes
  0 siblings, 0 replies; 3633+ messages in thread
From: One Thousand Gnomes @ 2014-10-23 11:26 UTC (permalink / raw)
  To: cocci

On Wed, 22 Oct 2014 18:48:21 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> >> If you are convinced that dropping the null tests is a good idea, then you 
> >> can submit the patch that makes the change to the relevant maintainers and 
> >> mailing lists.
> 
> Would you like to integrate the following proposal into your source code repository?

What platforms have you tested the code on at this point ?

Alan

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

* Re: [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable"
  2014-10-22 18:00                                   ` SF Markus Elfring
  (?)
  (?)
@ 2014-10-23 12:51                                     ` Jörg Rödel
  -1 siblings, 0 replies; 3633+ messages in thread
From: Jörg Rödel @ 2014-10-23 12:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: iommu, linux-kernel, kernel-janitors, trivial, Coccinelle

On Wed, Oct 22, 2014 at 08:00:17PM +0200, SF Markus Elfring wrote:
>  drivers/iommu/msm_iommu.c     | 3 +--
>  drivers/iommu/msm_iommu_dev.c | 6 ++----
>  2 files changed, 3 insertions(+), 6 deletions(-)

Applied to arm/msm, thanks.


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

* Re: [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable"
@ 2014-10-23 12:51                                     ` Jörg Rödel
  0 siblings, 0 replies; 3633+ messages in thread
From: Jörg Rödel @ 2014-10-23 12:51 UTC (permalink / raw)
  To: cocci

On Wed, Oct 22, 2014 at 08:00:17PM +0200, SF Markus Elfring wrote:
>  drivers/iommu/msm_iommu.c     | 3 +--
>  drivers/iommu/msm_iommu_dev.c | 6 ++----
>  2 files changed, 3 insertions(+), 6 deletions(-)

Applied to arm/msm, thanks.


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

* Re: [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable"
@ 2014-10-23 12:51                                     ` Jörg Rödel
  0 siblings, 0 replies; 3633+ messages in thread
From: Jörg Rödel @ 2014-10-23 12:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: trivial-DgEjT+Ai2ygdnm+yROfE0A,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Coccinelle

On Wed, Oct 22, 2014 at 08:00:17PM +0200, SF Markus Elfring wrote:
>  drivers/iommu/msm_iommu.c     | 3 +--
>  drivers/iommu/msm_iommu_dev.c | 6 ++----
>  2 files changed, 3 insertions(+), 6 deletions(-)

Applied to arm/msm, thanks.

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

* [Cocci] [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable"
@ 2014-10-23 12:51                                     ` Jörg Rödel
  0 siblings, 0 replies; 3633+ messages in thread
From: Jörg Rödel @ 2014-10-23 12:51 UTC (permalink / raw)
  To: cocci

On Wed, Oct 22, 2014 at 08:00:17PM +0200, SF Markus Elfring wrote:
>  drivers/iommu/msm_iommu.c     | 3 +--
>  drivers/iommu/msm_iommu_dev.c | 6 ++----
>  2 files changed, 3 insertions(+), 6 deletions(-)

Applied to arm/msm, thanks.

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

* Re: [PATCH 1/1] staging - rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-10-23 19:20                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-23 19:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

>From 45970693cad6c12da2d5ac7da3d2bd7a566170d7 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 23 Oct 2014 20:55:13 +0200
Subject: [PATCH] staging - rtl8188eu: Deletion of unnecessary checks before
 three function calls

The functions kfree(), rtw_free_netdev() and vfree() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 7006088..77f7552 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
_size_byte, u8  *pbuf)
 exit:
 	kfree(efuseTbl);

-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(eFuseWord);
 }

 static void efuse_read_phymap_from_txpktbuf(
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 149c271..df54350 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 	rtw_free_mlme_priv_ie_data(pmlmepriv);

 	if (pmlmepriv) {
-		if (pmlmepriv->free_bss_buf)
-			vfree(pmlmepriv->free_bss_buf);
+		vfree(pmlmepriv->free_bss_buf);
 	}
 }

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index e1dc8fa..af1de9c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)

 		rtw_mfree_sta_priv_lock(pstapriv);

-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
+		vfree(pstapriv->pallocated_stainfo_buf);
 	}

 	return _SUCCESS;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 639ace0..011c9cf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
 		pxmitbuf++;
 	}

-	if (pxmitpriv->pallocated_frame_buf)
-		vfree(pxmitpriv->pallocated_frame_buf);
+	vfree(pxmitpriv->pallocated_frame_buf);

-	if (pxmitpriv->pallocated_xmitbuf)
-		vfree(pxmitpriv->pallocated_xmitbuf);
+	vfree(pxmitpriv->pallocated_xmitbuf);

 	/*  free xmit extension buff */
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318..cdb70e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -456,7 +456,7 @@ free_adapter:
 	if (status != _SUCCESS) {
 		if (pnetdev)
 			rtw_free_netdev(pnetdev);
-		else if (padapter)
+		else
 			vfree(padapter);
 		padapter = NULL;
 	}
@@ -487,8 +487,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
 	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
 		if1->hw_init_completed);
 	rtw_free_drv_sw(if1);
-	if (pnetdev)
-		rtw_free_netdev(pnetdev);
+	rtw_free_netdev(pnetdev);
 }

 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct
usb_device_id *pdid)
-- 
2.1.2



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

* Re: [PATCH 1/1] staging - rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-23 19:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-23 19:20 UTC (permalink / raw)
  To: cocci

From 45970693cad6c12da2d5ac7da3d2bd7a566170d7 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 23 Oct 2014 20:55:13 +0200
Subject: [PATCH] staging - rtl8188eu: Deletion of unnecessary checks before
 three function calls

The functions kfree(), rtw_free_netdev() and vfree() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 7006088..77f7552 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
_size_byte, u8  *pbuf)
 exit:
 	kfree(efuseTbl);

-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(eFuseWord);
 }

 static void efuse_read_phymap_from_txpktbuf(
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 149c271..df54350 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 	rtw_free_mlme_priv_ie_data(pmlmepriv);

 	if (pmlmepriv) {
-		if (pmlmepriv->free_bss_buf)
-			vfree(pmlmepriv->free_bss_buf);
+		vfree(pmlmepriv->free_bss_buf);
 	}
 }

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index e1dc8fa..af1de9c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)

 		rtw_mfree_sta_priv_lock(pstapriv);

-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
+		vfree(pstapriv->pallocated_stainfo_buf);
 	}

 	return _SUCCESS;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 639ace0..011c9cf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
 		pxmitbuf++;
 	}

-	if (pxmitpriv->pallocated_frame_buf)
-		vfree(pxmitpriv->pallocated_frame_buf);
+	vfree(pxmitpriv->pallocated_frame_buf);

-	if (pxmitpriv->pallocated_xmitbuf)
-		vfree(pxmitpriv->pallocated_xmitbuf);
+	vfree(pxmitpriv->pallocated_xmitbuf);

 	/*  free xmit extension buff */
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318..cdb70e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -456,7 +456,7 @@ free_adapter:
 	if (status != _SUCCESS) {
 		if (pnetdev)
 			rtw_free_netdev(pnetdev);
-		else if (padapter)
+		else
 			vfree(padapter);
 		padapter = NULL;
 	}
@@ -487,8 +487,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
 	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
 		if1->hw_init_completed);
 	rtw_free_drv_sw(if1);
-	if (pnetdev)
-		rtw_free_netdev(pnetdev);
+	rtw_free_netdev(pnetdev);
 }

 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct
usb_device_id *pdid)
-- 
2.1.2



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

* [Cocci] [PATCH 1/1] staging - rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-23 19:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-23 19:20 UTC (permalink / raw)
  To: cocci

>From 45970693cad6c12da2d5ac7da3d2bd7a566170d7 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 23 Oct 2014 20:55:13 +0200
Subject: [PATCH] staging - rtl8188eu: Deletion of unnecessary checks before
 three function calls

The functions kfree(), rtw_free_netdev() and vfree() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 7006088..77f7552 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
_size_byte, u8  *pbuf)
 exit:
 	kfree(efuseTbl);

-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(eFuseWord);
 }

 static void efuse_read_phymap_from_txpktbuf(
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 149c271..df54350 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 	rtw_free_mlme_priv_ie_data(pmlmepriv);

 	if (pmlmepriv) {
-		if (pmlmepriv->free_bss_buf)
-			vfree(pmlmepriv->free_bss_buf);
+		vfree(pmlmepriv->free_bss_buf);
 	}
 }

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index e1dc8fa..af1de9c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)

 		rtw_mfree_sta_priv_lock(pstapriv);

-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
+		vfree(pstapriv->pallocated_stainfo_buf);
 	}

 	return _SUCCESS;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 639ace0..011c9cf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
 		pxmitbuf++;
 	}

-	if (pxmitpriv->pallocated_frame_buf)
-		vfree(pxmitpriv->pallocated_frame_buf);
+	vfree(pxmitpriv->pallocated_frame_buf);

-	if (pxmitpriv->pallocated_xmitbuf)
-		vfree(pxmitpriv->pallocated_xmitbuf);
+	vfree(pxmitpriv->pallocated_xmitbuf);

 	/*  free xmit extension buff */
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318..cdb70e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -456,7 +456,7 @@ free_adapter:
 	if (status != _SUCCESS) {
 		if (pnetdev)
 			rtw_free_netdev(pnetdev);
-		else if (padapter)
+		else
 			vfree(padapter);
 		padapter = NULL;
 	}
@@ -487,8 +487,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
 	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
 		if1->hw_init_completed);
 	rtw_free_drv_sw(if1);
-	if (pnetdev)
-		rtw_free_netdev(pnetdev);
+	rtw_free_netdev(pnetdev);
 }

 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct
usb_device_id *pdid)
-- 
2.1.2

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

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-22 18:01       ` SF Markus Elfring
@ 2014-10-26  6:07         ` SF Markus Elfring
       [not found]           ` <alpine.DEB.2.10.1410260614460.2563@hadrien>
  0 siblings, 1 reply; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-26  6:07 UTC (permalink / raw)
  To: cocci

> spatch version 1.0.0-rc20 with Python support and with PCRE support
[...]
> Fatal error: exception Failure("Show_functions_with_input_pointer_validation:
> already tagged token:
> C code context

I tried this small source code search out again.

elfring at Sonne:~/Projekte/Coccinelle/janitor> date \
> && MY_PATTERN=find_input_pointer_validation2.cocci \
> && cat $MY_PATTERN \
> && echo '-----' \
> && spatch.opt --version \
> && spatch.opt --profile --include-headers-for-types --recursive-includes \
> -I /usr/src/linux-stable/include/linux \
> -I /usr/src/linux-stable/include/uapi \
> -I /usr/src/linux-stable/arch/ia64/include \
> -I /usr/src/linux-stable/include/asm-generic \
> -I /usr/src/linux-stable/include/asm-generic/bitops \
> -I /usr/local/include/c++/4.8.2 \
> -I /usr/local/include/c++/4.8.2/x86_64-unknown-linux-gnu \
> -I /usr/local/include \
> -I /usr/include \
> --sp-file $MY_PATTERN /usr/src/linux-stable/mm/slab.c; \
> date
So 26. Okt 07:02:18 CET 2014
@Show_functions_with_input_pointer_validation@
identifier fun, x;
type t;
@@
*void fun(..., t* x, ...)
 {
  ...
  if (unlikely(ZERO_OR_NULL_PTR(x)))
     return;
  ...
 }
-----
spatch version 1.0.0-rc22 with Python support and with PCRE support
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: /usr/src/linux-stable/mm/slab.c
(ONCE) TYPE: header process.h not found
[...]
(ONCE) TYPE: header trace/events/kmem.h not found
     (ONCE) already tagged but only removed, so safe
diff =
--- /usr/src/linux-stable/mm/slab.c
@@ -3598,7 +3598,6 @@ EXPORT_SYMBOL(kmem_cache_free);
  * Don't free memory not originally allocated by kmalloc()
  * or you will run into trouble.
  */
-void kfree(const void *objp)
 {
        struct kmem_cache *c;
        unsigned long flags;
Note: processing took    43.5s: /usr/src/linux-stable/mm/slab.c
starting: Common.group_assoc_bykey_eff
ending: Common.group_assoc_bykey_eff, 0.000005s
---------------------
profiling result
---------------------
Main total                               :     43.552 sec          1 count
Main.outfiles computation                :     43.490 sec          1 count
full_engine                              :     43.481 sec          1 count
C parsing                                :     17.765 sec        866 count
TOTAL                                    :     17.763 sec        866 count
HACK                                     :      6.017 sec       2001 count
C parsing.fix_cpp                        :      5.559 sec       1134 count
C parsing.tokens                         :      3.528 sec        867 count
LEXING                                   :      3.506 sec        866 count
Parsing: multi pass                      :      2.818 sec       2369 count
Parsing: 1st pass                        :      2.258 sec      42256 count
MACRO managment                          :      1.725 sec       2671 count
YACC                                     :      1.634 sec      40007 count
TAC.annotate_program                     :      0.983 sec        433 count
show_xxx                                 :      0.855 sec        310 count
C parsing.fix_define                     :      0.761 sec       1733 count
MACRO mgmt prep 2                        :      0.494 sec        866 count
C consistencycheck                       :      0.461 sec        866 count
C parsing.lookahead                      :      0.407 sec     455401 count
Common.full_charpos_to_pos_large         :      0.389 sec        867 count
flow                                     :      0.371 sec      20946 count
C parsing.mk_info_item                   :      0.361 sec      42256 count
C parsing.lex_ident                      :      0.314 sec     313227 count
Type_c.type_of_s                         :      0.234 sec      10649 count
fix_flow                                 :      0.154 sec      15138 count
TAC.add_binding                          :      0.075 sec      18856 count
MACRO mgmt prep 1                        :      0.064 sec        866 count
pre_engine                               :      0.036 sec          1 count
parse cocci                              :      0.032 sec          1 count
bigloop                                  :      0.026 sec          1 count
Show_functions_with_input_pointer_validation :      0.023 sec          1 count
process_a_ctl_a_env_a_toplevel           :      0.023 sec        300 count
mysat                                    :      0.022 sec        300 count
Common.info_from_charpos                 :      0.018 sec         82 count
Common.=~                                :      0.013 sec       9107 count
worth_trying                             :      0.009 sec          1 count
Common.full_charpos_to_pos               :      0.005 sec          2 count
TAC.typedef_fix                          :      0.005 sec      14621 count
C unparsing                              :      0.005 sec          2 count
asttoctl2                                :      0.003 sec          1 count
ctl                                      :      0.000 sec          3 count
Transformation3.transform                :      0.000 sec          1 count
get_glimpse_constants                    :      0.000 sec          1 count
Main.result analysis                     :      0.000 sec          1 count
check_duplicate                          :      0.000 sec          1 count
Common.group_assoc_bykey_eff             :      0.000 sec          1 count
C_vs_c                                   :      0.000 sec          1 count
merge_env                                :      0.000 sec          1 count
post_engine                              :      0.000 sec          1 count
Main.infiles computation                 :      0.000 sec          1 count

So 26. Okt 07:03:01 CET 2014


Do you find this analysis result interesting?

Regards,
Markus

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

* Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
  2014-10-23 11:26                                     ` One Thousand Gnomes
  (?)
  (?)
@ 2014-10-26 12:10                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-26 12:10 UTC (permalink / raw)
  To: One Thousand Gnomes
  Cc: David Airlie, dri-devel, Daniel Vetter, Matt Roper,
	David Herrmann, Thomas Wood, Rob Clark, Patrik Jakobsson,
	Arthur Borsboom, Thierry Reding, Benoit Taine, linux-kernel,
	kernel-janitors, trivial, Coccinelle

> What platforms have you tested the code on at this point ?

None. - My "test computer" does not provide the corresponding hardware for the
affected driver source files.

Regards,
Markus

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

* Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
@ 2014-10-26 12:10                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-26 12:10 UTC (permalink / raw)
  To: cocci

> What platforms have you tested the code on at this point ?

None. - My "test computer" does not provide the corresponding hardware for the
affected driver source files.

Regards,
Markus

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

* [Cocci] [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
@ 2014-10-26 12:10                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-26 12:10 UTC (permalink / raw)
  To: cocci

> What platforms have you tested the code on at this point ?

None. - My "test computer" does not provide the corresponding hardware for the
affected driver source files.

Regards,
Markus

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

* Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
@ 2014-10-26 12:10                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-26 12:10 UTC (permalink / raw)
  To: One Thousand Gnomes
  Cc: David Airlie, dri-devel, Daniel Vetter, Matt Roper,
	David Herrmann, Thomas Wood, Rob Clark, Patrik Jakobsson,
	Arthur Borsboom, Thierry Reding, Benoit Taine, linux-kernel,
	kernel-janitors, trivial, Coccinelle

> What platforms have you tested the code on at this point ?

None. - My "test computer" does not provide the corresponding hardware for the
affected driver source files.

Regards,
Markus

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

* [Cocci] Remove unnecessary null pointer checks?
       [not found]           ` <alpine.DEB.2.10.1410260614460.2563@hadrien>
@ 2014-10-26 13:54             ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-26 13:54 UTC (permalink / raw)
  To: cocci

I would like to show again that the version 1.0.0-rc22 works better than
1.0.0-rc20 for another use case.


> There is an isomorphism for unlikely, but it does not work well.

Interesting ...


> You can disable it (look in standard.iso to find the name and then put disable
> name between the initial @@).

Does your feedback refer also to the message "(ONCE) already tagged but only
removed, so safe" eventually?


I am curious how the shown profiling results will change over time because of
software improvements.

Regards,
Markus

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

* [Cocci] [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
  2014-10-26 12:10                                       ` SF Markus Elfring
@ 2014-10-26 14:56                                         ` Arthur Borsboom
  -1 siblings, 0 replies; 3633+ messages in thread
From: Arthur Borsboom @ 2014-10-26 14:56 UTC (permalink / raw)
  To: cocci

I still have the hardware in use and I am willing to test.

If necessary, please send me a URL to the snapshot of the kernel with the
modified code. I can compile this (takes about 8 hours ;-) on the high
speed atom n2600) and run a couple of random tests, such as starting the
WM, browsing some webpages, changing resolution, and run a 2D benchmark.

Greetings,
Arthur Borsboom
On 26 Oct 2014 13:10, "SF Markus Elfring" <elfring@users.sourceforge.net>
wrote:

> > What platforms have you tested the code on at this point ?
>
> None. - My "test computer" does not provide the corresponding hardware for
> the
> affected driver source files.
>
> Regards,
> Markus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20141026/a28726a1/attachment-0001.html>

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

* Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls
@ 2014-10-26 14:56                                         ` Arthur Borsboom
  0 siblings, 0 replies; 3633+ messages in thread
From: Arthur Borsboom @ 2014-10-26 14:56 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: One Thousand Gnomes, trivial, Daniel Vetter, kernel-janitors,
	linux-kernel, dri-devel, Benoit Taine, Thierry Reding,
	Coccinelle, Thomas Wood


[-- Attachment #1.1: Type: text/plain, Size: 665 bytes --]

I still have the hardware in use and I am willing to test.

If necessary, please send me a URL to the snapshot of the kernel with the
modified code. I can compile this (takes about 8 hours ;-) on the high
speed atom n2600) and run a couple of random tests, such as starting the
WM, browsing some webpages, changing resolution, and run a 2D benchmark.

Greetings,
Arthur Borsboom
On 26 Oct 2014 13:10, "SF Markus Elfring" <elfring@users.sourceforge.net>
wrote:

> > What platforms have you tested the code on at this point ?
>
> None. - My "test computer" does not provide the corresponding hardware for
> the
> affected driver source files.
>
> Regards,
> Markus
>

[-- Attachment #1.2: Type: text/html, Size: 990 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/1] staging - rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-10-23 19:20                                   ` SF Markus Elfring
  (?)
@ 2014-10-29  8:47                                     ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 3633+ messages in thread
From: Greg Kroah-Hartman @ 2014-10-29  8:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, linux-kernel, kernel-janitors, trivial, Coccinelle

On Thu, Oct 23, 2014 at 09:20:29PM +0200, SF Markus Elfring wrote:
> >From 45970693cad6c12da2d5ac7da3d2bd7a566170d7 Mon Sep 17 00:00:00 2001
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 23 Oct 2014 20:55:13 +0200
> Subject: [PATCH] staging - rtl8188eu: Deletion of unnecessary checks before
>  three function calls

Why is this here?  Please use git send-email to send a patch, so I don't
have to hand-edit the text in it.

Also, your Subject is a bit odd, it has a "Re:" in it for no reason, and
your From: doesn't match the name you used here.

Please fix up and resend.

thanks,

greg k-h

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

* Re: [PATCH 1/1] staging - rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-29  8:47                                     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3633+ messages in thread
From: Greg Kroah-Hartman @ 2014-10-29  8:47 UTC (permalink / raw)
  To: cocci

On Thu, Oct 23, 2014 at 09:20:29PM +0200, SF Markus Elfring wrote:
> >From 45970693cad6c12da2d5ac7da3d2bd7a566170d7 Mon Sep 17 00:00:00 2001
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 23 Oct 2014 20:55:13 +0200
> Subject: [PATCH] staging - rtl8188eu: Deletion of unnecessary checks before
>  three function calls

Why is this here?  Please use git send-email to send a patch, so I don't
have to hand-edit the text in it.

Also, your Subject is a bit odd, it has a "Re:" in it for no reason, and
your From: doesn't match the name you used here.

Please fix up and resend.

thanks,

greg k-h

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

* [Cocci] [PATCH 1/1] staging - rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-29  8:47                                     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3633+ messages in thread
From: Greg Kroah-Hartman @ 2014-10-29  8:47 UTC (permalink / raw)
  To: cocci

On Thu, Oct 23, 2014 at 09:20:29PM +0200, SF Markus Elfring wrote:
> >From 45970693cad6c12da2d5ac7da3d2bd7a566170d7 Mon Sep 17 00:00:00 2001
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 23 Oct 2014 20:55:13 +0200
> Subject: [PATCH] staging - rtl8188eu: Deletion of unnecessary checks before
>  three function calls

Why is this here?  Please use git send-email to send a patch, so I don't
have to hand-edit the text in it.

Also, your Subject is a bit odd, it has a "Re:" in it for no reason, and
your From: doesn't match the name you used here.

Please fix up and resend.

thanks,

greg k-h

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

* Re: [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-10-31 17:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 17:40 UTC (permalink / raw)
  To: Ursula Braun, Martin Schwidefsky, Heiko Carstens, Frank Blaschka,
	linux390, linux-s390
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The functions debug_unregister() and kfree_fsm() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/s390/net/claw.c      |  6 ++----
 drivers/s390/net/ctcm_main.c |  6 ++----
 drivers/s390/net/lcs.c       |  6 ++----
 drivers/s390/net/netiucv.c   | 12 ++++--------
 4 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 213e54e..d609ca0 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -109,10 +109,8 @@ static debug_info_t *claw_dbf_trace;
 static void
 claw_unregister_debug_facility(void)
 {
-	if (claw_dbf_setup)
-		debug_unregister(claw_dbf_setup);
-	if (claw_dbf_trace)
-		debug_unregister(claw_dbf_trace);
+	debug_unregister(claw_dbf_setup);
+	debug_unregister(claw_dbf_trace);
 }

 static int
diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
index e056dd4..34dc0f3 100644
--- a/drivers/s390/net/ctcm_main.c
+++ b/drivers/s390/net/ctcm_main.c
@@ -1074,8 +1074,7 @@ static void ctcm_free_netdevice(struct net_device *dev)
 	if (priv) {
 		grp = priv->mpcg;
 		if (grp) {
-			if (grp->fsm)
-				kfree_fsm(grp->fsm);
+			kfree_fsm(grp->fsm);
 			if (grp->xid_skb)
 				dev_kfree_skb(grp->xid_skb);
 			if (grp->rcvd_xid_skb)
@@ -1672,8 +1671,7 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)
 		ctcm_free_netdevice(dev);
 	}

-	if (priv->fsm)
-		kfree_fsm(priv->fsm);
+	kfree_fsm(priv->fsm);

 	ccw_device_set_offline(cgdev->cdev[1]);
 	ccw_device_set_offline(cgdev->cdev[0]);
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 0a7d87c..5dfa7dd 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -88,10 +88,8 @@ static debug_info_t *lcs_dbf_trace;
 static void
 lcs_unregister_debug_facility(void)
 {
-	if (lcs_dbf_setup)
-		debug_unregister(lcs_dbf_setup);
-	if (lcs_dbf_trace)
-		debug_unregister(lcs_dbf_trace);
+	debug_unregister(lcs_dbf_setup);
+	debug_unregister(lcs_dbf_trace);
 }

 static int
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 0a87809..bdcc3fe 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -487,12 +487,9 @@ DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);

 static void iucv_unregister_dbf_views(void)
 {
-	if (iucv_dbf_setup)
-		debug_unregister(iucv_dbf_setup);
-	if (iucv_dbf_data)
-		debug_unregister(iucv_dbf_data);
-	if (iucv_dbf_trace)
-		debug_unregister(iucv_dbf_trace);
+	debug_unregister(iucv_dbf_setup);
+	debug_unregister(iucv_dbf_data);
+	debug_unregister(iucv_dbf_trace);
 }
 static int iucv_register_dbf_views(void)
 {
@@ -1975,8 +1972,7 @@ static void netiucv_free_netdevice(struct net_device *dev)
 	if (privptr) {
 		if (privptr->conn)
 			netiucv_remove_connection(privptr->conn);
-		if (privptr->fsm)
-			kfree_fsm(privptr->fsm);
+		kfree_fsm(privptr->fsm);
 		privptr->conn = NULL; privptr->fsm = NULL;
 		/* privptr gets freed by free_netdev() */
 	}
-- 
2.1.3


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

* Re: [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-10-31 17:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 17:40 UTC (permalink / raw)
  To: cocci

The functions debug_unregister() and kfree_fsm() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/s390/net/claw.c      |  6 ++----
 drivers/s390/net/ctcm_main.c |  6 ++----
 drivers/s390/net/lcs.c       |  6 ++----
 drivers/s390/net/netiucv.c   | 12 ++++--------
 4 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 213e54e..d609ca0 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -109,10 +109,8 @@ static debug_info_t *claw_dbf_trace;
 static void
 claw_unregister_debug_facility(void)
 {
-	if (claw_dbf_setup)
-		debug_unregister(claw_dbf_setup);
-	if (claw_dbf_trace)
-		debug_unregister(claw_dbf_trace);
+	debug_unregister(claw_dbf_setup);
+	debug_unregister(claw_dbf_trace);
 }

 static int
diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
index e056dd4..34dc0f3 100644
--- a/drivers/s390/net/ctcm_main.c
+++ b/drivers/s390/net/ctcm_main.c
@@ -1074,8 +1074,7 @@ static void ctcm_free_netdevice(struct net_device *dev)
 	if (priv) {
 		grp = priv->mpcg;
 		if (grp) {
-			if (grp->fsm)
-				kfree_fsm(grp->fsm);
+			kfree_fsm(grp->fsm);
 			if (grp->xid_skb)
 				dev_kfree_skb(grp->xid_skb);
 			if (grp->rcvd_xid_skb)
@@ -1672,8 +1671,7 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)
 		ctcm_free_netdevice(dev);
 	}

-	if (priv->fsm)
-		kfree_fsm(priv->fsm);
+	kfree_fsm(priv->fsm);

 	ccw_device_set_offline(cgdev->cdev[1]);
 	ccw_device_set_offline(cgdev->cdev[0]);
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 0a7d87c..5dfa7dd 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -88,10 +88,8 @@ static debug_info_t *lcs_dbf_trace;
 static void
 lcs_unregister_debug_facility(void)
 {
-	if (lcs_dbf_setup)
-		debug_unregister(lcs_dbf_setup);
-	if (lcs_dbf_trace)
-		debug_unregister(lcs_dbf_trace);
+	debug_unregister(lcs_dbf_setup);
+	debug_unregister(lcs_dbf_trace);
 }

 static int
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 0a87809..bdcc3fe 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -487,12 +487,9 @@ DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);

 static void iucv_unregister_dbf_views(void)
 {
-	if (iucv_dbf_setup)
-		debug_unregister(iucv_dbf_setup);
-	if (iucv_dbf_data)
-		debug_unregister(iucv_dbf_data);
-	if (iucv_dbf_trace)
-		debug_unregister(iucv_dbf_trace);
+	debug_unregister(iucv_dbf_setup);
+	debug_unregister(iucv_dbf_data);
+	debug_unregister(iucv_dbf_trace);
 }
 static int iucv_register_dbf_views(void)
 {
@@ -1975,8 +1972,7 @@ static void netiucv_free_netdevice(struct net_device *dev)
 	if (privptr) {
 		if (privptr->conn)
 			netiucv_remove_connection(privptr->conn);
-		if (privptr->fsm)
-			kfree_fsm(privptr->fsm);
+		kfree_fsm(privptr->fsm);
 		privptr->conn = NULL; privptr->fsm = NULL;
 		/* privptr gets freed by free_netdev() */
 	}
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-10-31 17:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 17:40 UTC (permalink / raw)
  To: cocci

The functions debug_unregister() and kfree_fsm() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/s390/net/claw.c      |  6 ++----
 drivers/s390/net/ctcm_main.c |  6 ++----
 drivers/s390/net/lcs.c       |  6 ++----
 drivers/s390/net/netiucv.c   | 12 ++++--------
 4 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 213e54e..d609ca0 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -109,10 +109,8 @@ static debug_info_t *claw_dbf_trace;
 static void
 claw_unregister_debug_facility(void)
 {
-	if (claw_dbf_setup)
-		debug_unregister(claw_dbf_setup);
-	if (claw_dbf_trace)
-		debug_unregister(claw_dbf_trace);
+	debug_unregister(claw_dbf_setup);
+	debug_unregister(claw_dbf_trace);
 }

 static int
diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
index e056dd4..34dc0f3 100644
--- a/drivers/s390/net/ctcm_main.c
+++ b/drivers/s390/net/ctcm_main.c
@@ -1074,8 +1074,7 @@ static void ctcm_free_netdevice(struct net_device *dev)
 	if (priv) {
 		grp = priv->mpcg;
 		if (grp) {
-			if (grp->fsm)
-				kfree_fsm(grp->fsm);
+			kfree_fsm(grp->fsm);
 			if (grp->xid_skb)
 				dev_kfree_skb(grp->xid_skb);
 			if (grp->rcvd_xid_skb)
@@ -1672,8 +1671,7 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)
 		ctcm_free_netdevice(dev);
 	}

-	if (priv->fsm)
-		kfree_fsm(priv->fsm);
+	kfree_fsm(priv->fsm);

 	ccw_device_set_offline(cgdev->cdev[1]);
 	ccw_device_set_offline(cgdev->cdev[0]);
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 0a7d87c..5dfa7dd 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -88,10 +88,8 @@ static debug_info_t *lcs_dbf_trace;
 static void
 lcs_unregister_debug_facility(void)
 {
-	if (lcs_dbf_setup)
-		debug_unregister(lcs_dbf_setup);
-	if (lcs_dbf_trace)
-		debug_unregister(lcs_dbf_trace);
+	debug_unregister(lcs_dbf_setup);
+	debug_unregister(lcs_dbf_trace);
 }

 static int
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 0a87809..bdcc3fe 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -487,12 +487,9 @@ DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);

 static void iucv_unregister_dbf_views(void)
 {
-	if (iucv_dbf_setup)
-		debug_unregister(iucv_dbf_setup);
-	if (iucv_dbf_data)
-		debug_unregister(iucv_dbf_data);
-	if (iucv_dbf_trace)
-		debug_unregister(iucv_dbf_trace);
+	debug_unregister(iucv_dbf_setup);
+	debug_unregister(iucv_dbf_data);
+	debug_unregister(iucv_dbf_trace);
 }
 static int iucv_register_dbf_views(void)
 {
@@ -1975,8 +1972,7 @@ static void netiucv_free_netdevice(struct net_device *dev)
 	if (privptr) {
 		if (privptr->conn)
 			netiucv_remove_connection(privptr->conn);
-		if (privptr->fsm)
-			kfree_fsm(privptr->fsm);
+		kfree_fsm(privptr->fsm);
 		privptr->conn = NULL; privptr->fsm = NULL;
 		/* privptr gets freed by free_netdev() */
 	}
-- 
2.1.3

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

* [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-10-29  8:47                                     ` Greg Kroah-Hartman
  (?)
@ 2014-10-31 17:55                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 17:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The functions kfree(), rtw_free_netdev() and vfree() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 7006088..77f7552 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
_size_byte, u8  *pbuf)
 exit:
 	kfree(efuseTbl);

-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(eFuseWord);
 }

 static void efuse_read_phymap_from_txpktbuf(
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 149c271..df54350 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 	rtw_free_mlme_priv_ie_data(pmlmepriv);

 	if (pmlmepriv) {
-		if (pmlmepriv->free_bss_buf)
-			vfree(pmlmepriv->free_bss_buf);
+		vfree(pmlmepriv->free_bss_buf);
 	}
 }

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index e1dc8fa..af1de9c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)

 		rtw_mfree_sta_priv_lock(pstapriv);

-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
+		vfree(pstapriv->pallocated_stainfo_buf);
 	}

 	return _SUCCESS;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 639ace0..011c9cf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
 		pxmitbuf++;
 	}

-	if (pxmitpriv->pallocated_frame_buf)
-		vfree(pxmitpriv->pallocated_frame_buf);
+	vfree(pxmitpriv->pallocated_frame_buf);

-	if (pxmitpriv->pallocated_xmitbuf)
-		vfree(pxmitpriv->pallocated_xmitbuf);
+	vfree(pxmitpriv->pallocated_xmitbuf);

 	/*  free xmit extension buff */
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318..cdb70e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -456,7 +456,7 @@ free_adapter:
 	if (status != _SUCCESS) {
 		if (pnetdev)
 			rtw_free_netdev(pnetdev);
-		else if (padapter)
+		else
 			vfree(padapter);
 		padapter = NULL;
 	}
@@ -487,8 +487,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
 	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
 		if1->hw_init_completed);
 	rtw_free_drv_sw(if1);
-	if (pnetdev)
-		rtw_free_netdev(pnetdev);
+	rtw_free_netdev(pnetdev);
 }

 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct
usb_device_id *pdid)
-- 
2.1.2


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

* [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-31 17:55                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 17:55 UTC (permalink / raw)
  To: cocci

The functions kfree(), rtw_free_netdev() and vfree() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 7006088..77f7552 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
_size_byte, u8  *pbuf)
 exit:
 	kfree(efuseTbl);

-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(eFuseWord);
 }

 static void efuse_read_phymap_from_txpktbuf(
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 149c271..df54350 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 	rtw_free_mlme_priv_ie_data(pmlmepriv);

 	if (pmlmepriv) {
-		if (pmlmepriv->free_bss_buf)
-			vfree(pmlmepriv->free_bss_buf);
+		vfree(pmlmepriv->free_bss_buf);
 	}
 }

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index e1dc8fa..af1de9c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)

 		rtw_mfree_sta_priv_lock(pstapriv);

-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
+		vfree(pstapriv->pallocated_stainfo_buf);
 	}

 	return _SUCCESS;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 639ace0..011c9cf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
 		pxmitbuf++;
 	}

-	if (pxmitpriv->pallocated_frame_buf)
-		vfree(pxmitpriv->pallocated_frame_buf);
+	vfree(pxmitpriv->pallocated_frame_buf);

-	if (pxmitpriv->pallocated_xmitbuf)
-		vfree(pxmitpriv->pallocated_xmitbuf);
+	vfree(pxmitpriv->pallocated_xmitbuf);

 	/*  free xmit extension buff */
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318..cdb70e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -456,7 +456,7 @@ free_adapter:
 	if (status != _SUCCESS) {
 		if (pnetdev)
 			rtw_free_netdev(pnetdev);
-		else if (padapter)
+		else
 			vfree(padapter);
 		padapter = NULL;
 	}
@@ -487,8 +487,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
 	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
 		if1->hw_init_completed);
 	rtw_free_drv_sw(if1);
-	if (pnetdev)
-		rtw_free_netdev(pnetdev);
+	rtw_free_netdev(pnetdev);
 }

 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct
usb_device_id *pdid)
-- 
2.1.2


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

* [Cocci] [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-31 17:55                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 17:55 UTC (permalink / raw)
  To: cocci

The functions kfree(), rtw_free_netdev() and vfree() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 7006088..77f7552 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
_size_byte, u8  *pbuf)
 exit:
 	kfree(efuseTbl);

-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(eFuseWord);
 }

 static void efuse_read_phymap_from_txpktbuf(
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 149c271..df54350 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 	rtw_free_mlme_priv_ie_data(pmlmepriv);

 	if (pmlmepriv) {
-		if (pmlmepriv->free_bss_buf)
-			vfree(pmlmepriv->free_bss_buf);
+		vfree(pmlmepriv->free_bss_buf);
 	}
 }

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index e1dc8fa..af1de9c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)

 		rtw_mfree_sta_priv_lock(pstapriv);

-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
+		vfree(pstapriv->pallocated_stainfo_buf);
 	}

 	return _SUCCESS;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 639ace0..011c9cf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
 		pxmitbuf++;
 	}

-	if (pxmitpriv->pallocated_frame_buf)
-		vfree(pxmitpriv->pallocated_frame_buf);
+	vfree(pxmitpriv->pallocated_frame_buf);

-	if (pxmitpriv->pallocated_xmitbuf)
-		vfree(pxmitpriv->pallocated_xmitbuf);
+	vfree(pxmitpriv->pallocated_xmitbuf);

 	/*  free xmit extension buff */
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318..cdb70e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -456,7 +456,7 @@ free_adapter:
 	if (status != _SUCCESS) {
 		if (pnetdev)
 			rtw_free_netdev(pnetdev);
-		else if (padapter)
+		else
 			vfree(padapter);
 		padapter = NULL;
 	}
@@ -487,8 +487,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
 	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
 		if1->hw_init_completed);
 	rtw_free_drv_sw(if1);
-	if (pnetdev)
-		rtw_free_netdev(pnetdev);
+	rtw_free_netdev(pnetdev);
 }

 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct
usb_device_id *pdid)
-- 
2.1.2

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

* Re: [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-10-31 17:55                                       ` SF Markus Elfring
  (?)
@ 2014-10-31 18:01                                         ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-10-31 18:01 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

On Fri, 31 Oct 2014, SF Markus Elfring wrote:

> The functions kfree(), rtw_free_netdev() and vfree() test whether their
> argument is NULL and then return immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
>  5 files changed, 7 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 7006088..77f7552 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
> _size_byte, u8  *pbuf)
>  exit:
>  	kfree(efuseTbl);
>
> -	if (eFuseWord)
> -		kfree(eFuseWord);
> +	kfree(eFuseWord);

I think that this code has been updated already.  It would be better to
add labels so that kfree is only executed when needed.

julia

>  }
>
>  static void efuse_read_phymap_from_txpktbuf(
> diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c
> b/drivers/staging/rtl8188eu/core/rtw_mlme.c
> index 149c271..df54350 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
> @@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
>  	rtw_free_mlme_priv_ie_data(pmlmepriv);
>
>  	if (pmlmepriv) {
> -		if (pmlmepriv->free_bss_buf)
> -			vfree(pmlmepriv->free_bss_buf);
> +		vfree(pmlmepriv->free_bss_buf);
>  	}
>  }
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> index e1dc8fa..af1de9c 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> @@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
>
>  		rtw_mfree_sta_priv_lock(pstapriv);
>
> -		if (pstapriv->pallocated_stainfo_buf)
> -			vfree(pstapriv->pallocated_stainfo_buf);
> +		vfree(pstapriv->pallocated_stainfo_buf);
>  	}
>
>  	return _SUCCESS;
> diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> index 639ace0..011c9cf 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> @@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
>  		pxmitbuf++;
>  	}
>
> -	if (pxmitpriv->pallocated_frame_buf)
> -		vfree(pxmitpriv->pallocated_frame_buf);
> +	vfree(pxmitpriv->pallocated_frame_buf);
>
> -	if (pxmitpriv->pallocated_xmitbuf)
> -		vfree(pxmitpriv->pallocated_xmitbuf);
> +	vfree(pxmitpriv->pallocated_xmitbuf);
>
>  	/*  free xmit extension buff */
>  	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
> diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> index 407a318..cdb70e4 100644
> --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> @@ -456,7 +456,7 @@ free_adapter:
>  	if (status != _SUCCESS) {
>  		if (pnetdev)
>  			rtw_free_netdev(pnetdev);
> -		else if (padapter)
> +		else
>  			vfree(padapter);
>  		padapter = NULL;
>  	}
> @@ -487,8 +487,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>  	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
>  		if1->hw_init_completed);
>  	rtw_free_drv_sw(if1);
> -	if (pnetdev)
> -		rtw_free_netdev(pnetdev);
> +	rtw_free_netdev(pnetdev);
>  }
>
>  static int rtw_drv_init(struct usb_interface *pusb_intf, const struct
> usb_device_id *pdid)
> --
> 2.1.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-31 18:01                                         ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-10-31 18:01 UTC (permalink / raw)
  To: cocci

On Fri, 31 Oct 2014, SF Markus Elfring wrote:

> The functions kfree(), rtw_free_netdev() and vfree() test whether their
> argument is NULL and then return immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
>  5 files changed, 7 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 7006088..77f7552 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
> _size_byte, u8  *pbuf)
>  exit:
>  	kfree(efuseTbl);
>
> -	if (eFuseWord)
> -		kfree(eFuseWord);
> +	kfree(eFuseWord);

I think that this code has been updated already.  It would be better to
add labels so that kfree is only executed when needed.

julia

>  }
>
>  static void efuse_read_phymap_from_txpktbuf(
> diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c
> b/drivers/staging/rtl8188eu/core/rtw_mlme.c
> index 149c271..df54350 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
> @@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
>  	rtw_free_mlme_priv_ie_data(pmlmepriv);
>
>  	if (pmlmepriv) {
> -		if (pmlmepriv->free_bss_buf)
> -			vfree(pmlmepriv->free_bss_buf);
> +		vfree(pmlmepriv->free_bss_buf);
>  	}
>  }
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> index e1dc8fa..af1de9c 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> @@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
>
>  		rtw_mfree_sta_priv_lock(pstapriv);
>
> -		if (pstapriv->pallocated_stainfo_buf)
> -			vfree(pstapriv->pallocated_stainfo_buf);
> +		vfree(pstapriv->pallocated_stainfo_buf);
>  	}
>
>  	return _SUCCESS;
> diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> index 639ace0..011c9cf 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> @@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
>  		pxmitbuf++;
>  	}
>
> -	if (pxmitpriv->pallocated_frame_buf)
> -		vfree(pxmitpriv->pallocated_frame_buf);
> +	vfree(pxmitpriv->pallocated_frame_buf);
>
> -	if (pxmitpriv->pallocated_xmitbuf)
> -		vfree(pxmitpriv->pallocated_xmitbuf);
> +	vfree(pxmitpriv->pallocated_xmitbuf);
>
>  	/*  free xmit extension buff */
>  	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
> diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> index 407a318..cdb70e4 100644
> --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> @@ -456,7 +456,7 @@ free_adapter:
>  	if (status != _SUCCESS) {
>  		if (pnetdev)
>  			rtw_free_netdev(pnetdev);
> -		else if (padapter)
> +		else
>  			vfree(padapter);
>  		padapter = NULL;
>  	}
> @@ -487,8 +487,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>  	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
>  		if1->hw_init_completed);
>  	rtw_free_drv_sw(if1);
> -	if (pnetdev)
> -		rtw_free_netdev(pnetdev);
> +	rtw_free_netdev(pnetdev);
>  }
>
>  static int rtw_drv_init(struct usb_interface *pusb_intf, const struct
> usb_device_id *pdid)
> --
> 2.1.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* [Cocci] [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-31 18:01                                         ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-10-31 18:01 UTC (permalink / raw)
  To: cocci

On Fri, 31 Oct 2014, SF Markus Elfring wrote:

> The functions kfree(), rtw_free_netdev() and vfree() test whether their
> argument is NULL and then return immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
>  5 files changed, 7 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 7006088..77f7552 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
> _size_byte, u8  *pbuf)
>  exit:
>  	kfree(efuseTbl);
>
> -	if (eFuseWord)
> -		kfree(eFuseWord);
> +	kfree(eFuseWord);

I think that this code has been updated already.  It would be better to
add labels so that kfree is only executed when needed.

julia

>  }
>
>  static void efuse_read_phymap_from_txpktbuf(
> diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c
> b/drivers/staging/rtl8188eu/core/rtw_mlme.c
> index 149c271..df54350 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
> @@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
>  	rtw_free_mlme_priv_ie_data(pmlmepriv);
>
>  	if (pmlmepriv) {
> -		if (pmlmepriv->free_bss_buf)
> -			vfree(pmlmepriv->free_bss_buf);
> +		vfree(pmlmepriv->free_bss_buf);
>  	}
>  }
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> index e1dc8fa..af1de9c 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
> @@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
>
>  		rtw_mfree_sta_priv_lock(pstapriv);
>
> -		if (pstapriv->pallocated_stainfo_buf)
> -			vfree(pstapriv->pallocated_stainfo_buf);
> +		vfree(pstapriv->pallocated_stainfo_buf);
>  	}
>
>  	return _SUCCESS;
> diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> index 639ace0..011c9cf 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> @@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
>  		pxmitbuf++;
>  	}
>
> -	if (pxmitpriv->pallocated_frame_buf)
> -		vfree(pxmitpriv->pallocated_frame_buf);
> +	vfree(pxmitpriv->pallocated_frame_buf);
>
> -	if (pxmitpriv->pallocated_xmitbuf)
> -		vfree(pxmitpriv->pallocated_xmitbuf);
> +	vfree(pxmitpriv->pallocated_xmitbuf);
>
>  	/*  free xmit extension buff */
>  	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
> diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> index 407a318..cdb70e4 100644
> --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
> @@ -456,7 +456,7 @@ free_adapter:
>  	if (status != _SUCCESS) {
>  		if (pnetdev)
>  			rtw_free_netdev(pnetdev);
> -		else if (padapter)
> +		else
>  			vfree(padapter);
>  		padapter = NULL;
>  	}
> @@ -487,8 +487,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>  	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
>  		if1->hw_init_completed);
>  	rtw_free_drv_sw(if1);
> -	if (pnetdev)
> -		rtw_free_netdev(pnetdev);
> +	rtw_free_netdev(pnetdev);
>  }
>
>  static int rtw_drv_init(struct usb_interface *pusb_intf, const struct
> usb_device_id *pdid)
> --
> 2.1.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-10-31 18:01                                         ` Julia Lawall
  (?)
@ 2014-10-31 18:08                                           ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 18:08 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Greg Kroah-Hartman, devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

>> The functions kfree(), rtw_free_netdev() and vfree() test whether their
>> argument is NULL and then return immediately. Thus the test around the call
>> is not needed.
>>
>> This issue was detected by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
>>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
>>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
>>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
>>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
>>  5 files changed, 7 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> b/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> index 7006088..77f7552 100644
>> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
>> _size_byte, u8  *pbuf)
>>  exit:
>>  	kfree(efuseTbl);
>>
>> -	if (eFuseWord)
>> -		kfree(eFuseWord);
>> +	kfree(eFuseWord);
> 
> I think that this code has been updated already.  It would be better to
> add labels so that kfree is only executed when needed.

Are there any chances to achieve the suggested fine-tuning for jump labels
also with another semantic patch approach?

Regards,
Markus

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

* Re: [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-31 18:08                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 18:08 UTC (permalink / raw)
  To: cocci

>> The functions kfree(), rtw_free_netdev() and vfree() test whether their
>> argument is NULL and then return immediately. Thus the test around the call
>> is not needed.
>>
>> This issue was detected by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
>>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
>>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
>>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
>>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
>>  5 files changed, 7 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> b/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> index 7006088..77f7552 100644
>> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
>> _size_byte, u8  *pbuf)
>>  exit:
>>  	kfree(efuseTbl);
>>
>> -	if (eFuseWord)
>> -		kfree(eFuseWord);
>> +	kfree(eFuseWord);
> 
> I think that this code has been updated already.  It would be better to
> add labels so that kfree is only executed when needed.

Are there any chances to achieve the suggested fine-tuning for jump labels
also with another semantic patch approach?

Regards,
Markus

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

* [Cocci] [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-31 18:08                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 18:08 UTC (permalink / raw)
  To: cocci

>> The functions kfree(), rtw_free_netdev() and vfree() test whether their
>> argument is NULL and then return immediately. Thus the test around the call
>> is not needed.
>>
>> This issue was detected by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
>>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
>>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
>>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
>>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
>>  5 files changed, 7 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> b/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> index 7006088..77f7552 100644
>> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
>> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
>> _size_byte, u8  *pbuf)
>>  exit:
>>  	kfree(efuseTbl);
>>
>> -	if (eFuseWord)
>> -		kfree(eFuseWord);
>> +	kfree(eFuseWord);
> 
> I think that this code has been updated already.  It would be better to
> add labels so that kfree is only executed when needed.

Are there any chances to achieve the suggested fine-tuning for jump labels
also with another semantic patch approach?

Regards,
Markus

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

* Re: [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-10-31 18:08                                           ` SF Markus Elfring
  (?)
@ 2014-10-31 18:11                                             ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-10-31 18:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

On Fri, 31 Oct 2014, SF Markus Elfring wrote:

> >> The functions kfree(), rtw_free_netdev() and vfree() test whether their
> >> argument is NULL and then return immediately. Thus the test around the call
> >> is not needed.
> >>
> >> This issue was detected by using the Coccinelle software.
> >>
> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >> ---
> >>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
> >>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
> >>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
> >>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
> >>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
> >>  5 files changed, 7 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> index 7006088..77f7552 100644
> >> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
> >> _size_byte, u8  *pbuf)
> >>  exit:
> >>  	kfree(efuseTbl);
> >>
> >> -	if (eFuseWord)
> >> -		kfree(eFuseWord);
> >> +	kfree(eFuseWord);
> >
> > I think that this code has been updated already.  It would be better to
> > add labels so that kfree is only executed when needed.
>
> Are there any chances to achieve the suggested fine-tuning for jump labels
> also with another semantic patch approach?

No, I don't think so.  The pattern is not regular enough.

julia

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

* Re: [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-31 18:11                                             ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-10-31 18:11 UTC (permalink / raw)
  To: cocci

On Fri, 31 Oct 2014, SF Markus Elfring wrote:

> >> The functions kfree(), rtw_free_netdev() and vfree() test whether their
> >> argument is NULL and then return immediately. Thus the test around the call
> >> is not needed.
> >>
> >> This issue was detected by using the Coccinelle software.
> >>
> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >> ---
> >>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
> >>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
> >>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
> >>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
> >>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
> >>  5 files changed, 7 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> index 7006088..77f7552 100644
> >> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
> >> _size_byte, u8  *pbuf)
> >>  exit:
> >>  	kfree(efuseTbl);
> >>
> >> -	if (eFuseWord)
> >> -		kfree(eFuseWord);
> >> +	kfree(eFuseWord);
> >
> > I think that this code has been updated already.  It would be better to
> > add labels so that kfree is only executed when needed.
>
> Are there any chances to achieve the suggested fine-tuning for jump labels
> also with another semantic patch approach?

No, I don't think so.  The pattern is not regular enough.

julia

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

* [Cocci] [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-10-31 18:11                                             ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-10-31 18:11 UTC (permalink / raw)
  To: cocci

On Fri, 31 Oct 2014, SF Markus Elfring wrote:

> >> The functions kfree(), rtw_free_netdev() and vfree() test whether their
> >> argument is NULL and then return immediately. Thus the test around the call
> >> is not needed.
> >>
> >> This issue was detected by using the Coccinelle software.
> >>
> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >> ---
> >>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
> >>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
> >>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
> >>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
> >>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 5 ++---
> >>  5 files changed, 7 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> index 7006088..77f7552 100644
> >> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> >> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
> >> _size_byte, u8  *pbuf)
> >>  exit:
> >>  	kfree(efuseTbl);
> >>
> >> -	if (eFuseWord)
> >> -		kfree(eFuseWord);
> >> +	kfree(eFuseWord);
> >
> > I think that this code has been updated already.  It would be better to
> > add labels so that kfree is only executed when needed.
>
> Are there any chances to achieve the suggested fine-tuning for jump labels
> also with another semantic patch approach?

No, I don't think so.  The pattern is not regular enough.

julia

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

* [PATCH 1/1] btrfs: Deletion of unnecessary checks before six function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-10-31 21:52                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 21:52 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, linux-btrfs
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The following functions test whether their argument is NULL and then
return immediately.
* btrfs_free_path()
* free_extent_buffer()
* free_extent_map()
* free_extent_state()
* iput()
* kfree()

Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/btrfs/dev-replace.c       |  3 +--
 fs/btrfs/extent_io.c         | 12 ++++--------
 fs/btrfs/file.c              |  6 ++----
 fs/btrfs/free-space-cache.c  |  7 +++----
 fs/btrfs/inode.c             |  6 ++----
 fs/btrfs/reada.c             |  3 +--
 fs/btrfs/relocation.c        |  3 +--
 fs/btrfs/tests/btrfs-tests.c |  3 +--
 fs/btrfs/tree-defrag.c       |  3 +--
 fs/btrfs/tree-log.c          |  6 ++----
 10 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 6f662b3..3465029 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -183,8 +183,7 @@ no_valid_dev_replace_entry_found:
 	}

 out:
-	if (path)
-		btrfs_free_path(path);
+	btrfs_free_path(path);
 	return ret;
 }

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index bf3f424..cfbf00a 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -704,8 +704,7 @@ next:

 out:
 	spin_unlock(&tree->lock);
-	if (prealloc)
-		free_extent_state(prealloc);
+	free_extent_state(prealloc);

 	return 0;

@@ -1006,8 +1005,7 @@ hit_next:

 out:
 	spin_unlock(&tree->lock);
-	if (prealloc)
-		free_extent_state(prealloc);
+	free_extent_state(prealloc);

 	return err;

@@ -1223,8 +1221,7 @@ hit_next:

 out:
 	spin_unlock(&tree->lock);
-	if (prealloc)
-		free_extent_state(prealloc);
+	free_extent_state(prealloc);

 	return err;

@@ -4146,8 +4143,7 @@ int extent_readpages(struct extent_io_tree *tree,
 		__extent_readpages(tree, pagepool, nr, get_extent, &em_cached,
 				   &bio, 0, &bio_flags, READ);

-	if (em_cached)
-		free_extent_map(em_cached);
+	free_extent_map(em_cached);

 	BUG_ON(!list_empty(pages));
 	if (bio)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a18ceab..add07ce8 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -677,10 +677,8 @@ next:
 		/* once for the tree*/
 		free_extent_map(em);
 	}
-	if (split)
-		free_extent_map(split);
-	if (split2)
-		free_extent_map(split2);
+	free_extent_map(split);
+	free_extent_map(split2);
 }

 /*
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 3384819..11883e2 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1943,8 +1943,7 @@ new_bitmap:

 out:
 	if (info) {
-		if (info->bitmap)
-			kfree(info->bitmap);
+		kfree(info->bitmap);
 		kmem_cache_free(btrfs_free_space_cachep, info);
 	}

@@ -3322,8 +3321,8 @@ again:

 	if (info)
 		kmem_cache_free(btrfs_free_space_cachep, info);
-	if (map)
-		kfree(map);
+
+	kfree(map);
 	return 0;
 }

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d23362f..7301b99 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -857,8 +857,7 @@ static u64 get_extent_allocation_hint(struct inode *inode,
u64 start,
 			em = search_extent_mapping(em_tree, 0, 0);
 			if (em && em->block_start < EXTENT_MAP_LAST_BYTE)
 				alloc_hint = em->block_start;
-			if (em)
-				free_extent_map(em);
+			free_extent_map(em);
 		} else {
 			alloc_hint = em->block_start;
 			free_extent_map(em);
@@ -6573,8 +6572,7 @@ out:

 	trace_btrfs_get_extent(root, em);

-	if (path)
-		btrfs_free_path(path);
+	btrfs_free_path(path);
 	if (trans) {
 		ret = btrfs_end_transaction(trans, root);
 		if (!err)
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index b63ae20..ec8eb49 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -731,8 +731,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info
*fs_info,
 	else if (eb)
 		__readahead_hook(fs_info->extent_root, eb, eb->start, ret);

-	if (eb)
-		free_extent_buffer(eb);
+	free_extent_buffer(eb);

 	return 1;

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 74257d6..f87a5ee 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4158,8 +4158,7 @@ out:
 	btrfs_end_transaction(trans, root);
 	btrfs_btree_balance_dirty(root);
 	if (err) {
-		if (inode)
-			iput(inode);
+		iput(inode);
 		inode = ERR_PTR(err);
 	}
 	return inode;
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index 9626252..7fb123f 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -162,8 +162,7 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
 {
 	if (!root)
 		return;
-	if (root->node)
-		free_extent_buffer(root->node);
+	free_extent_buffer(root->node);
 	if (root->fs_info)
 		btrfs_free_dummy_fs_info(root->fs_info);
 	kfree(root);
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index a63719c..c74f106 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -118,8 +118,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
 		ret = -EAGAIN;
 	}
 out:
-	if (path)
-		btrfs_free_path(path);
+	btrfs_free_path(path);
 	if (ret == -EAGAIN) {
 		if (root->defrag_max.objectid > root->defrag_progress.objectid)
 			goto done;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1475979..70926a9 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -736,8 +736,7 @@ static noinline int replay_one_extent(struct
btrfs_trans_handle *trans,
 	inode_add_bytes(inode, nbytes);
 	ret = btrfs_update_inode(trans, root, inode);
 out:
-	if (inode)
-		iput(inode);
+	iput(inode);
 	return ret;
 }

@@ -2210,8 +2209,7 @@ static noinline int walk_down_log_tree(struct
btrfs_trans_handle *trans,
 		}

 		WARN_ON(*level <= 0);
-		if (path->nodes[*level-1])
-			free_extent_buffer(path->nodes[*level-1]);
+		free_extent_buffer(path->nodes[*level-1]);
 		path->nodes[*level-1] = next;
 		*level = btrfs_header_level(next);
 		path->slots[*level] = 0;
-- 
2.1.3



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

* [PATCH 1/1] btrfs: Deletion of unnecessary checks before six function calls
@ 2014-10-31 21:52                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 21:52 UTC (permalink / raw)
  To: cocci

The following functions test whether their argument is NULL and then
return immediately.
* btrfs_free_path()
* free_extent_buffer()
* free_extent_map()
* free_extent_state()
* iput()
* kfree()

Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/btrfs/dev-replace.c       |  3 +--
 fs/btrfs/extent_io.c         | 12 ++++--------
 fs/btrfs/file.c              |  6 ++----
 fs/btrfs/free-space-cache.c  |  7 +++----
 fs/btrfs/inode.c             |  6 ++----
 fs/btrfs/reada.c             |  3 +--
 fs/btrfs/relocation.c        |  3 +--
 fs/btrfs/tests/btrfs-tests.c |  3 +--
 fs/btrfs/tree-defrag.c       |  3 +--
 fs/btrfs/tree-log.c          |  6 ++----
 10 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 6f662b3..3465029 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -183,8 +183,7 @@ no_valid_dev_replace_entry_found:
 	}

 out:
-	if (path)
-		btrfs_free_path(path);
+	btrfs_free_path(path);
 	return ret;
 }

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index bf3f424..cfbf00a 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -704,8 +704,7 @@ next:

 out:
 	spin_unlock(&tree->lock);
-	if (prealloc)
-		free_extent_state(prealloc);
+	free_extent_state(prealloc);

 	return 0;

@@ -1006,8 +1005,7 @@ hit_next:

 out:
 	spin_unlock(&tree->lock);
-	if (prealloc)
-		free_extent_state(prealloc);
+	free_extent_state(prealloc);

 	return err;

@@ -1223,8 +1221,7 @@ hit_next:

 out:
 	spin_unlock(&tree->lock);
-	if (prealloc)
-		free_extent_state(prealloc);
+	free_extent_state(prealloc);

 	return err;

@@ -4146,8 +4143,7 @@ int extent_readpages(struct extent_io_tree *tree,
 		__extent_readpages(tree, pagepool, nr, get_extent, &em_cached,
 				   &bio, 0, &bio_flags, READ);

-	if (em_cached)
-		free_extent_map(em_cached);
+	free_extent_map(em_cached);

 	BUG_ON(!list_empty(pages));
 	if (bio)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a18ceab..add07ce8 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -677,10 +677,8 @@ next:
 		/* once for the tree*/
 		free_extent_map(em);
 	}
-	if (split)
-		free_extent_map(split);
-	if (split2)
-		free_extent_map(split2);
+	free_extent_map(split);
+	free_extent_map(split2);
 }

 /*
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 3384819..11883e2 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1943,8 +1943,7 @@ new_bitmap:

 out:
 	if (info) {
-		if (info->bitmap)
-			kfree(info->bitmap);
+		kfree(info->bitmap);
 		kmem_cache_free(btrfs_free_space_cachep, info);
 	}

@@ -3322,8 +3321,8 @@ again:

 	if (info)
 		kmem_cache_free(btrfs_free_space_cachep, info);
-	if (map)
-		kfree(map);
+
+	kfree(map);
 	return 0;
 }

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d23362f..7301b99 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -857,8 +857,7 @@ static u64 get_extent_allocation_hint(struct inode *inode,
u64 start,
 			em = search_extent_mapping(em_tree, 0, 0);
 			if (em && em->block_start < EXTENT_MAP_LAST_BYTE)
 				alloc_hint = em->block_start;
-			if (em)
-				free_extent_map(em);
+			free_extent_map(em);
 		} else {
 			alloc_hint = em->block_start;
 			free_extent_map(em);
@@ -6573,8 +6572,7 @@ out:

 	trace_btrfs_get_extent(root, em);

-	if (path)
-		btrfs_free_path(path);
+	btrfs_free_path(path);
 	if (trans) {
 		ret = btrfs_end_transaction(trans, root);
 		if (!err)
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index b63ae20..ec8eb49 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -731,8 +731,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info
*fs_info,
 	else if (eb)
 		__readahead_hook(fs_info->extent_root, eb, eb->start, ret);

-	if (eb)
-		free_extent_buffer(eb);
+	free_extent_buffer(eb);

 	return 1;

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 74257d6..f87a5ee 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4158,8 +4158,7 @@ out:
 	btrfs_end_transaction(trans, root);
 	btrfs_btree_balance_dirty(root);
 	if (err) {
-		if (inode)
-			iput(inode);
+		iput(inode);
 		inode = ERR_PTR(err);
 	}
 	return inode;
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index 9626252..7fb123f 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -162,8 +162,7 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
 {
 	if (!root)
 		return;
-	if (root->node)
-		free_extent_buffer(root->node);
+	free_extent_buffer(root->node);
 	if (root->fs_info)
 		btrfs_free_dummy_fs_info(root->fs_info);
 	kfree(root);
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index a63719c..c74f106 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -118,8 +118,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
 		ret = -EAGAIN;
 	}
 out:
-	if (path)
-		btrfs_free_path(path);
+	btrfs_free_path(path);
 	if (ret = -EAGAIN) {
 		if (root->defrag_max.objectid > root->defrag_progress.objectid)
 			goto done;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1475979..70926a9 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -736,8 +736,7 @@ static noinline int replay_one_extent(struct
btrfs_trans_handle *trans,
 	inode_add_bytes(inode, nbytes);
 	ret = btrfs_update_inode(trans, root, inode);
 out:
-	if (inode)
-		iput(inode);
+	iput(inode);
 	return ret;
 }

@@ -2210,8 +2209,7 @@ static noinline int walk_down_log_tree(struct
btrfs_trans_handle *trans,
 		}

 		WARN_ON(*level <= 0);
-		if (path->nodes[*level-1])
-			free_extent_buffer(path->nodes[*level-1]);
+		free_extent_buffer(path->nodes[*level-1]);
 		path->nodes[*level-1] = next;
 		*level = btrfs_header_level(next);
 		path->slots[*level] = 0;
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] btrfs: Deletion of unnecessary checks before six function calls
@ 2014-10-31 21:52                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-10-31 21:52 UTC (permalink / raw)
  To: cocci

The following functions test whether their argument is NULL and then
return immediately.
* btrfs_free_path()
* free_extent_buffer()
* free_extent_map()
* free_extent_state()
* iput()
* kfree()

Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/btrfs/dev-replace.c       |  3 +--
 fs/btrfs/extent_io.c         | 12 ++++--------
 fs/btrfs/file.c              |  6 ++----
 fs/btrfs/free-space-cache.c  |  7 +++----
 fs/btrfs/inode.c             |  6 ++----
 fs/btrfs/reada.c             |  3 +--
 fs/btrfs/relocation.c        |  3 +--
 fs/btrfs/tests/btrfs-tests.c |  3 +--
 fs/btrfs/tree-defrag.c       |  3 +--
 fs/btrfs/tree-log.c          |  6 ++----
 10 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 6f662b3..3465029 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -183,8 +183,7 @@ no_valid_dev_replace_entry_found:
 	}

 out:
-	if (path)
-		btrfs_free_path(path);
+	btrfs_free_path(path);
 	return ret;
 }

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index bf3f424..cfbf00a 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -704,8 +704,7 @@ next:

 out:
 	spin_unlock(&tree->lock);
-	if (prealloc)
-		free_extent_state(prealloc);
+	free_extent_state(prealloc);

 	return 0;

@@ -1006,8 +1005,7 @@ hit_next:

 out:
 	spin_unlock(&tree->lock);
-	if (prealloc)
-		free_extent_state(prealloc);
+	free_extent_state(prealloc);

 	return err;

@@ -1223,8 +1221,7 @@ hit_next:

 out:
 	spin_unlock(&tree->lock);
-	if (prealloc)
-		free_extent_state(prealloc);
+	free_extent_state(prealloc);

 	return err;

@@ -4146,8 +4143,7 @@ int extent_readpages(struct extent_io_tree *tree,
 		__extent_readpages(tree, pagepool, nr, get_extent, &em_cached,
 				   &bio, 0, &bio_flags, READ);

-	if (em_cached)
-		free_extent_map(em_cached);
+	free_extent_map(em_cached);

 	BUG_ON(!list_empty(pages));
 	if (bio)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a18ceab..add07ce8 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -677,10 +677,8 @@ next:
 		/* once for the tree*/
 		free_extent_map(em);
 	}
-	if (split)
-		free_extent_map(split);
-	if (split2)
-		free_extent_map(split2);
+	free_extent_map(split);
+	free_extent_map(split2);
 }

 /*
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 3384819..11883e2 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1943,8 +1943,7 @@ new_bitmap:

 out:
 	if (info) {
-		if (info->bitmap)
-			kfree(info->bitmap);
+		kfree(info->bitmap);
 		kmem_cache_free(btrfs_free_space_cachep, info);
 	}

@@ -3322,8 +3321,8 @@ again:

 	if (info)
 		kmem_cache_free(btrfs_free_space_cachep, info);
-	if (map)
-		kfree(map);
+
+	kfree(map);
 	return 0;
 }

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d23362f..7301b99 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -857,8 +857,7 @@ static u64 get_extent_allocation_hint(struct inode *inode,
u64 start,
 			em = search_extent_mapping(em_tree, 0, 0);
 			if (em && em->block_start < EXTENT_MAP_LAST_BYTE)
 				alloc_hint = em->block_start;
-			if (em)
-				free_extent_map(em);
+			free_extent_map(em);
 		} else {
 			alloc_hint = em->block_start;
 			free_extent_map(em);
@@ -6573,8 +6572,7 @@ out:

 	trace_btrfs_get_extent(root, em);

-	if (path)
-		btrfs_free_path(path);
+	btrfs_free_path(path);
 	if (trans) {
 		ret = btrfs_end_transaction(trans, root);
 		if (!err)
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index b63ae20..ec8eb49 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -731,8 +731,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info
*fs_info,
 	else if (eb)
 		__readahead_hook(fs_info->extent_root, eb, eb->start, ret);

-	if (eb)
-		free_extent_buffer(eb);
+	free_extent_buffer(eb);

 	return 1;

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 74257d6..f87a5ee 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4158,8 +4158,7 @@ out:
 	btrfs_end_transaction(trans, root);
 	btrfs_btree_balance_dirty(root);
 	if (err) {
-		if (inode)
-			iput(inode);
+		iput(inode);
 		inode = ERR_PTR(err);
 	}
 	return inode;
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index 9626252..7fb123f 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -162,8 +162,7 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
 {
 	if (!root)
 		return;
-	if (root->node)
-		free_extent_buffer(root->node);
+	free_extent_buffer(root->node);
 	if (root->fs_info)
 		btrfs_free_dummy_fs_info(root->fs_info);
 	kfree(root);
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index a63719c..c74f106 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -118,8 +118,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
 		ret = -EAGAIN;
 	}
 out:
-	if (path)
-		btrfs_free_path(path);
+	btrfs_free_path(path);
 	if (ret == -EAGAIN) {
 		if (root->defrag_max.objectid > root->defrag_progress.objectid)
 			goto done;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1475979..70926a9 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -736,8 +736,7 @@ static noinline int replay_one_extent(struct
btrfs_trans_handle *trans,
 	inode_add_bytes(inode, nbytes);
 	ret = btrfs_update_inode(trans, root, inode);
 out:
-	if (inode)
-		iput(inode);
+	iput(inode);
 	return ret;
 }

@@ -2210,8 +2209,7 @@ static noinline int walk_down_log_tree(struct
btrfs_trans_handle *trans,
 		}

 		WARN_ON(*level <= 0);
-		if (path->nodes[*level-1])
-			free_extent_buffer(path->nodes[*level-1]);
+		free_extent_buffer(path->nodes[*level-1]);
 		path->nodes[*level-1] = next;
 		*level = btrfs_header_level(next);
 		path->slots[*level] = 0;
-- 
2.1.3

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

* Re: [Cocci] [PATCH 1/1] btrfs: Deletion of unnecessary checks before six function calls
  2014-10-31 21:52                                   ` SF Markus Elfring
  (?)
@ 2014-10-31 21:59                                     ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-10-31 21:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Chris Mason, Josef Bacik, linux-btrfs, trivial, kernel-janitors,
	linux-kernel, Coccinelle



On Fri, 31 Oct 2014, SF Markus Elfring wrote:

> The following functions test whether their argument is NULL and then
> return immediately.
> * btrfs_free_path()
> * free_extent_buffer()
> * free_extent_map()
> * free_extent_state()
> * iput()
> * kfree()
> 
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/btrfs/dev-replace.c       |  3 +--
>  fs/btrfs/extent_io.c         | 12 ++++--------
>  fs/btrfs/file.c              |  6 ++----
>  fs/btrfs/free-space-cache.c  |  7 +++----
>  fs/btrfs/inode.c             |  6 ++----
>  fs/btrfs/reada.c             |  3 +--
>  fs/btrfs/relocation.c        |  3 +--
>  fs/btrfs/tests/btrfs-tests.c |  3 +--
>  fs/btrfs/tree-defrag.c       |  3 +--
>  fs/btrfs/tree-log.c          |  6 ++----
>  10 files changed, 18 insertions(+), 34 deletions(-)
> 
> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
> index 6f662b3..3465029 100644
> --- a/fs/btrfs/dev-replace.c
> +++ b/fs/btrfs/dev-replace.c
> @@ -183,8 +183,7 @@ no_valid_dev_replace_entry_found:
>  	}
> 
>  out:
> -	if (path)
> -		btrfs_free_path(path);
> +	btrfs_free_path(path);

It appears to be statically apparent whether btrfs_free_path is needed or 
not.  The code could be changed both not to have the test and not to have 
the jump and call to btrfs_free_path.

This is probably the case for the other occurrences next to labels.

julia

>  	return ret;
>  }
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index bf3f424..cfbf00a 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -704,8 +704,7 @@ next:
> 
>  out:
>  	spin_unlock(&tree->lock);
> -	if (prealloc)
> -		free_extent_state(prealloc);
> +	free_extent_state(prealloc);
> 
>  	return 0;
> 
> @@ -1006,8 +1005,7 @@ hit_next:
> 
>  out:
>  	spin_unlock(&tree->lock);
> -	if (prealloc)
> -		free_extent_state(prealloc);
> +	free_extent_state(prealloc);
> 
>  	return err;
> 
> @@ -1223,8 +1221,7 @@ hit_next:
> 
>  out:
>  	spin_unlock(&tree->lock);
> -	if (prealloc)
> -		free_extent_state(prealloc);
> +	free_extent_state(prealloc);
> 
>  	return err;
> 
> @@ -4146,8 +4143,7 @@ int extent_readpages(struct extent_io_tree *tree,
>  		__extent_readpages(tree, pagepool, nr, get_extent, &em_cached,
>  				   &bio, 0, &bio_flags, READ);
> 
> -	if (em_cached)
> -		free_extent_map(em_cached);
> +	free_extent_map(em_cached);
> 
>  	BUG_ON(!list_empty(pages));
>  	if (bio)
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index a18ceab..add07ce8 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -677,10 +677,8 @@ next:
>  		/* once for the tree*/
>  		free_extent_map(em);
>  	}
> -	if (split)
> -		free_extent_map(split);
> -	if (split2)
> -		free_extent_map(split2);
> +	free_extent_map(split);
> +	free_extent_map(split2);
>  }
> 
>  /*
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 3384819..11883e2 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -1943,8 +1943,7 @@ new_bitmap:
> 
>  out:
>  	if (info) {
> -		if (info->bitmap)
> -			kfree(info->bitmap);
> +		kfree(info->bitmap);
>  		kmem_cache_free(btrfs_free_space_cachep, info);
>  	}
> 
> @@ -3322,8 +3321,8 @@ again:
> 
>  	if (info)
>  		kmem_cache_free(btrfs_free_space_cachep, info);
> -	if (map)
> -		kfree(map);
> +
> +	kfree(map);
>  	return 0;
>  }
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index d23362f..7301b99 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -857,8 +857,7 @@ static u64 get_extent_allocation_hint(struct inode *inode,
> u64 start,
>  			em = search_extent_mapping(em_tree, 0, 0);
>  			if (em && em->block_start < EXTENT_MAP_LAST_BYTE)
>  				alloc_hint = em->block_start;
> -			if (em)
> -				free_extent_map(em);
> +			free_extent_map(em);
>  		} else {
>  			alloc_hint = em->block_start;
>  			free_extent_map(em);
> @@ -6573,8 +6572,7 @@ out:
> 
>  	trace_btrfs_get_extent(root, em);
> 
> -	if (path)
> -		btrfs_free_path(path);
> +	btrfs_free_path(path);
>  	if (trans) {
>  		ret = btrfs_end_transaction(trans, root);
>  		if (!err)
> diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
> index b63ae20..ec8eb49 100644
> --- a/fs/btrfs/reada.c
> +++ b/fs/btrfs/reada.c
> @@ -731,8 +731,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info
> *fs_info,
>  	else if (eb)
>  		__readahead_hook(fs_info->extent_root, eb, eb->start, ret);
> 
> -	if (eb)
> -		free_extent_buffer(eb);
> +	free_extent_buffer(eb);
> 
>  	return 1;
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 74257d6..f87a5ee 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -4158,8 +4158,7 @@ out:
>  	btrfs_end_transaction(trans, root);
>  	btrfs_btree_balance_dirty(root);
>  	if (err) {
> -		if (inode)
> -			iput(inode);
> +		iput(inode);
>  		inode = ERR_PTR(err);
>  	}
>  	return inode;
> diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
> index 9626252..7fb123f 100644
> --- a/fs/btrfs/tests/btrfs-tests.c
> +++ b/fs/btrfs/tests/btrfs-tests.c
> @@ -162,8 +162,7 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
>  {
>  	if (!root)
>  		return;
> -	if (root->node)
> -		free_extent_buffer(root->node);
> +	free_extent_buffer(root->node);
>  	if (root->fs_info)
>  		btrfs_free_dummy_fs_info(root->fs_info);
>  	kfree(root);
> diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
> index a63719c..c74f106 100644
> --- a/fs/btrfs/tree-defrag.c
> +++ b/fs/btrfs/tree-defrag.c
> @@ -118,8 +118,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
>  		ret = -EAGAIN;
>  	}
>  out:
> -	if (path)
> -		btrfs_free_path(path);
> +	btrfs_free_path(path);
>  	if (ret == -EAGAIN) {
>  		if (root->defrag_max.objectid > root->defrag_progress.objectid)
>  			goto done;
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 1475979..70926a9 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -736,8 +736,7 @@ static noinline int replay_one_extent(struct
> btrfs_trans_handle *trans,
>  	inode_add_bytes(inode, nbytes);
>  	ret = btrfs_update_inode(trans, root, inode);
>  out:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
>  	return ret;
>  }
> 
> @@ -2210,8 +2209,7 @@ static noinline int walk_down_log_tree(struct
> btrfs_trans_handle *trans,
>  		}
> 
>  		WARN_ON(*level <= 0);
> -		if (path->nodes[*level-1])
> -			free_extent_buffer(path->nodes[*level-1]);
> +		free_extent_buffer(path->nodes[*level-1]);
>  		path->nodes[*level-1] = next;
>  		*level = btrfs_header_level(next);
>  		path->slots[*level] = 0;
> -- 
> 2.1.3
> 
> 
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
> 

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

* Re: [Cocci] [PATCH 1/1] btrfs: Deletion of unnecessary checks before six function calls
@ 2014-10-31 21:59                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-10-31 21:59 UTC (permalink / raw)
  To: cocci



On Fri, 31 Oct 2014, SF Markus Elfring wrote:

> The following functions test whether their argument is NULL and then
> return immediately.
> * btrfs_free_path()
> * free_extent_buffer()
> * free_extent_map()
> * free_extent_state()
> * iput()
> * kfree()
> 
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/btrfs/dev-replace.c       |  3 +--
>  fs/btrfs/extent_io.c         | 12 ++++--------
>  fs/btrfs/file.c              |  6 ++----
>  fs/btrfs/free-space-cache.c  |  7 +++----
>  fs/btrfs/inode.c             |  6 ++----
>  fs/btrfs/reada.c             |  3 +--
>  fs/btrfs/relocation.c        |  3 +--
>  fs/btrfs/tests/btrfs-tests.c |  3 +--
>  fs/btrfs/tree-defrag.c       |  3 +--
>  fs/btrfs/tree-log.c          |  6 ++----
>  10 files changed, 18 insertions(+), 34 deletions(-)
> 
> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
> index 6f662b3..3465029 100644
> --- a/fs/btrfs/dev-replace.c
> +++ b/fs/btrfs/dev-replace.c
> @@ -183,8 +183,7 @@ no_valid_dev_replace_entry_found:
>  	}
> 
>  out:
> -	if (path)
> -		btrfs_free_path(path);
> +	btrfs_free_path(path);

It appears to be statically apparent whether btrfs_free_path is needed or 
not.  The code could be changed both not to have the test and not to have 
the jump and call to btrfs_free_path.

This is probably the case for the other occurrences next to labels.

julia

>  	return ret;
>  }
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index bf3f424..cfbf00a 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -704,8 +704,7 @@ next:
> 
>  out:
>  	spin_unlock(&tree->lock);
> -	if (prealloc)
> -		free_extent_state(prealloc);
> +	free_extent_state(prealloc);
> 
>  	return 0;
> 
> @@ -1006,8 +1005,7 @@ hit_next:
> 
>  out:
>  	spin_unlock(&tree->lock);
> -	if (prealloc)
> -		free_extent_state(prealloc);
> +	free_extent_state(prealloc);
> 
>  	return err;
> 
> @@ -1223,8 +1221,7 @@ hit_next:
> 
>  out:
>  	spin_unlock(&tree->lock);
> -	if (prealloc)
> -		free_extent_state(prealloc);
> +	free_extent_state(prealloc);
> 
>  	return err;
> 
> @@ -4146,8 +4143,7 @@ int extent_readpages(struct extent_io_tree *tree,
>  		__extent_readpages(tree, pagepool, nr, get_extent, &em_cached,
>  				   &bio, 0, &bio_flags, READ);
> 
> -	if (em_cached)
> -		free_extent_map(em_cached);
> +	free_extent_map(em_cached);
> 
>  	BUG_ON(!list_empty(pages));
>  	if (bio)
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index a18ceab..add07ce8 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -677,10 +677,8 @@ next:
>  		/* once for the tree*/
>  		free_extent_map(em);
>  	}
> -	if (split)
> -		free_extent_map(split);
> -	if (split2)
> -		free_extent_map(split2);
> +	free_extent_map(split);
> +	free_extent_map(split2);
>  }
> 
>  /*
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 3384819..11883e2 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -1943,8 +1943,7 @@ new_bitmap:
> 
>  out:
>  	if (info) {
> -		if (info->bitmap)
> -			kfree(info->bitmap);
> +		kfree(info->bitmap);
>  		kmem_cache_free(btrfs_free_space_cachep, info);
>  	}
> 
> @@ -3322,8 +3321,8 @@ again:
> 
>  	if (info)
>  		kmem_cache_free(btrfs_free_space_cachep, info);
> -	if (map)
> -		kfree(map);
> +
> +	kfree(map);
>  	return 0;
>  }
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index d23362f..7301b99 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -857,8 +857,7 @@ static u64 get_extent_allocation_hint(struct inode *inode,
> u64 start,
>  			em = search_extent_mapping(em_tree, 0, 0);
>  			if (em && em->block_start < EXTENT_MAP_LAST_BYTE)
>  				alloc_hint = em->block_start;
> -			if (em)
> -				free_extent_map(em);
> +			free_extent_map(em);
>  		} else {
>  			alloc_hint = em->block_start;
>  			free_extent_map(em);
> @@ -6573,8 +6572,7 @@ out:
> 
>  	trace_btrfs_get_extent(root, em);
> 
> -	if (path)
> -		btrfs_free_path(path);
> +	btrfs_free_path(path);
>  	if (trans) {
>  		ret = btrfs_end_transaction(trans, root);
>  		if (!err)
> diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
> index b63ae20..ec8eb49 100644
> --- a/fs/btrfs/reada.c
> +++ b/fs/btrfs/reada.c
> @@ -731,8 +731,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info
> *fs_info,
>  	else if (eb)
>  		__readahead_hook(fs_info->extent_root, eb, eb->start, ret);
> 
> -	if (eb)
> -		free_extent_buffer(eb);
> +	free_extent_buffer(eb);
> 
>  	return 1;
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 74257d6..f87a5ee 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -4158,8 +4158,7 @@ out:
>  	btrfs_end_transaction(trans, root);
>  	btrfs_btree_balance_dirty(root);
>  	if (err) {
> -		if (inode)
> -			iput(inode);
> +		iput(inode);
>  		inode = ERR_PTR(err);
>  	}
>  	return inode;
> diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
> index 9626252..7fb123f 100644
> --- a/fs/btrfs/tests/btrfs-tests.c
> +++ b/fs/btrfs/tests/btrfs-tests.c
> @@ -162,8 +162,7 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
>  {
>  	if (!root)
>  		return;
> -	if (root->node)
> -		free_extent_buffer(root->node);
> +	free_extent_buffer(root->node);
>  	if (root->fs_info)
>  		btrfs_free_dummy_fs_info(root->fs_info);
>  	kfree(root);
> diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
> index a63719c..c74f106 100644
> --- a/fs/btrfs/tree-defrag.c
> +++ b/fs/btrfs/tree-defrag.c
> @@ -118,8 +118,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
>  		ret = -EAGAIN;
>  	}
>  out:
> -	if (path)
> -		btrfs_free_path(path);
> +	btrfs_free_path(path);
>  	if (ret = -EAGAIN) {
>  		if (root->defrag_max.objectid > root->defrag_progress.objectid)
>  			goto done;
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 1475979..70926a9 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -736,8 +736,7 @@ static noinline int replay_one_extent(struct
> btrfs_trans_handle *trans,
>  	inode_add_bytes(inode, nbytes);
>  	ret = btrfs_update_inode(trans, root, inode);
>  out:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
>  	return ret;
>  }
> 
> @@ -2210,8 +2209,7 @@ static noinline int walk_down_log_tree(struct
> btrfs_trans_handle *trans,
>  		}
> 
>  		WARN_ON(*level <= 0);
> -		if (path->nodes[*level-1])
> -			free_extent_buffer(path->nodes[*level-1]);
> +		free_extent_buffer(path->nodes[*level-1]);
>  		path->nodes[*level-1] = next;
>  		*level = btrfs_header_level(next);
>  		path->slots[*level] = 0;
> -- 
> 2.1.3
> 
> 
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
> 

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

* [Cocci] [PATCH 1/1] btrfs: Deletion of unnecessary checks before six function calls
@ 2014-10-31 21:59                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-10-31 21:59 UTC (permalink / raw)
  To: cocci



On Fri, 31 Oct 2014, SF Markus Elfring wrote:

> The following functions test whether their argument is NULL and then
> return immediately.
> * btrfs_free_path()
> * free_extent_buffer()
> * free_extent_map()
> * free_extent_state()
> * iput()
> * kfree()
> 
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/btrfs/dev-replace.c       |  3 +--
>  fs/btrfs/extent_io.c         | 12 ++++--------
>  fs/btrfs/file.c              |  6 ++----
>  fs/btrfs/free-space-cache.c  |  7 +++----
>  fs/btrfs/inode.c             |  6 ++----
>  fs/btrfs/reada.c             |  3 +--
>  fs/btrfs/relocation.c        |  3 +--
>  fs/btrfs/tests/btrfs-tests.c |  3 +--
>  fs/btrfs/tree-defrag.c       |  3 +--
>  fs/btrfs/tree-log.c          |  6 ++----
>  10 files changed, 18 insertions(+), 34 deletions(-)
> 
> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
> index 6f662b3..3465029 100644
> --- a/fs/btrfs/dev-replace.c
> +++ b/fs/btrfs/dev-replace.c
> @@ -183,8 +183,7 @@ no_valid_dev_replace_entry_found:
>  	}
> 
>  out:
> -	if (path)
> -		btrfs_free_path(path);
> +	btrfs_free_path(path);

It appears to be statically apparent whether btrfs_free_path is needed or 
not.  The code could be changed both not to have the test and not to have 
the jump and call to btrfs_free_path.

This is probably the case for the other occurrences next to labels.

julia

>  	return ret;
>  }
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index bf3f424..cfbf00a 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -704,8 +704,7 @@ next:
> 
>  out:
>  	spin_unlock(&tree->lock);
> -	if (prealloc)
> -		free_extent_state(prealloc);
> +	free_extent_state(prealloc);
> 
>  	return 0;
> 
> @@ -1006,8 +1005,7 @@ hit_next:
> 
>  out:
>  	spin_unlock(&tree->lock);
> -	if (prealloc)
> -		free_extent_state(prealloc);
> +	free_extent_state(prealloc);
> 
>  	return err;
> 
> @@ -1223,8 +1221,7 @@ hit_next:
> 
>  out:
>  	spin_unlock(&tree->lock);
> -	if (prealloc)
> -		free_extent_state(prealloc);
> +	free_extent_state(prealloc);
> 
>  	return err;
> 
> @@ -4146,8 +4143,7 @@ int extent_readpages(struct extent_io_tree *tree,
>  		__extent_readpages(tree, pagepool, nr, get_extent, &em_cached,
>  				   &bio, 0, &bio_flags, READ);
> 
> -	if (em_cached)
> -		free_extent_map(em_cached);
> +	free_extent_map(em_cached);
> 
>  	BUG_ON(!list_empty(pages));
>  	if (bio)
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index a18ceab..add07ce8 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -677,10 +677,8 @@ next:
>  		/* once for the tree*/
>  		free_extent_map(em);
>  	}
> -	if (split)
> -		free_extent_map(split);
> -	if (split2)
> -		free_extent_map(split2);
> +	free_extent_map(split);
> +	free_extent_map(split2);
>  }
> 
>  /*
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 3384819..11883e2 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -1943,8 +1943,7 @@ new_bitmap:
> 
>  out:
>  	if (info) {
> -		if (info->bitmap)
> -			kfree(info->bitmap);
> +		kfree(info->bitmap);
>  		kmem_cache_free(btrfs_free_space_cachep, info);
>  	}
> 
> @@ -3322,8 +3321,8 @@ again:
> 
>  	if (info)
>  		kmem_cache_free(btrfs_free_space_cachep, info);
> -	if (map)
> -		kfree(map);
> +
> +	kfree(map);
>  	return 0;
>  }
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index d23362f..7301b99 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -857,8 +857,7 @@ static u64 get_extent_allocation_hint(struct inode *inode,
> u64 start,
>  			em = search_extent_mapping(em_tree, 0, 0);
>  			if (em && em->block_start < EXTENT_MAP_LAST_BYTE)
>  				alloc_hint = em->block_start;
> -			if (em)
> -				free_extent_map(em);
> +			free_extent_map(em);
>  		} else {
>  			alloc_hint = em->block_start;
>  			free_extent_map(em);
> @@ -6573,8 +6572,7 @@ out:
> 
>  	trace_btrfs_get_extent(root, em);
> 
> -	if (path)
> -		btrfs_free_path(path);
> +	btrfs_free_path(path);
>  	if (trans) {
>  		ret = btrfs_end_transaction(trans, root);
>  		if (!err)
> diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
> index b63ae20..ec8eb49 100644
> --- a/fs/btrfs/reada.c
> +++ b/fs/btrfs/reada.c
> @@ -731,8 +731,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info
> *fs_info,
>  	else if (eb)
>  		__readahead_hook(fs_info->extent_root, eb, eb->start, ret);
> 
> -	if (eb)
> -		free_extent_buffer(eb);
> +	free_extent_buffer(eb);
> 
>  	return 1;
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 74257d6..f87a5ee 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -4158,8 +4158,7 @@ out:
>  	btrfs_end_transaction(trans, root);
>  	btrfs_btree_balance_dirty(root);
>  	if (err) {
> -		if (inode)
> -			iput(inode);
> +		iput(inode);
>  		inode = ERR_PTR(err);
>  	}
>  	return inode;
> diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
> index 9626252..7fb123f 100644
> --- a/fs/btrfs/tests/btrfs-tests.c
> +++ b/fs/btrfs/tests/btrfs-tests.c
> @@ -162,8 +162,7 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
>  {
>  	if (!root)
>  		return;
> -	if (root->node)
> -		free_extent_buffer(root->node);
> +	free_extent_buffer(root->node);
>  	if (root->fs_info)
>  		btrfs_free_dummy_fs_info(root->fs_info);
>  	kfree(root);
> diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
> index a63719c..c74f106 100644
> --- a/fs/btrfs/tree-defrag.c
> +++ b/fs/btrfs/tree-defrag.c
> @@ -118,8 +118,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
>  		ret = -EAGAIN;
>  	}
>  out:
> -	if (path)
> -		btrfs_free_path(path);
> +	btrfs_free_path(path);
>  	if (ret == -EAGAIN) {
>  		if (root->defrag_max.objectid > root->defrag_progress.objectid)
>  			goto done;
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 1475979..70926a9 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -736,8 +736,7 @@ static noinline int replay_one_extent(struct
> btrfs_trans_handle *trans,
>  	inode_add_bytes(inode, nbytes);
>  	ret = btrfs_update_inode(trans, root, inode);
>  out:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
>  	return ret;
>  }
> 
> @@ -2210,8 +2209,7 @@ static noinline int walk_down_log_tree(struct
> btrfs_trans_handle *trans,
>  		}
> 
>  		WARN_ON(*level <= 0);
> -		if (path->nodes[*level-1])
> -			free_extent_buffer(path->nodes[*level-1]);
> +		free_extent_buffer(path->nodes[*level-1]);
>  		path->nodes[*level-1] = next;
>  		*level = btrfs_header_level(next);
>  		path->slots[*level] = 0;
> -- 
> 2.1.3
> 
> 
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
> 

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

* [PATCH 1/1] ocfs2: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-02  9:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02  9:40 UTC (permalink / raw)
  To: Mark Fasheh, Joel Becker, ocfs2-devel
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The functions iput() and ocfs2_free_path() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ocfs2/alloc.c      | 15 +++++----------
 fs/ocfs2/ioctl.c      |  3 +--
 fs/ocfs2/journal.c    |  9 +++------
 fs/ocfs2/localalloc.c |  9 +++------
 fs/ocfs2/namei.c      |  3 +--
 fs/ocfs2/slot_map.c   |  3 +--
 fs/ocfs2/super.c      |  3 +--
 7 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index a93bf98..2e0ab63 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
 					   subtree_index);
 	}
 out:
-	if (right_path)
-		ocfs2_free_path(right_path);
+	ocfs2_free_path(right_path);
 	return ret;
 }

@@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
 						   right_path, subtree_index);
 	}
 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
+	ocfs2_free_path(left_path);
 	return ret;
 }

@@ -4431,10 +4429,8 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 	}

 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
-	if (right_path)
-		ocfs2_free_path(right_path);
+	ocfs2_free_path(left_path);
+	ocfs2_free_path(right_path);

 	return ret;
 }
@@ -6157,8 +6153,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
 	}

 bail:
-	if (tl_inode)
-		iput(tl_inode);
+	iput(tl_inode);
 	brelse(tl_bh);

 	if (status < 0 && (*tl_copy)) {
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 53e6c40..28afb56 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -606,8 +606,7 @@ bail:
 	if (gb_inode)
 		mutex_unlock(&gb_inode->i_mutex);

-	if (gb_inode)
-		iput(gb_inode);
+	iput(gb_inode);

 	brelse(bh);

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 4b0c688..f94be68 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1009,8 +1009,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)

 //	up_write(&journal->j_trans_barrier);
 done:
-	if (inode)
-		iput(inode);
+	iput(inode);
 }

 static void ocfs2_clear_journal_error(struct super_block *sb,
@@ -1646,8 +1645,7 @@ done:
 	if (got_lock)
 		ocfs2_inode_unlock(inode, 1);

-	if (inode)
-		iput(inode);
+	iput(inode);

 	brelse(bh);

@@ -1755,8 +1753,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,

 	ocfs2_inode_unlock(inode, 1);
 bail:
-	if (inode)
-		iput(inode);
+	iput(inode);

 	return status;
 }
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 0440134..7eca277 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -358,8 +358,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 bail:
 	if (status < 0)
 		brelse(alloc_bh);
-	if (inode)
-		iput(inode);
+	iput(inode);

 	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);

@@ -473,8 +472,7 @@ out_mutex:
 	iput(main_bm_inode);

 out:
-	if (local_alloc_inode)
-		iput(local_alloc_inode);
+	iput(local_alloc_inode);

 	kfree(alloc_copy);
 }
@@ -1328,8 +1326,7 @@ bail:

 	brelse(main_bm_bh);

-	if (main_bm_inode)
-		iput(main_bm_inode);
+	iput(main_bm_inode);

 	kfree(alloc_copy);

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8add6f1..a02593d 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1607,8 +1607,7 @@ bail:
 	if (new_inode)
 		sync_mapping_buffers(old_inode->i_mapping);

-	if (new_inode)
-		iput(new_inode);
+	iput(new_inode);

 	ocfs2_free_dir_lookup_result(&target_lookup_res);
 	ocfs2_free_dir_lookup_result(&old_entry_lookup);
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index a88b2a4..c5c6eb0 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -322,8 +322,7 @@ static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
 	if (si == NULL)
 		return;

-	if (si->si_inode)
-		iput(si->si_inode);
+	iput(si->si_inode);
 	if (si->si_bh) {
 		for (i = 0; i < si->si_blocks; i++) {
 			if (si->si_bh[i]) {
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 4142546..5860f0f 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1723,8 +1723,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct
kstatfs *buf)
 	ocfs2_inode_unlock(inode, 0);
 	status = 0;
 bail:
-	if (inode)
-		iput(inode);
+	iput(inode);

 	if (status)
 		mlog_errno(status);
-- 
2.1.3



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

* [PATCH 1/1] ocfs2: Deletion of unnecessary checks before two function calls
@ 2014-11-02  9:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02  9:40 UTC (permalink / raw)
  To: cocci

The functions iput() and ocfs2_free_path() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ocfs2/alloc.c      | 15 +++++----------
 fs/ocfs2/ioctl.c      |  3 +--
 fs/ocfs2/journal.c    |  9 +++------
 fs/ocfs2/localalloc.c |  9 +++------
 fs/ocfs2/namei.c      |  3 +--
 fs/ocfs2/slot_map.c   |  3 +--
 fs/ocfs2/super.c      |  3 +--
 7 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index a93bf98..2e0ab63 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
 					   subtree_index);
 	}
 out:
-	if (right_path)
-		ocfs2_free_path(right_path);
+	ocfs2_free_path(right_path);
 	return ret;
 }

@@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
 						   right_path, subtree_index);
 	}
 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
+	ocfs2_free_path(left_path);
 	return ret;
 }

@@ -4431,10 +4429,8 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 	}

 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
-	if (right_path)
-		ocfs2_free_path(right_path);
+	ocfs2_free_path(left_path);
+	ocfs2_free_path(right_path);

 	return ret;
 }
@@ -6157,8 +6153,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
 	}

 bail:
-	if (tl_inode)
-		iput(tl_inode);
+	iput(tl_inode);
 	brelse(tl_bh);

 	if (status < 0 && (*tl_copy)) {
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 53e6c40..28afb56 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -606,8 +606,7 @@ bail:
 	if (gb_inode)
 		mutex_unlock(&gb_inode->i_mutex);

-	if (gb_inode)
-		iput(gb_inode);
+	iput(gb_inode);

 	brelse(bh);

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 4b0c688..f94be68 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1009,8 +1009,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)

 //	up_write(&journal->j_trans_barrier);
 done:
-	if (inode)
-		iput(inode);
+	iput(inode);
 }

 static void ocfs2_clear_journal_error(struct super_block *sb,
@@ -1646,8 +1645,7 @@ done:
 	if (got_lock)
 		ocfs2_inode_unlock(inode, 1);

-	if (inode)
-		iput(inode);
+	iput(inode);

 	brelse(bh);

@@ -1755,8 +1753,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,

 	ocfs2_inode_unlock(inode, 1);
 bail:
-	if (inode)
-		iput(inode);
+	iput(inode);

 	return status;
 }
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 0440134..7eca277 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -358,8 +358,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 bail:
 	if (status < 0)
 		brelse(alloc_bh);
-	if (inode)
-		iput(inode);
+	iput(inode);

 	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);

@@ -473,8 +472,7 @@ out_mutex:
 	iput(main_bm_inode);

 out:
-	if (local_alloc_inode)
-		iput(local_alloc_inode);
+	iput(local_alloc_inode);

 	kfree(alloc_copy);
 }
@@ -1328,8 +1326,7 @@ bail:

 	brelse(main_bm_bh);

-	if (main_bm_inode)
-		iput(main_bm_inode);
+	iput(main_bm_inode);

 	kfree(alloc_copy);

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8add6f1..a02593d 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1607,8 +1607,7 @@ bail:
 	if (new_inode)
 		sync_mapping_buffers(old_inode->i_mapping);

-	if (new_inode)
-		iput(new_inode);
+	iput(new_inode);

 	ocfs2_free_dir_lookup_result(&target_lookup_res);
 	ocfs2_free_dir_lookup_result(&old_entry_lookup);
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index a88b2a4..c5c6eb0 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -322,8 +322,7 @@ static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
 	if (si = NULL)
 		return;

-	if (si->si_inode)
-		iput(si->si_inode);
+	iput(si->si_inode);
 	if (si->si_bh) {
 		for (i = 0; i < si->si_blocks; i++) {
 			if (si->si_bh[i]) {
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 4142546..5860f0f 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1723,8 +1723,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct
kstatfs *buf)
 	ocfs2_inode_unlock(inode, 0);
 	status = 0;
 bail:
-	if (inode)
-		iput(inode);
+	iput(inode);

 	if (status)
 		mlog_errno(status);
-- 
2.1.3



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

* [Ocfs2-devel] [PATCH 1/1] ocfs2: Deletion of unnecessary checks before two function calls
@ 2014-11-02  9:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02  9:40 UTC (permalink / raw)
  To: cocci

The functions iput() and ocfs2_free_path() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ocfs2/alloc.c      | 15 +++++----------
 fs/ocfs2/ioctl.c      |  3 +--
 fs/ocfs2/journal.c    |  9 +++------
 fs/ocfs2/localalloc.c |  9 +++------
 fs/ocfs2/namei.c      |  3 +--
 fs/ocfs2/slot_map.c   |  3 +--
 fs/ocfs2/super.c      |  3 +--
 7 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index a93bf98..2e0ab63 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
 					   subtree_index);
 	}
 out:
-	if (right_path)
-		ocfs2_free_path(right_path);
+	ocfs2_free_path(right_path);
 	return ret;
 }

@@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
 						   right_path, subtree_index);
 	}
 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
+	ocfs2_free_path(left_path);
 	return ret;
 }

@@ -4431,10 +4429,8 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 	}

 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
-	if (right_path)
-		ocfs2_free_path(right_path);
+	ocfs2_free_path(left_path);
+	ocfs2_free_path(right_path);

 	return ret;
 }
@@ -6157,8 +6153,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
 	}

 bail:
-	if (tl_inode)
-		iput(tl_inode);
+	iput(tl_inode);
 	brelse(tl_bh);

 	if (status < 0 && (*tl_copy)) {
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 53e6c40..28afb56 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -606,8 +606,7 @@ bail:
 	if (gb_inode)
 		mutex_unlock(&gb_inode->i_mutex);

-	if (gb_inode)
-		iput(gb_inode);
+	iput(gb_inode);

 	brelse(bh);

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 4b0c688..f94be68 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1009,8 +1009,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)

 //	up_write(&journal->j_trans_barrier);
 done:
-	if (inode)
-		iput(inode);
+	iput(inode);
 }

 static void ocfs2_clear_journal_error(struct super_block *sb,
@@ -1646,8 +1645,7 @@ done:
 	if (got_lock)
 		ocfs2_inode_unlock(inode, 1);

-	if (inode)
-		iput(inode);
+	iput(inode);

 	brelse(bh);

@@ -1755,8 +1753,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,

 	ocfs2_inode_unlock(inode, 1);
 bail:
-	if (inode)
-		iput(inode);
+	iput(inode);

 	return status;
 }
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 0440134..7eca277 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -358,8 +358,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 bail:
 	if (status < 0)
 		brelse(alloc_bh);
-	if (inode)
-		iput(inode);
+	iput(inode);

 	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);

@@ -473,8 +472,7 @@ out_mutex:
 	iput(main_bm_inode);

 out:
-	if (local_alloc_inode)
-		iput(local_alloc_inode);
+	iput(local_alloc_inode);

 	kfree(alloc_copy);
 }
@@ -1328,8 +1326,7 @@ bail:

 	brelse(main_bm_bh);

-	if (main_bm_inode)
-		iput(main_bm_inode);
+	iput(main_bm_inode);

 	kfree(alloc_copy);

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8add6f1..a02593d 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1607,8 +1607,7 @@ bail:
 	if (new_inode)
 		sync_mapping_buffers(old_inode->i_mapping);

-	if (new_inode)
-		iput(new_inode);
+	iput(new_inode);

 	ocfs2_free_dir_lookup_result(&target_lookup_res);
 	ocfs2_free_dir_lookup_result(&old_entry_lookup);
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index a88b2a4..c5c6eb0 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -322,8 +322,7 @@ static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
 	if (si == NULL)
 		return;

-	if (si->si_inode)
-		iput(si->si_inode);
+	iput(si->si_inode);
 	if (si->si_bh) {
 		for (i = 0; i < si->si_blocks; i++) {
 			if (si->si_bh[i]) {
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 4142546..5860f0f 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1723,8 +1723,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct
kstatfs *buf)
 	ocfs2_inode_unlock(inode, 0);
 	status = 0;
 bail:
-	if (inode)
-		iput(inode);
+	iput(inode);

 	if (status)
 		mlog_errno(status);
-- 
2.1.3

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

* [Cocci] [PATCH 1/1] ocfs2: Deletion of unnecessary checks before two function calls
@ 2014-11-02  9:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02  9:40 UTC (permalink / raw)
  To: cocci

The functions iput() and ocfs2_free_path() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ocfs2/alloc.c      | 15 +++++----------
 fs/ocfs2/ioctl.c      |  3 +--
 fs/ocfs2/journal.c    |  9 +++------
 fs/ocfs2/localalloc.c |  9 +++------
 fs/ocfs2/namei.c      |  3 +--
 fs/ocfs2/slot_map.c   |  3 +--
 fs/ocfs2/super.c      |  3 +--
 7 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index a93bf98..2e0ab63 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
 					   subtree_index);
 	}
 out:
-	if (right_path)
-		ocfs2_free_path(right_path);
+	ocfs2_free_path(right_path);
 	return ret;
 }

@@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
 						   right_path, subtree_index);
 	}
 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
+	ocfs2_free_path(left_path);
 	return ret;
 }

@@ -4431,10 +4429,8 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
 	}

 out:
-	if (left_path)
-		ocfs2_free_path(left_path);
-	if (right_path)
-		ocfs2_free_path(right_path);
+	ocfs2_free_path(left_path);
+	ocfs2_free_path(right_path);

 	return ret;
 }
@@ -6157,8 +6153,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
 	}

 bail:
-	if (tl_inode)
-		iput(tl_inode);
+	iput(tl_inode);
 	brelse(tl_bh);

 	if (status < 0 && (*tl_copy)) {
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 53e6c40..28afb56 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -606,8 +606,7 @@ bail:
 	if (gb_inode)
 		mutex_unlock(&gb_inode->i_mutex);

-	if (gb_inode)
-		iput(gb_inode);
+	iput(gb_inode);

 	brelse(bh);

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 4b0c688..f94be68 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1009,8 +1009,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)

 //	up_write(&journal->j_trans_barrier);
 done:
-	if (inode)
-		iput(inode);
+	iput(inode);
 }

 static void ocfs2_clear_journal_error(struct super_block *sb,
@@ -1646,8 +1645,7 @@ done:
 	if (got_lock)
 		ocfs2_inode_unlock(inode, 1);

-	if (inode)
-		iput(inode);
+	iput(inode);

 	brelse(bh);

@@ -1755,8 +1753,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,

 	ocfs2_inode_unlock(inode, 1);
 bail:
-	if (inode)
-		iput(inode);
+	iput(inode);

 	return status;
 }
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 0440134..7eca277 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -358,8 +358,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 bail:
 	if (status < 0)
 		brelse(alloc_bh);
-	if (inode)
-		iput(inode);
+	iput(inode);

 	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);

@@ -473,8 +472,7 @@ out_mutex:
 	iput(main_bm_inode);

 out:
-	if (local_alloc_inode)
-		iput(local_alloc_inode);
+	iput(local_alloc_inode);

 	kfree(alloc_copy);
 }
@@ -1328,8 +1326,7 @@ bail:

 	brelse(main_bm_bh);

-	if (main_bm_inode)
-		iput(main_bm_inode);
+	iput(main_bm_inode);

 	kfree(alloc_copy);

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8add6f1..a02593d 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1607,8 +1607,7 @@ bail:
 	if (new_inode)
 		sync_mapping_buffers(old_inode->i_mapping);

-	if (new_inode)
-		iput(new_inode);
+	iput(new_inode);

 	ocfs2_free_dir_lookup_result(&target_lookup_res);
 	ocfs2_free_dir_lookup_result(&old_entry_lookup);
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index a88b2a4..c5c6eb0 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -322,8 +322,7 @@ static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
 	if (si == NULL)
 		return;

-	if (si->si_inode)
-		iput(si->si_inode);
+	iput(si->si_inode);
 	if (si->si_bh) {
 		for (i = 0; i < si->si_blocks; i++) {
 			if (si->si_bh[i]) {
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 4142546..5860f0f 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1723,8 +1723,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct
kstatfs *buf)
 	ocfs2_inode_unlock(inode, 0);
 	status = 0;
 bail:
-	if (inode)
-		iput(inode);
+	iput(inode);

 	if (status)
 		mlog_errno(status);
-- 
2.1.3

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

* Re: [PATCH 1/1] ocfs2: Deletion of unnecessary checks before two function calls
  2014-11-02  9:40                                   ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-02 10:51                                     ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-02 10:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Mark Fasheh, Joel Becker, ocfs2-devel, linux-kernel,
	kernel-janitors, trivial, Coccinelle

On Sun, 2 Nov 2014, SF Markus Elfring wrote:

> The functions iput() and ocfs2_free_path() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.

Please check whether more labels could be added to avoid executing 
unnecessary code.

julia


> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ocfs2/alloc.c      | 15 +++++----------
>  fs/ocfs2/ioctl.c      |  3 +--
>  fs/ocfs2/journal.c    |  9 +++------
>  fs/ocfs2/localalloc.c |  9 +++------
>  fs/ocfs2/namei.c      |  3 +--
>  fs/ocfs2/slot_map.c   |  3 +--
>  fs/ocfs2/super.c      |  3 +--
>  7 files changed, 15 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index a93bf98..2e0ab63 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
>  					   subtree_index);
>  	}
>  out:
> -	if (right_path)
> -		ocfs2_free_path(right_path);
> +	ocfs2_free_path(right_path);
>  	return ret;
>  }
> 
> @@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
>  						   right_path, subtree_index);
>  	}
>  out:
> -	if (left_path)
> -		ocfs2_free_path(left_path);
> +	ocfs2_free_path(left_path);
>  	return ret;
>  }
> 
> @@ -4431,10 +4429,8 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
>  	}
> 
>  out:
> -	if (left_path)
> -		ocfs2_free_path(left_path);
> -	if (right_path)
> -		ocfs2_free_path(right_path);
> +	ocfs2_free_path(left_path);
> +	ocfs2_free_path(right_path);
> 
>  	return ret;
>  }
> @@ -6157,8 +6153,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
>  	}
> 
>  bail:
> -	if (tl_inode)
> -		iput(tl_inode);
> +	iput(tl_inode);
>  	brelse(tl_bh);
> 
>  	if (status < 0 && (*tl_copy)) {
> diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
> index 53e6c40..28afb56 100644
> --- a/fs/ocfs2/ioctl.c
> +++ b/fs/ocfs2/ioctl.c
> @@ -606,8 +606,7 @@ bail:
>  	if (gb_inode)
>  		mutex_unlock(&gb_inode->i_mutex);
> 
> -	if (gb_inode)
> -		iput(gb_inode);
> +	iput(gb_inode);
> 
>  	brelse(bh);
> 
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index 4b0c688..f94be68 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -1009,8 +1009,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
> 
>  //	up_write(&journal->j_trans_barrier);
>  done:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
>  }
> 
>  static void ocfs2_clear_journal_error(struct super_block *sb,
> @@ -1646,8 +1645,7 @@ done:
>  	if (got_lock)
>  		ocfs2_inode_unlock(inode, 1);
> 
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	brelse(bh);
> 
> @@ -1755,8 +1753,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
> 
>  	ocfs2_inode_unlock(inode, 1);
>  bail:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	return status;
>  }
> diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
> index 0440134..7eca277 100644
> --- a/fs/ocfs2/localalloc.c
> +++ b/fs/ocfs2/localalloc.c
> @@ -358,8 +358,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
>  bail:
>  	if (status < 0)
>  		brelse(alloc_bh);
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);
> 
> @@ -473,8 +472,7 @@ out_mutex:
>  	iput(main_bm_inode);
> 
>  out:
> -	if (local_alloc_inode)
> -		iput(local_alloc_inode);
> +	iput(local_alloc_inode);
> 
>  	kfree(alloc_copy);
>  }
> @@ -1328,8 +1326,7 @@ bail:
> 
>  	brelse(main_bm_bh);
> 
> -	if (main_bm_inode)
> -		iput(main_bm_inode);
> +	iput(main_bm_inode);
> 
>  	kfree(alloc_copy);
> 
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 8add6f1..a02593d 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -1607,8 +1607,7 @@ bail:
>  	if (new_inode)
>  		sync_mapping_buffers(old_inode->i_mapping);
> 
> -	if (new_inode)
> -		iput(new_inode);
> +	iput(new_inode);
> 
>  	ocfs2_free_dir_lookup_result(&target_lookup_res);
>  	ocfs2_free_dir_lookup_result(&old_entry_lookup);
> diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
> index a88b2a4..c5c6eb0 100644
> --- a/fs/ocfs2/slot_map.c
> +++ b/fs/ocfs2/slot_map.c
> @@ -322,8 +322,7 @@ static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
>  	if (si == NULL)
>  		return;
> 
> -	if (si->si_inode)
> -		iput(si->si_inode);
> +	iput(si->si_inode);
>  	if (si->si_bh) {
>  		for (i = 0; i < si->si_blocks; i++) {
>  			if (si->si_bh[i]) {
> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
> index 4142546..5860f0f 100644
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
> @@ -1723,8 +1723,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct
> kstatfs *buf)
>  	ocfs2_inode_unlock(inode, 0);
>  	status = 0;
>  bail:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	if (status)
>  		mlog_errno(status);
> -- 
> 2.1.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 1/1] ocfs2: Deletion of unnecessary checks before two function calls
@ 2014-11-02 10:51                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-02 10:51 UTC (permalink / raw)
  To: cocci

On Sun, 2 Nov 2014, SF Markus Elfring wrote:

> The functions iput() and ocfs2_free_path() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.

Please check whether more labels could be added to avoid executing 
unnecessary code.

julia


> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ocfs2/alloc.c      | 15 +++++----------
>  fs/ocfs2/ioctl.c      |  3 +--
>  fs/ocfs2/journal.c    |  9 +++------
>  fs/ocfs2/localalloc.c |  9 +++------
>  fs/ocfs2/namei.c      |  3 +--
>  fs/ocfs2/slot_map.c   |  3 +--
>  fs/ocfs2/super.c      |  3 +--
>  7 files changed, 15 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index a93bf98..2e0ab63 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
>  					   subtree_index);
>  	}
>  out:
> -	if (right_path)
> -		ocfs2_free_path(right_path);
> +	ocfs2_free_path(right_path);
>  	return ret;
>  }
> 
> @@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
>  						   right_path, subtree_index);
>  	}
>  out:
> -	if (left_path)
> -		ocfs2_free_path(left_path);
> +	ocfs2_free_path(left_path);
>  	return ret;
>  }
> 
> @@ -4431,10 +4429,8 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
>  	}
> 
>  out:
> -	if (left_path)
> -		ocfs2_free_path(left_path);
> -	if (right_path)
> -		ocfs2_free_path(right_path);
> +	ocfs2_free_path(left_path);
> +	ocfs2_free_path(right_path);
> 
>  	return ret;
>  }
> @@ -6157,8 +6153,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
>  	}
> 
>  bail:
> -	if (tl_inode)
> -		iput(tl_inode);
> +	iput(tl_inode);
>  	brelse(tl_bh);
> 
>  	if (status < 0 && (*tl_copy)) {
> diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
> index 53e6c40..28afb56 100644
> --- a/fs/ocfs2/ioctl.c
> +++ b/fs/ocfs2/ioctl.c
> @@ -606,8 +606,7 @@ bail:
>  	if (gb_inode)
>  		mutex_unlock(&gb_inode->i_mutex);
> 
> -	if (gb_inode)
> -		iput(gb_inode);
> +	iput(gb_inode);
> 
>  	brelse(bh);
> 
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index 4b0c688..f94be68 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -1009,8 +1009,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
> 
>  //	up_write(&journal->j_trans_barrier);
>  done:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
>  }
> 
>  static void ocfs2_clear_journal_error(struct super_block *sb,
> @@ -1646,8 +1645,7 @@ done:
>  	if (got_lock)
>  		ocfs2_inode_unlock(inode, 1);
> 
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	brelse(bh);
> 
> @@ -1755,8 +1753,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
> 
>  	ocfs2_inode_unlock(inode, 1);
>  bail:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	return status;
>  }
> diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
> index 0440134..7eca277 100644
> --- a/fs/ocfs2/localalloc.c
> +++ b/fs/ocfs2/localalloc.c
> @@ -358,8 +358,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
>  bail:
>  	if (status < 0)
>  		brelse(alloc_bh);
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);
> 
> @@ -473,8 +472,7 @@ out_mutex:
>  	iput(main_bm_inode);
> 
>  out:
> -	if (local_alloc_inode)
> -		iput(local_alloc_inode);
> +	iput(local_alloc_inode);
> 
>  	kfree(alloc_copy);
>  }
> @@ -1328,8 +1326,7 @@ bail:
> 
>  	brelse(main_bm_bh);
> 
> -	if (main_bm_inode)
> -		iput(main_bm_inode);
> +	iput(main_bm_inode);
> 
>  	kfree(alloc_copy);
> 
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 8add6f1..a02593d 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -1607,8 +1607,7 @@ bail:
>  	if (new_inode)
>  		sync_mapping_buffers(old_inode->i_mapping);
> 
> -	if (new_inode)
> -		iput(new_inode);
> +	iput(new_inode);
> 
>  	ocfs2_free_dir_lookup_result(&target_lookup_res);
>  	ocfs2_free_dir_lookup_result(&old_entry_lookup);
> diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
> index a88b2a4..c5c6eb0 100644
> --- a/fs/ocfs2/slot_map.c
> +++ b/fs/ocfs2/slot_map.c
> @@ -322,8 +322,7 @@ static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
>  	if (si = NULL)
>  		return;
> 
> -	if (si->si_inode)
> -		iput(si->si_inode);
> +	iput(si->si_inode);
>  	if (si->si_bh) {
>  		for (i = 0; i < si->si_blocks; i++) {
>  			if (si->si_bh[i]) {
> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
> index 4142546..5860f0f 100644
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
> @@ -1723,8 +1723,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct
> kstatfs *buf)
>  	ocfs2_inode_unlock(inode, 0);
>  	status = 0;
>  bail:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	if (status)
>  		mlog_errno(status);
> -- 
> 2.1.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* [Ocfs2-devel] [PATCH 1/1] ocfs2: Deletion of unnecessary checks before two function calls
@ 2014-11-02 10:51                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-02 10:51 UTC (permalink / raw)
  To: cocci

On Sun, 2 Nov 2014, SF Markus Elfring wrote:

> The functions iput() and ocfs2_free_path() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.

Please check whether more labels could be added to avoid executing 
unnecessary code.

julia


> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ocfs2/alloc.c      | 15 +++++----------
>  fs/ocfs2/ioctl.c      |  3 +--
>  fs/ocfs2/journal.c    |  9 +++------
>  fs/ocfs2/localalloc.c |  9 +++------
>  fs/ocfs2/namei.c      |  3 +--
>  fs/ocfs2/slot_map.c   |  3 +--
>  fs/ocfs2/super.c      |  3 +--
>  7 files changed, 15 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index a93bf98..2e0ab63 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
>  					   subtree_index);
>  	}
>  out:
> -	if (right_path)
> -		ocfs2_free_path(right_path);
> +	ocfs2_free_path(right_path);
>  	return ret;
>  }
> 
> @@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
>  						   right_path, subtree_index);
>  	}
>  out:
> -	if (left_path)
> -		ocfs2_free_path(left_path);
> +	ocfs2_free_path(left_path);
>  	return ret;
>  }
> 
> @@ -4431,10 +4429,8 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
>  	}
> 
>  out:
> -	if (left_path)
> -		ocfs2_free_path(left_path);
> -	if (right_path)
> -		ocfs2_free_path(right_path);
> +	ocfs2_free_path(left_path);
> +	ocfs2_free_path(right_path);
> 
>  	return ret;
>  }
> @@ -6157,8 +6153,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
>  	}
> 
>  bail:
> -	if (tl_inode)
> -		iput(tl_inode);
> +	iput(tl_inode);
>  	brelse(tl_bh);
> 
>  	if (status < 0 && (*tl_copy)) {
> diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
> index 53e6c40..28afb56 100644
> --- a/fs/ocfs2/ioctl.c
> +++ b/fs/ocfs2/ioctl.c
> @@ -606,8 +606,7 @@ bail:
>  	if (gb_inode)
>  		mutex_unlock(&gb_inode->i_mutex);
> 
> -	if (gb_inode)
> -		iput(gb_inode);
> +	iput(gb_inode);
> 
>  	brelse(bh);
> 
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index 4b0c688..f94be68 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -1009,8 +1009,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
> 
>  //	up_write(&journal->j_trans_barrier);
>  done:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
>  }
> 
>  static void ocfs2_clear_journal_error(struct super_block *sb,
> @@ -1646,8 +1645,7 @@ done:
>  	if (got_lock)
>  		ocfs2_inode_unlock(inode, 1);
> 
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	brelse(bh);
> 
> @@ -1755,8 +1753,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
> 
>  	ocfs2_inode_unlock(inode, 1);
>  bail:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	return status;
>  }
> diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
> index 0440134..7eca277 100644
> --- a/fs/ocfs2/localalloc.c
> +++ b/fs/ocfs2/localalloc.c
> @@ -358,8 +358,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
>  bail:
>  	if (status < 0)
>  		brelse(alloc_bh);
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);
> 
> @@ -473,8 +472,7 @@ out_mutex:
>  	iput(main_bm_inode);
> 
>  out:
> -	if (local_alloc_inode)
> -		iput(local_alloc_inode);
> +	iput(local_alloc_inode);
> 
>  	kfree(alloc_copy);
>  }
> @@ -1328,8 +1326,7 @@ bail:
> 
>  	brelse(main_bm_bh);
> 
> -	if (main_bm_inode)
> -		iput(main_bm_inode);
> +	iput(main_bm_inode);
> 
>  	kfree(alloc_copy);
> 
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 8add6f1..a02593d 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -1607,8 +1607,7 @@ bail:
>  	if (new_inode)
>  		sync_mapping_buffers(old_inode->i_mapping);
> 
> -	if (new_inode)
> -		iput(new_inode);
> +	iput(new_inode);
> 
>  	ocfs2_free_dir_lookup_result(&target_lookup_res);
>  	ocfs2_free_dir_lookup_result(&old_entry_lookup);
> diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
> index a88b2a4..c5c6eb0 100644
> --- a/fs/ocfs2/slot_map.c
> +++ b/fs/ocfs2/slot_map.c
> @@ -322,8 +322,7 @@ static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
>  	if (si == NULL)
>  		return;
> 
> -	if (si->si_inode)
> -		iput(si->si_inode);
> +	iput(si->si_inode);
>  	if (si->si_bh) {
>  		for (i = 0; i < si->si_blocks; i++) {
>  			if (si->si_bh[i]) {
> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
> index 4142546..5860f0f 100644
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
> @@ -1723,8 +1723,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct
> kstatfs *buf)
>  	ocfs2_inode_unlock(inode, 0);
>  	status = 0;
>  bail:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	if (status)
>  		mlog_errno(status);
> -- 
> 2.1.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* [Cocci] [PATCH 1/1] ocfs2: Deletion of unnecessary checks before two function calls
@ 2014-11-02 10:51                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-02 10:51 UTC (permalink / raw)
  To: cocci

On Sun, 2 Nov 2014, SF Markus Elfring wrote:

> The functions iput() and ocfs2_free_path() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.

Please check whether more labels could be added to avoid executing 
unnecessary code.

julia


> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ocfs2/alloc.c      | 15 +++++----------
>  fs/ocfs2/ioctl.c      |  3 +--
>  fs/ocfs2/journal.c    |  9 +++------
>  fs/ocfs2/localalloc.c |  9 +++------
>  fs/ocfs2/namei.c      |  3 +--
>  fs/ocfs2/slot_map.c   |  3 +--
>  fs/ocfs2/super.c      |  3 +--
>  7 files changed, 15 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index a93bf98..2e0ab63 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -3453,8 +3453,7 @@ static int ocfs2_merge_rec_right(struct ocfs2_path *left_path,
>  					   subtree_index);
>  	}
>  out:
> -	if (right_path)
> -		ocfs2_free_path(right_path);
> +	ocfs2_free_path(right_path);
>  	return ret;
>  }
> 
> @@ -3647,8 +3646,7 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
>  						   right_path, subtree_index);
>  	}
>  out:
> -	if (left_path)
> -		ocfs2_free_path(left_path);
> +	ocfs2_free_path(left_path);
>  	return ret;
>  }
> 
> @@ -4431,10 +4429,8 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
>  	}
> 
>  out:
> -	if (left_path)
> -		ocfs2_free_path(left_path);
> -	if (right_path)
> -		ocfs2_free_path(right_path);
> +	ocfs2_free_path(left_path);
> +	ocfs2_free_path(right_path);
> 
>  	return ret;
>  }
> @@ -6157,8 +6153,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
>  	}
> 
>  bail:
> -	if (tl_inode)
> -		iput(tl_inode);
> +	iput(tl_inode);
>  	brelse(tl_bh);
> 
>  	if (status < 0 && (*tl_copy)) {
> diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
> index 53e6c40..28afb56 100644
> --- a/fs/ocfs2/ioctl.c
> +++ b/fs/ocfs2/ioctl.c
> @@ -606,8 +606,7 @@ bail:
>  	if (gb_inode)
>  		mutex_unlock(&gb_inode->i_mutex);
> 
> -	if (gb_inode)
> -		iput(gb_inode);
> +	iput(gb_inode);
> 
>  	brelse(bh);
> 
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index 4b0c688..f94be68 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -1009,8 +1009,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
> 
>  //	up_write(&journal->j_trans_barrier);
>  done:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
>  }
> 
>  static void ocfs2_clear_journal_error(struct super_block *sb,
> @@ -1646,8 +1645,7 @@ done:
>  	if (got_lock)
>  		ocfs2_inode_unlock(inode, 1);
> 
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	brelse(bh);
> 
> @@ -1755,8 +1753,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
> 
>  	ocfs2_inode_unlock(inode, 1);
>  bail:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	return status;
>  }
> diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
> index 0440134..7eca277 100644
> --- a/fs/ocfs2/localalloc.c
> +++ b/fs/ocfs2/localalloc.c
> @@ -358,8 +358,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
>  bail:
>  	if (status < 0)
>  		brelse(alloc_bh);
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	trace_ocfs2_load_local_alloc(osb->local_alloc_bits);
> 
> @@ -473,8 +472,7 @@ out_mutex:
>  	iput(main_bm_inode);
> 
>  out:
> -	if (local_alloc_inode)
> -		iput(local_alloc_inode);
> +	iput(local_alloc_inode);
> 
>  	kfree(alloc_copy);
>  }
> @@ -1328,8 +1326,7 @@ bail:
> 
>  	brelse(main_bm_bh);
> 
> -	if (main_bm_inode)
> -		iput(main_bm_inode);
> +	iput(main_bm_inode);
> 
>  	kfree(alloc_copy);
> 
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 8add6f1..a02593d 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -1607,8 +1607,7 @@ bail:
>  	if (new_inode)
>  		sync_mapping_buffers(old_inode->i_mapping);
> 
> -	if (new_inode)
> -		iput(new_inode);
> +	iput(new_inode);
> 
>  	ocfs2_free_dir_lookup_result(&target_lookup_res);
>  	ocfs2_free_dir_lookup_result(&old_entry_lookup);
> diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
> index a88b2a4..c5c6eb0 100644
> --- a/fs/ocfs2/slot_map.c
> +++ b/fs/ocfs2/slot_map.c
> @@ -322,8 +322,7 @@ static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
>  	if (si == NULL)
>  		return;
> 
> -	if (si->si_inode)
> -		iput(si->si_inode);
> +	iput(si->si_inode);
>  	if (si->si_bh) {
>  		for (i = 0; i < si->si_blocks; i++) {
>  			if (si->si_bh[i]) {
> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
> index 4142546..5860f0f 100644
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
> @@ -1723,8 +1723,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct
> kstatfs *buf)
>  	ocfs2_inode_unlock(inode, 0);
>  	status = 0;
>  bail:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);
> 
>  	if (status)
>  		mlog_errno(status);
> -- 
> 2.1.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* [PATCH 1/1] ceph: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-02 14:20                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 14:20 UTC (permalink / raw)
  To: Sage Weil, ceph-devel; +Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The functions ceph_put_snap_context() and iput() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ceph/caps.c       | 3 +--
 fs/ceph/mds_client.c | 6 ++----
 fs/ceph/snap.c       | 9 +++------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 6d1cd45..7d99fc8 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -3136,8 +3136,7 @@ flush_cap_releases:
 done:
 	mutex_unlock(&session->s_mutex);
 done_unlocked:
-	if (inode)
-		iput(inode);
+	iput(inode);
 	return;

 bad:
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index bad07c0..3b0ab05 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -523,8 +523,7 @@ void ceph_mdsc_release_request(struct kref *kref)
 	}
 	if (req->r_locked_dir)
 		ceph_put_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
-	if (req->r_target_inode)
-		iput(req->r_target_inode);
+	iput(req->r_target_inode);
 	if (req->r_dentry)
 		dput(req->r_dentry);
 	if (req->r_old_dentry)
@@ -995,8 +994,7 @@ out:
 	session->s_cap_iterator = NULL;
 	spin_unlock(&session->s_cap_lock);

-	if (last_inode)
-		iput(last_inode);
+	iput(last_inode);
 	if (old_cap)
 		ceph_put_cap(session->s_mdsc, old_cap);

diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index f01645a..c1cc993 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -365,8 +365,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
 	     realm->ino, realm, snapc, snapc->seq,
 	     (unsigned int) snapc->num_snaps);

-	if (realm->cached_context)
-		ceph_put_snap_context(realm->cached_context);
+	ceph_put_snap_context(realm->cached_context);
 	realm->cached_context = snapc;
 	return 0;

@@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
*realm)
 		if (!inode)
 			continue;
 		spin_unlock(&realm->inodes_with_caps_lock);
-		if (lastinode)
-			iput(lastinode);
+		iput(lastinode);
 		lastinode = inode;
 		ceph_queue_cap_snap(ci);
 		spin_lock(&realm->inodes_with_caps_lock);
 	}
 	spin_unlock(&realm->inodes_with_caps_lock);
-	if (lastinode)
-		iput(lastinode);
+	iput(lastinode);

 	list_for_each_entry(child, &realm->children, child_item) {
 		dout("queue_realm_cap_snaps %p %llx queue child %p %llx\n",
-- 
2.1.3



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

* [PATCH 1/1] ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-02 14:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 14:20 UTC (permalink / raw)
  To: Sage Weil, ceph-devel; +Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The functions ceph_put_snap_context() and iput() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ceph/caps.c       | 3 +--
 fs/ceph/mds_client.c | 6 ++----
 fs/ceph/snap.c       | 9 +++------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 6d1cd45..7d99fc8 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -3136,8 +3136,7 @@ flush_cap_releases:
 done:
 	mutex_unlock(&session->s_mutex);
 done_unlocked:
-	if (inode)
-		iput(inode);
+	iput(inode);
 	return;

 bad:
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index bad07c0..3b0ab05 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -523,8 +523,7 @@ void ceph_mdsc_release_request(struct kref *kref)
 	}
 	if (req->r_locked_dir)
 		ceph_put_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
-	if (req->r_target_inode)
-		iput(req->r_target_inode);
+	iput(req->r_target_inode);
 	if (req->r_dentry)
 		dput(req->r_dentry);
 	if (req->r_old_dentry)
@@ -995,8 +994,7 @@ out:
 	session->s_cap_iterator = NULL;
 	spin_unlock(&session->s_cap_lock);

-	if (last_inode)
-		iput(last_inode);
+	iput(last_inode);
 	if (old_cap)
 		ceph_put_cap(session->s_mdsc, old_cap);

diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index f01645a..c1cc993 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -365,8 +365,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
 	     realm->ino, realm, snapc, snapc->seq,
 	     (unsigned int) snapc->num_snaps);

-	if (realm->cached_context)
-		ceph_put_snap_context(realm->cached_context);
+	ceph_put_snap_context(realm->cached_context);
 	realm->cached_context = snapc;
 	return 0;

@@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
*realm)
 		if (!inode)
 			continue;
 		spin_unlock(&realm->inodes_with_caps_lock);
-		if (lastinode)
-			iput(lastinode);
+		iput(lastinode);
 		lastinode = inode;
 		ceph_queue_cap_snap(ci);
 		spin_lock(&realm->inodes_with_caps_lock);
 	}
 	spin_unlock(&realm->inodes_with_caps_lock);
-	if (lastinode)
-		iput(lastinode);
+	iput(lastinode);

 	list_for_each_entry(child, &realm->children, child_item) {
 		dout("queue_realm_cap_snaps %p %llx queue child %p %llx\n",
-- 
2.1.3



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

* [PATCH 1/1] ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-02 14:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 14:20 UTC (permalink / raw)
  To: Sage Weil, ceph-devel; +Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The functions ceph_put_snap_context() and iput() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ceph/caps.c       | 3 +--
 fs/ceph/mds_client.c | 6 ++----
 fs/ceph/snap.c       | 9 +++------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 6d1cd45..7d99fc8 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -3136,8 +3136,7 @@ flush_cap_releases:
 done:
 	mutex_unlock(&session->s_mutex);
 done_unlocked:
-	if (inode)
-		iput(inode);
+	iput(inode);
 	return;

 bad:
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index bad07c0..3b0ab05 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -523,8 +523,7 @@ void ceph_mdsc_release_request(struct kref *kref)
 	}
 	if (req->r_locked_dir)
 		ceph_put_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
-	if (req->r_target_inode)
-		iput(req->r_target_inode);
+	iput(req->r_target_inode);
 	if (req->r_dentry)
 		dput(req->r_dentry);
 	if (req->r_old_dentry)
@@ -995,8 +994,7 @@ out:
 	session->s_cap_iterator = NULL;
 	spin_unlock(&session->s_cap_lock);

-	if (last_inode)
-		iput(last_inode);
+	iput(last_inode);
 	if (old_cap)
 		ceph_put_cap(session->s_mdsc, old_cap);

diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index f01645a..c1cc993 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -365,8 +365,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
 	     realm->ino, realm, snapc, snapc->seq,
 	     (unsigned int) snapc->num_snaps);

-	if (realm->cached_context)
-		ceph_put_snap_context(realm->cached_context);
+	ceph_put_snap_context(realm->cached_context);
 	realm->cached_context = snapc;
 	return 0;

@@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
*realm)
 		if (!inode)
 			continue;
 		spin_unlock(&realm->inodes_with_caps_lock);
-		if (lastinode)
-			iput(lastinode);
+		iput(lastinode);
 		lastinode = inode;
 		ceph_queue_cap_snap(ci);
 		spin_lock(&realm->inodes_with_caps_lock);
 	}
 	spin_unlock(&realm->inodes_with_caps_lock);
-	if (lastinode)
-		iput(lastinode);
+	iput(lastinode);

 	list_for_each_entry(child, &realm->children, child_item) {
 		dout("queue_realm_cap_snaps %p %llx queue child %p %llx\n",
-- 
2.1.3

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

* [Cocci] [PATCH 1/1] ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-02 14:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 14:20 UTC (permalink / raw)
  To: cocci

The functions ceph_put_snap_context() and iput() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ceph/caps.c       | 3 +--
 fs/ceph/mds_client.c | 6 ++----
 fs/ceph/snap.c       | 9 +++------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 6d1cd45..7d99fc8 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -3136,8 +3136,7 @@ flush_cap_releases:
 done:
 	mutex_unlock(&session->s_mutex);
 done_unlocked:
-	if (inode)
-		iput(inode);
+	iput(inode);
 	return;

 bad:
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index bad07c0..3b0ab05 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -523,8 +523,7 @@ void ceph_mdsc_release_request(struct kref *kref)
 	}
 	if (req->r_locked_dir)
 		ceph_put_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
-	if (req->r_target_inode)
-		iput(req->r_target_inode);
+	iput(req->r_target_inode);
 	if (req->r_dentry)
 		dput(req->r_dentry);
 	if (req->r_old_dentry)
@@ -995,8 +994,7 @@ out:
 	session->s_cap_iterator = NULL;
 	spin_unlock(&session->s_cap_lock);

-	if (last_inode)
-		iput(last_inode);
+	iput(last_inode);
 	if (old_cap)
 		ceph_put_cap(session->s_mdsc, old_cap);

diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index f01645a..c1cc993 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -365,8 +365,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
 	     realm->ino, realm, snapc, snapc->seq,
 	     (unsigned int) snapc->num_snaps);

-	if (realm->cached_context)
-		ceph_put_snap_context(realm->cached_context);
+	ceph_put_snap_context(realm->cached_context);
 	realm->cached_context = snapc;
 	return 0;

@@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
*realm)
 		if (!inode)
 			continue;
 		spin_unlock(&realm->inodes_with_caps_lock);
-		if (lastinode)
-			iput(lastinode);
+		iput(lastinode);
 		lastinode = inode;
 		ceph_queue_cap_snap(ci);
 		spin_lock(&realm->inodes_with_caps_lock);
 	}
 	spin_unlock(&realm->inodes_with_caps_lock);
-	if (lastinode)
-		iput(lastinode);
+	iput(lastinode);

 	list_for_each_entry(child, &realm->children, child_item) {
 		dout("queue_realm_cap_snaps %p %llx queue child %p %llx\n",
-- 
2.1.3

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

* [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-02 15:12                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 15:12 UTC (permalink / raw)
  To: Bjorn Helgaas, Boris Ostrovsky, David Vrabel,
	Konrad Rzeszutek Wilk, Len Brown, Rafael J. Wysocki, linux-pci
  Cc: linux-acpi, linux-kernel, xen-devel, kernel-janitors, trivial,
	Coccinelle

The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pci/pci-acpi.c     | 3 +--
 drivers/pci/probe.c        | 3 +--
 drivers/pci/search.c       | 3 +--
 drivers/pci/xen-pcifront.c | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 37263b0..a8fe5de 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
 	pci_wakeup_event(pci_dev);
 	pm_runtime_resume(&pci_dev->dev);

-	if (pci_dev->subordinate)
-		pci_pme_wakeup_bus(pci_dev->subordinate);
+	pci_pme_wakeup_bus(pci_dev->subordinate);
 }

 /**
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4170113..e93f16e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev)
 {
 	struct pci_bus *pci_bus = to_pci_bus(dev);

-	if (pci_bus->bridge)
-		put_device(pci_bus->bridge);
+	put_device(pci_bus->bridge);
 	pci_bus_remove_resources(pci_bus);
 	pci_release_bus_of_node(pci_bus);
 	kfree(pci_bus);
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 827ad83..2d806bd 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct
pci_device_id *id,
 			      match_pci_dev_by_id);
 	if (dev)
 		pdev = to_pci_dev(dev);
-	if (from)
-		pci_dev_put(from);
+	pci_dev_put(from);
 	return pdev;
 }

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 53df39a..46664cc 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
 	pcidev = pci_get_bus_and_slot(bus, devfn);
 	if (!pcidev || !pcidev->driver) {
 		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
-		if (pcidev)
-			pci_dev_put(pcidev);
+		pci_dev_put(pcidev);
 		return result;
 	}
 	pdrv = pcidev->driver;
-- 
2.1.3

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

* [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls
@ 2014-11-02 15:12                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 15:12 UTC (permalink / raw)
  To: Bjorn Helgaas, Boris Ostrovsky, David Vrabel,
	Konrad Rzeszutek Wilk, Len Brown, Rafael J. Wysocki, linux-pci
  Cc: linux-acpi, linux-kernel, xen-devel, kernel-janitors, trivial,
	Coccinelle

The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pci/pci-acpi.c     | 3 +--
 drivers/pci/probe.c        | 3 +--
 drivers/pci/search.c       | 3 +--
 drivers/pci/xen-pcifront.c | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 37263b0..a8fe5de 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
 	pci_wakeup_event(pci_dev);
 	pm_runtime_resume(&pci_dev->dev);

-	if (pci_dev->subordinate)
-		pci_pme_wakeup_bus(pci_dev->subordinate);
+	pci_pme_wakeup_bus(pci_dev->subordinate);
 }

 /**
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4170113..e93f16e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev)
 {
 	struct pci_bus *pci_bus = to_pci_bus(dev);

-	if (pci_bus->bridge)
-		put_device(pci_bus->bridge);
+	put_device(pci_bus->bridge);
 	pci_bus_remove_resources(pci_bus);
 	pci_release_bus_of_node(pci_bus);
 	kfree(pci_bus);
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 827ad83..2d806bd 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct
pci_device_id *id,
 			      match_pci_dev_by_id);
 	if (dev)
 		pdev = to_pci_dev(dev);
-	if (from)
-		pci_dev_put(from);
+	pci_dev_put(from);
 	return pdev;
 }

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 53df39a..46664cc 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
 	pcidev = pci_get_bus_and_slot(bus, devfn);
 	if (!pcidev || !pcidev->driver) {
 		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
-		if (pcidev)
-			pci_dev_put(pcidev);
+		pci_dev_put(pcidev);
 		return result;
 	}
 	pdrv = pcidev->driver;
-- 
2.1.3



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

* [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls
@ 2014-11-02 15:12                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 15:12 UTC (permalink / raw)
  To: cocci

The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pci/pci-acpi.c     | 3 +--
 drivers/pci/probe.c        | 3 +--
 drivers/pci/search.c       | 3 +--
 drivers/pci/xen-pcifront.c | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 37263b0..a8fe5de 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
 	pci_wakeup_event(pci_dev);
 	pm_runtime_resume(&pci_dev->dev);

-	if (pci_dev->subordinate)
-		pci_pme_wakeup_bus(pci_dev->subordinate);
+	pci_pme_wakeup_bus(pci_dev->subordinate);
 }

 /**
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4170113..e93f16e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev)
 {
 	struct pci_bus *pci_bus = to_pci_bus(dev);

-	if (pci_bus->bridge)
-		put_device(pci_bus->bridge);
+	put_device(pci_bus->bridge);
 	pci_bus_remove_resources(pci_bus);
 	pci_release_bus_of_node(pci_bus);
 	kfree(pci_bus);
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 827ad83..2d806bd 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct
pci_device_id *id,
 			      match_pci_dev_by_id);
 	if (dev)
 		pdev = to_pci_dev(dev);
-	if (from)
-		pci_dev_put(from);
+	pci_dev_put(from);
 	return pdev;
 }

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 53df39a..46664cc 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
 	pcidev = pci_get_bus_and_slot(bus, devfn);
 	if (!pcidev || !pcidev->driver) {
 		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
-		if (pcidev)
-			pci_dev_put(pcidev);
+		pci_dev_put(pcidev);
 		return result;
 	}
 	pdrv = pcidev->driver;
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls
@ 2014-11-02 15:12                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 15:12 UTC (permalink / raw)
  To: cocci

The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pci/pci-acpi.c     | 3 +--
 drivers/pci/probe.c        | 3 +--
 drivers/pci/search.c       | 3 +--
 drivers/pci/xen-pcifront.c | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 37263b0..a8fe5de 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
 	pci_wakeup_event(pci_dev);
 	pm_runtime_resume(&pci_dev->dev);

-	if (pci_dev->subordinate)
-		pci_pme_wakeup_bus(pci_dev->subordinate);
+	pci_pme_wakeup_bus(pci_dev->subordinate);
 }

 /**
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4170113..e93f16e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev)
 {
 	struct pci_bus *pci_bus = to_pci_bus(dev);

-	if (pci_bus->bridge)
-		put_device(pci_bus->bridge);
+	put_device(pci_bus->bridge);
 	pci_bus_remove_resources(pci_bus);
 	pci_release_bus_of_node(pci_bus);
 	kfree(pci_bus);
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 827ad83..2d806bd 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct
pci_device_id *id,
 			      match_pci_dev_by_id);
 	if (dev)
 		pdev = to_pci_dev(dev);
-	if (from)
-		pci_dev_put(from);
+	pci_dev_put(from);
 	return pdev;
 }

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 53df39a..46664cc 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
 	pcidev = pci_get_bus_and_slot(bus, devfn);
 	if (!pcidev || !pcidev->driver) {
 		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
-		if (pcidev)
-			pci_dev_put(pcidev);
+		pci_dev_put(pcidev);
 		return result;
 	}
 	pdrv = pcidev->driver;
-- 
2.1.3

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

* [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
                                                   ` (17 preceding siblings ...)
  (?)
@ 2014-11-02 15:12                                 ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 15:12 UTC (permalink / raw)
  To: Bjorn Helgaas, Boris Ostrovsky, David Vrabel,
	Konrad Rzeszutek Wilk, Len Brown, Rafael J. Wysocki, linux-pci
  Cc: trivial, kernel-janitors, linux-kernel, linux-acpi, xen-devel,
	Coccinelle

The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pci/pci-acpi.c     | 3 +--
 drivers/pci/probe.c        | 3 +--
 drivers/pci/search.c       | 3 +--
 drivers/pci/xen-pcifront.c | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 37263b0..a8fe5de 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
 	pci_wakeup_event(pci_dev);
 	pm_runtime_resume(&pci_dev->dev);

-	if (pci_dev->subordinate)
-		pci_pme_wakeup_bus(pci_dev->subordinate);
+	pci_pme_wakeup_bus(pci_dev->subordinate);
 }

 /**
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4170113..e93f16e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev)
 {
 	struct pci_bus *pci_bus = to_pci_bus(dev);

-	if (pci_bus->bridge)
-		put_device(pci_bus->bridge);
+	put_device(pci_bus->bridge);
 	pci_bus_remove_resources(pci_bus);
 	pci_release_bus_of_node(pci_bus);
 	kfree(pci_bus);
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 827ad83..2d806bd 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct
pci_device_id *id,
 			      match_pci_dev_by_id);
 	if (dev)
 		pdev = to_pci_dev(dev);
-	if (from)
-		pci_dev_put(from);
+	pci_dev_put(from);
 	return pdev;
 }

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 53df39a..46664cc 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
 	pcidev = pci_get_bus_and_slot(bus, devfn);
 	if (!pcidev || !pcidev->driver) {
 		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
-		if (pcidev)
-			pci_dev_put(pcidev);
+		pci_dev_put(pcidev);
 		return result;
 	}
 	pdrv = pcidev->driver;
-- 
2.1.3

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

* [PATCH 1/1] PCI: EMU10K1: Deletion of unnecessary checks before three function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-02 18:27                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 18:27 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The functions kfree(), release_firmware() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/emu10k1/emu10k1_main.c | 9 +++------
 sound/pci/emu10k1/emufx.c        | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 2292697..b4458a6 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 	}
 	if (emu->emu1010.firmware_thread)
 		kthread_stop(emu->emu1010.firmware_thread);
-	if (emu->firmware)
-		release_firmware(emu->firmware);
-	if (emu->dock_fw)
-		release_firmware(emu->dock_fw);
+	release_firmware(emu->firmware);
+	release_firmware(emu->dock_fw);
 	if (emu->irq >= 0)
 		free_irq(emu->irq, emu);
 	/* remove reserved page */
@@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 			(struct snd_util_memblk *)emu->reserved_page);
 		emu->reserved_page = NULL;
 	}
-	if (emu->memhdr)
-		snd_util_memhdr_free(emu->memhdr);
+	snd_util_memhdr_free(emu->memhdr);
 	if (emu->silent_page.area)
 		snd_dma_free_pages(&emu->silent_page);
 	if (emu->ptb_pages.area)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 745f062..eb5c0ab 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol
*kctl)
 	kctl->private_value = 0;
 	list_del(&ctl->list);
 	kfree(ctl);
-	if (kctl->tlv.p)
-		kfree(kctl->tlv.p);
+	kfree(kctl->tlv.p);
 }

 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
-- 
2.1.3



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

* [PATCH 1/1] PCI: EMU10K1: Deletion of unnecessary checks before three function calls
@ 2014-11-02 18:27                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 18:27 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The functions kfree(), release_firmware() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/emu10k1/emu10k1_main.c | 9 +++------
 sound/pci/emu10k1/emufx.c        | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 2292697..b4458a6 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 	}
 	if (emu->emu1010.firmware_thread)
 		kthread_stop(emu->emu1010.firmware_thread);
-	if (emu->firmware)
-		release_firmware(emu->firmware);
-	if (emu->dock_fw)
-		release_firmware(emu->dock_fw);
+	release_firmware(emu->firmware);
+	release_firmware(emu->dock_fw);
 	if (emu->irq >= 0)
 		free_irq(emu->irq, emu);
 	/* remove reserved page */
@@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 			(struct snd_util_memblk *)emu->reserved_page);
 		emu->reserved_page = NULL;
 	}
-	if (emu->memhdr)
-		snd_util_memhdr_free(emu->memhdr);
+	snd_util_memhdr_free(emu->memhdr);
 	if (emu->silent_page.area)
 		snd_dma_free_pages(&emu->silent_page);
 	if (emu->ptb_pages.area)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 745f062..eb5c0ab 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol
*kctl)
 	kctl->private_value = 0;
 	list_del(&ctl->list);
 	kfree(ctl);
-	if (kctl->tlv.p)
-		kfree(kctl->tlv.p);
+	kfree(kctl->tlv.p);
 }

 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
-- 
2.1.3



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

* [PATCH 1/1] PCI: EMU10K1: Deletion of unnecessary checks before three function calls
@ 2014-11-02 18:27                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 18:27 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The functions kfree(), release_firmware() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/emu10k1/emu10k1_main.c | 9 +++------
 sound/pci/emu10k1/emufx.c        | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 2292697..b4458a6 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 	}
 	if (emu->emu1010.firmware_thread)
 		kthread_stop(emu->emu1010.firmware_thread);
-	if (emu->firmware)
-		release_firmware(emu->firmware);
-	if (emu->dock_fw)
-		release_firmware(emu->dock_fw);
+	release_firmware(emu->firmware);
+	release_firmware(emu->dock_fw);
 	if (emu->irq >= 0)
 		free_irq(emu->irq, emu);
 	/* remove reserved page */
@@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 			(struct snd_util_memblk *)emu->reserved_page);
 		emu->reserved_page = NULL;
 	}
-	if (emu->memhdr)
-		snd_util_memhdr_free(emu->memhdr);
+	snd_util_memhdr_free(emu->memhdr);
 	if (emu->silent_page.area)
 		snd_dma_free_pages(&emu->silent_page);
 	if (emu->ptb_pages.area)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 745f062..eb5c0ab 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol
*kctl)
 	kctl->private_value = 0;
 	list_del(&ctl->list);
 	kfree(ctl);
-	if (kctl->tlv.p)
-		kfree(kctl->tlv.p);
+	kfree(kctl->tlv.p);
 }

 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
-- 
2.1.3

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

* [Cocci] [PATCH 1/1] PCI: EMU10K1: Deletion of unnecessary checks before three function calls
@ 2014-11-02 18:27                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 18:27 UTC (permalink / raw)
  To: cocci

The functions kfree(), release_firmware() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/emu10k1/emu10k1_main.c | 9 +++------
 sound/pci/emu10k1/emufx.c        | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 2292697..b4458a6 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 	}
 	if (emu->emu1010.firmware_thread)
 		kthread_stop(emu->emu1010.firmware_thread);
-	if (emu->firmware)
-		release_firmware(emu->firmware);
-	if (emu->dock_fw)
-		release_firmware(emu->dock_fw);
+	release_firmware(emu->firmware);
+	release_firmware(emu->dock_fw);
 	if (emu->irq >= 0)
 		free_irq(emu->irq, emu);
 	/* remove reserved page */
@@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 			(struct snd_util_memblk *)emu->reserved_page);
 		emu->reserved_page = NULL;
 	}
-	if (emu->memhdr)
-		snd_util_memhdr_free(emu->memhdr);
+	snd_util_memhdr_free(emu->memhdr);
 	if (emu->silent_page.area)
 		snd_dma_free_pages(&emu->silent_page);
 	if (emu->ptb_pages.area)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 745f062..eb5c0ab 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol
*kctl)
 	kctl->private_value = 0;
 	list_del(&ctl->list);
 	kfree(ctl);
-	if (kctl->tlv.p)
-		kfree(kctl->tlv.p);
+	kfree(kctl->tlv.p);
 }

 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
-- 
2.1.3

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

* [PATCH 1/1] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-02 19:42                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 19:42 UTC (permalink / raw)
  To: Yann E. MORIN, linux-kbuild
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

The sym_calc_value() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/kconfig/confdata.c | 6 ++----
 scripts/kconfig/symbol.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..3073cb6 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -262,8 +262,7 @@ int conf_read_simple(const char *name, int def)
 			goto load;
 		sym_add_change_count(1);
 		if (!sym_defconfig_list) {
-			if (modules_sym)
-				sym_calc_value(modules_sym);
+			sym_calc_value(modules_sym);
 			return 1;
 		}

@@ -399,8 +398,7 @@ setsym:
 	free(line);
 	fclose(in);

-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 	return 0;
 }

diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 7caabdb..3f7797b 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -447,8 +447,7 @@ void sym_clear_all_valid(void)
 	for_all_symbols(i, sym)
 		sym->flags &= ~SYMBOL_VALID;
 	sym_add_change_count(1);
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 }

 void sym_set_changed(struct symbol *sym)
-- 
2.1.3



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

* [PATCH 1/1] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value"
@ 2014-11-02 19:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 19:42 UTC (permalink / raw)
  To: cocci

The sym_calc_value() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/kconfig/confdata.c | 6 ++----
 scripts/kconfig/symbol.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..3073cb6 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -262,8 +262,7 @@ int conf_read_simple(const char *name, int def)
 			goto load;
 		sym_add_change_count(1);
 		if (!sym_defconfig_list) {
-			if (modules_sym)
-				sym_calc_value(modules_sym);
+			sym_calc_value(modules_sym);
 			return 1;
 		}

@@ -399,8 +398,7 @@ setsym:
 	free(line);
 	fclose(in);

-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 	return 0;
 }

diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 7caabdb..3f7797b 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -447,8 +447,7 @@ void sym_clear_all_valid(void)
 	for_all_symbols(i, sym)
 		sym->flags &= ~SYMBOL_VALID;
 	sym_add_change_count(1);
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 }

 void sym_set_changed(struct symbol *sym)
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value"
@ 2014-11-02 19:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-02 19:42 UTC (permalink / raw)
  To: cocci

The sym_calc_value() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/kconfig/confdata.c | 6 ++----
 scripts/kconfig/symbol.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..3073cb6 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -262,8 +262,7 @@ int conf_read_simple(const char *name, int def)
 			goto load;
 		sym_add_change_count(1);
 		if (!sym_defconfig_list) {
-			if (modules_sym)
-				sym_calc_value(modules_sym);
+			sym_calc_value(modules_sym);
 			return 1;
 		}

@@ -399,8 +398,7 @@ setsym:
 	free(line);
 	fclose(in);

-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 	return 0;
 }

diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 7caabdb..3f7797b 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -447,8 +447,7 @@ void sym_clear_all_valid(void)
 	for_all_symbols(i, sym)
 		sym->flags &= ~SYMBOL_VALID;
 	sym_add_change_count(1);
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 }

 void sym_set_changed(struct symbol *sym)
-- 
2.1.3

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

* Re: [PATCH 1/1] PCI: EMU10K1: Deletion of unnecessary checks before three function calls
  2014-11-02 18:27                                   ` SF Markus Elfring
  (?)
@ 2014-11-03  9:45                                     ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-03  9:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

At Sun, 02 Nov 2014 19:27:20 +0100,
SF Markus Elfring wrote:
> 
> The functions kfree(), release_firmware() and snd_util_memhdr_free() test
> whether their argument is NULL and then return immediately. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Your patch can't be applied cleanly due to your MUA breaking the
lines.  Please fix your MUA setup, or use an attachment if it's
impossible, and resend the patch.

Also, try to align the subject line with the relevant commits.  See
"git log sound/pci/emu10k1" 


thanks,

Takashi


> ---
>  sound/pci/emu10k1/emu10k1_main.c | 9 +++------
>  sound/pci/emu10k1/emufx.c        | 3 +--
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
> index 2292697..b4458a6 100644
> --- a/sound/pci/emu10k1/emu10k1_main.c
> +++ b/sound/pci/emu10k1/emu10k1_main.c
> @@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
>  	}
>  	if (emu->emu1010.firmware_thread)
>  		kthread_stop(emu->emu1010.firmware_thread);
> -	if (emu->firmware)
> -		release_firmware(emu->firmware);
> -	if (emu->dock_fw)
> -		release_firmware(emu->dock_fw);
> +	release_firmware(emu->firmware);
> +	release_firmware(emu->dock_fw);
>  	if (emu->irq >= 0)
>  		free_irq(emu->irq, emu);
>  	/* remove reserved page */
> @@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
>  			(struct snd_util_memblk *)emu->reserved_page);
>  		emu->reserved_page = NULL;
>  	}
> -	if (emu->memhdr)
> -		snd_util_memhdr_free(emu->memhdr);
> +	snd_util_memhdr_free(emu->memhdr);
>  	if (emu->silent_page.area)
>  		snd_dma_free_pages(&emu->silent_page);
>  	if (emu->ptb_pages.area)
> diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
> index 745f062..eb5c0ab 100644
> --- a/sound/pci/emu10k1/emufx.c
> +++ b/sound/pci/emu10k1/emufx.c
> @@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol
> *kctl)
>  	kctl->private_value = 0;
>  	list_del(&ctl->list);
>  	kfree(ctl);
> -	if (kctl->tlv.p)
> -		kfree(kctl->tlv.p);
> +	kfree(kctl->tlv.p);
>  }
> 
>  static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] PCI: EMU10K1: Deletion of unnecessary checks before three function calls
@ 2014-11-03  9:45                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-03  9:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

At Sun, 02 Nov 2014 19:27:20 +0100,
SF Markus Elfring wrote:
> 
> The functions kfree(), release_firmware() and snd_util_memhdr_free() test
> whether their argument is NULL and then return immediately. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Your patch can't be applied cleanly due to your MUA breaking the
lines.  Please fix your MUA setup, or use an attachment if it's
impossible, and resend the patch.

Also, try to align the subject line with the relevant commits.  See
"git log sound/pci/emu10k1" 


thanks,

Takashi


> ---
>  sound/pci/emu10k1/emu10k1_main.c | 9 +++------
>  sound/pci/emu10k1/emufx.c        | 3 +--
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
> index 2292697..b4458a6 100644
> --- a/sound/pci/emu10k1/emu10k1_main.c
> +++ b/sound/pci/emu10k1/emu10k1_main.c
> @@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
>  	}
>  	if (emu->emu1010.firmware_thread)
>  		kthread_stop(emu->emu1010.firmware_thread);
> -	if (emu->firmware)
> -		release_firmware(emu->firmware);
> -	if (emu->dock_fw)
> -		release_firmware(emu->dock_fw);
> +	release_firmware(emu->firmware);
> +	release_firmware(emu->dock_fw);
>  	if (emu->irq >= 0)
>  		free_irq(emu->irq, emu);
>  	/* remove reserved page */
> @@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
>  			(struct snd_util_memblk *)emu->reserved_page);
>  		emu->reserved_page = NULL;
>  	}
> -	if (emu->memhdr)
> -		snd_util_memhdr_free(emu->memhdr);
> +	snd_util_memhdr_free(emu->memhdr);
>  	if (emu->silent_page.area)
>  		snd_dma_free_pages(&emu->silent_page);
>  	if (emu->ptb_pages.area)
> diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
> index 745f062..eb5c0ab 100644
> --- a/sound/pci/emu10k1/emufx.c
> +++ b/sound/pci/emu10k1/emufx.c
> @@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol
> *kctl)
>  	kctl->private_value = 0;
>  	list_del(&ctl->list);
>  	kfree(ctl);
> -	if (kctl->tlv.p)
> -		kfree(kctl->tlv.p);
> +	kfree(kctl->tlv.p);
>  }
> 
>  static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
> -- 
> 2.1.3
> 
> 

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

* [Cocci] [PATCH 1/1] PCI: EMU10K1: Deletion of unnecessary checks before three function calls
@ 2014-11-03  9:45                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-03  9:45 UTC (permalink / raw)
  To: cocci

At Sun, 02 Nov 2014 19:27:20 +0100,
SF Markus Elfring wrote:
> 
> The functions kfree(), release_firmware() and snd_util_memhdr_free() test
> whether their argument is NULL and then return immediately. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Your patch can't be applied cleanly due to your MUA breaking the
lines.  Please fix your MUA setup, or use an attachment if it's
impossible, and resend the patch.

Also, try to align the subject line with the relevant commits.  See
"git log sound/pci/emu10k1" 


thanks,

Takashi


> ---
>  sound/pci/emu10k1/emu10k1_main.c | 9 +++------
>  sound/pci/emu10k1/emufx.c        | 3 +--
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
> index 2292697..b4458a6 100644
> --- a/sound/pci/emu10k1/emu10k1_main.c
> +++ b/sound/pci/emu10k1/emu10k1_main.c
> @@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
>  	}
>  	if (emu->emu1010.firmware_thread)
>  		kthread_stop(emu->emu1010.firmware_thread);
> -	if (emu->firmware)
> -		release_firmware(emu->firmware);
> -	if (emu->dock_fw)
> -		release_firmware(emu->dock_fw);
> +	release_firmware(emu->firmware);
> +	release_firmware(emu->dock_fw);
>  	if (emu->irq >= 0)
>  		free_irq(emu->irq, emu);
>  	/* remove reserved page */
> @@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
>  			(struct snd_util_memblk *)emu->reserved_page);
>  		emu->reserved_page = NULL;
>  	}
> -	if (emu->memhdr)
> -		snd_util_memhdr_free(emu->memhdr);
> +	snd_util_memhdr_free(emu->memhdr);
>  	if (emu->silent_page.area)
>  		snd_dma_free_pages(&emu->silent_page);
>  	if (emu->ptb_pages.area)
> diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
> index 745f062..eb5c0ab 100644
> --- a/sound/pci/emu10k1/emufx.c
> +++ b/sound/pci/emu10k1/emufx.c
> @@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol
> *kctl)
>  	kctl->private_value = 0;
>  	list_del(&ctl->list);
>  	kfree(ctl);
> -	if (kctl->tlv.p)
> -		kfree(kctl->tlv.p);
> +	kfree(kctl->tlv.p);
>  }
> 
>  static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls
  2014-10-31 17:40                                   ` SF Markus Elfring
  (?)
@ 2014-11-03  9:50                                     ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03  9:50 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ursula Braun, Martin Schwidefsky, Heiko Carstens, Frank Blaschka,
	linux390, linux-s390, linux-kernel, kernel-janitors, trivial,
	Coccinelle

This one is buggy.

I'm sorry, but please stop sending these.

For kfree(), at least we all know that kfree() accepts NULL pointer.
But for this one:
1) I don't know what the functions do so I have to look at the code.
2) It's in a arch that I don't compile so cscope isn't set up meaning
   it's hard to find the functions.

You're sending a lot of patches and they are all hard to review and some
of them are buggy and none of them really add any value.  It's a waste
of your time and it's a waste of my time.

regards,
dan carpenter

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

* Re: [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03  9:50                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03  9:50 UTC (permalink / raw)
  To: cocci

This one is buggy.

I'm sorry, but please stop sending these.

For kfree(), at least we all know that kfree() accepts NULL pointer.
But for this one:
1) I don't know what the functions do so I have to look at the code.
2) It's in a arch that I don't compile so cscope isn't set up meaning
   it's hard to find the functions.

You're sending a lot of patches and they are all hard to review and some
of them are buggy and none of them really add any value.  It's a waste
of your time and it's a waste of my time.

regards,
dan carpenter

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

* [Cocci] [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03  9:50                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03  9:50 UTC (permalink / raw)
  To: cocci

This one is buggy.

I'm sorry, but please stop sending these.

For kfree(), at least we all know that kfree() accepts NULL pointer.
But for this one:
1) I don't know what the functions do so I have to look at the code.
2) It's in a arch that I don't compile so cscope isn't set up meaning
   it's hard to find the functions.

You're sending a lot of patches and they are all hard to review and some
of them are buggy and none of them really add any value.  It's a waste
of your time and it's a waste of my time.

regards,
dan carpenter

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

* Re: [PATCH 1/1] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value"
  2014-11-02 19:42                                   ` SF Markus Elfring
  (?)
@ 2014-11-03 10:35                                     ` Paul Bolle
  -1 siblings, 0 replies; 3633+ messages in thread
From: Paul Bolle @ 2014-11-03 10:35 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yann E. MORIN, linux-kbuild, linux-kernel, kernel-janitors,
	trivial, Coccinelle

Since you use "SF Markus Elfring", this patch should start with:

From: Markus Elfring <elfring@users.sourceforge.net>

We don't care that you used a sourceforge.net address. Or has SF another
meaning? 

On Sun, 2014-11-02 at 20:42 +0100, SF Markus Elfring wrote:
> The sym_calc_value() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.

Side note: I guess the coccinelle script you use just skips cases like
    if (sym) {
        sym_calc_value(sym);
        do_foo_bar():
    }

Or did you filter those manually?

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  scripts/kconfig/confdata.c | 6 ++----
>  scripts/kconfig/symbol.c   | 3 +--
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index f88d90f..3073cb6 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -262,8 +262,7 @@ int conf_read_simple(const char *name, int def)
>  			goto load;
>  		sym_add_change_count(1);
>  		if (!sym_defconfig_list) {
> -			if (modules_sym)
> -				sym_calc_value(modules_sym);
> +			sym_calc_value(modules_sym);
>  			return 1;
>  		}
> 
> @@ -399,8 +398,7 @@ setsym:
>  	free(line);
>  	fclose(in);
> 
> -	if (modules_sym)
> -		sym_calc_value(modules_sym);
> +	sym_calc_value(modules_sym);
>  	return 0;
>  }
> 
> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index 7caabdb..3f7797b 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
> @@ -447,8 +447,7 @@ void sym_clear_all_valid(void)
>  	for_all_symbols(i, sym)
>  		sym->flags &= ~SYMBOL_VALID;
>  	sym_add_change_count(1);
> -	if (modules_sym)
> -		sym_calc_value(modules_sym);
> +	sym_calc_value(modules_sym);
>  }
> 
>  void sym_set_changed(struct symbol *sym)

Please resend with
    Acked-by: Paul Bolle <pebolle@tiscali.nl>

added.


Paul Bolle


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

* Re: [PATCH 1/1] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value"
@ 2014-11-03 10:35                                     ` Paul Bolle
  0 siblings, 0 replies; 3633+ messages in thread
From: Paul Bolle @ 2014-11-03 10:35 UTC (permalink / raw)
  To: cocci

Since you use "SF Markus Elfring", this patch should start with:

From: Markus Elfring <elfring@users.sourceforge.net>

We don't care that you used a sourceforge.net address. Or has SF another
meaning? 

On Sun, 2014-11-02 at 20:42 +0100, SF Markus Elfring wrote:
> The sym_calc_value() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.

Side note: I guess the coccinelle script you use just skips cases like
    if (sym) {
        sym_calc_value(sym);
        do_foo_bar():
    }

Or did you filter those manually?

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  scripts/kconfig/confdata.c | 6 ++----
>  scripts/kconfig/symbol.c   | 3 +--
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index f88d90f..3073cb6 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -262,8 +262,7 @@ int conf_read_simple(const char *name, int def)
>  			goto load;
>  		sym_add_change_count(1);
>  		if (!sym_defconfig_list) {
> -			if (modules_sym)
> -				sym_calc_value(modules_sym);
> +			sym_calc_value(modules_sym);
>  			return 1;
>  		}
> 
> @@ -399,8 +398,7 @@ setsym:
>  	free(line);
>  	fclose(in);
> 
> -	if (modules_sym)
> -		sym_calc_value(modules_sym);
> +	sym_calc_value(modules_sym);
>  	return 0;
>  }
> 
> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index 7caabdb..3f7797b 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
> @@ -447,8 +447,7 @@ void sym_clear_all_valid(void)
>  	for_all_symbols(i, sym)
>  		sym->flags &= ~SYMBOL_VALID;
>  	sym_add_change_count(1);
> -	if (modules_sym)
> -		sym_calc_value(modules_sym);
> +	sym_calc_value(modules_sym);
>  }
> 
>  void sym_set_changed(struct symbol *sym)

Please resend with
    Acked-by: Paul Bolle <pebolle@tiscali.nl>

added.


Paul Bolle


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

* [Cocci] [PATCH 1/1] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value"
@ 2014-11-03 10:35                                     ` Paul Bolle
  0 siblings, 0 replies; 3633+ messages in thread
From: Paul Bolle @ 2014-11-03 10:35 UTC (permalink / raw)
  To: cocci

Since you use "SF Markus Elfring", this patch should start with:

From: Markus Elfring <elfring@users.sourceforge.net>

We don't care that you used a sourceforge.net address. Or has SF another
meaning? 

On Sun, 2014-11-02 at 20:42 +0100, SF Markus Elfring wrote:
> The sym_calc_value() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.

Side note: I guess the coccinelle script you use just skips cases like
    if (sym) {
        sym_calc_value(sym);
        do_foo_bar():
    }

Or did you filter those manually?

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  scripts/kconfig/confdata.c | 6 ++----
>  scripts/kconfig/symbol.c   | 3 +--
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index f88d90f..3073cb6 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -262,8 +262,7 @@ int conf_read_simple(const char *name, int def)
>  			goto load;
>  		sym_add_change_count(1);
>  		if (!sym_defconfig_list) {
> -			if (modules_sym)
> -				sym_calc_value(modules_sym);
> +			sym_calc_value(modules_sym);
>  			return 1;
>  		}
> 
> @@ -399,8 +398,7 @@ setsym:
>  	free(line);
>  	fclose(in);
> 
> -	if (modules_sym)
> -		sym_calc_value(modules_sym);
> +	sym_calc_value(modules_sym);
>  	return 0;
>  }
> 
> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index 7caabdb..3f7797b 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
> @@ -447,8 +447,7 @@ void sym_clear_all_valid(void)
>  	for_all_symbols(i, sym)
>  		sym->flags &= ~SYMBOL_VALID;
>  	sym_add_change_count(1);
> -	if (modules_sym)
> -		sym_calc_value(modules_sym);
> +	sym_calc_value(modules_sym);
>  }
> 
>  void sym_set_changed(struct symbol *sym)

Please resend with
    Acked-by: Paul Bolle <pebolle@tiscali.nl>

added.


Paul Bolle

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

* Re: [PATCH 1/1] ceph: Deletion of unnecessary checks before two function calls
  2014-11-02 14:20                                   ` SF Markus Elfring
  (?)
@ 2014-11-03 10:35                                     ` Ilya Dryomov
  -1 siblings, 0 replies; 3633+ messages in thread
From: Ilya Dryomov @ 2014-11-03 10:35 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sage Weil, Ceph Development, Linux Kernel Mailing List,
	kernel-janitors, trivial, Coccinelle, Yan, Zheng

On Sun, Nov 2, 2014 at 5:20 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> The functions ceph_put_snap_context() and iput() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ceph/caps.c       | 3 +--
>  fs/ceph/mds_client.c | 6 ++----
>  fs/ceph/snap.c       | 9 +++------
>  3 files changed, 6 insertions(+), 12 deletions(-)

[CC'ed Zheng]

Applied, but see below.

>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index 6d1cd45..7d99fc8 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -3136,8 +3136,7 @@ flush_cap_releases:
>  done:
>         mutex_unlock(&session->s_mutex);
>  done_unlocked:
> -       if (inode)
> -               iput(inode);
> +       iput(inode);
>         return;
>
>  bad:
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index bad07c0..3b0ab05 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -523,8 +523,7 @@ void ceph_mdsc_release_request(struct kref *kref)
>         }
>         if (req->r_locked_dir)
>                 ceph_put_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
> -       if (req->r_target_inode)
> -               iput(req->r_target_inode);
> +       iput(req->r_target_inode);
>         if (req->r_dentry)
>                 dput(req->r_dentry);

dput() also checks for NULL argument, but the check is wrapped into
unlikely(), which is why I presume it wasn't picked up.  It would be
great if you could improve your coccinelle script to handle
{un,}likely() as well.

>         if (req->r_old_dentry)
> @@ -995,8 +994,7 @@ out:
>         session->s_cap_iterator = NULL;
>         spin_unlock(&session->s_cap_lock);
>
> -       if (last_inode)
> -               iput(last_inode);
> +       iput(last_inode);
>         if (old_cap)
>                 ceph_put_cap(session->s_mdsc, old_cap);
>
> diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
> index f01645a..c1cc993 100644
> --- a/fs/ceph/snap.c
> +++ b/fs/ceph/snap.c
> @@ -365,8 +365,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
>              realm->ino, realm, snapc, snapc->seq,
>              (unsigned int) snapc->num_snaps);
>
> -       if (realm->cached_context)
> -               ceph_put_snap_context(realm->cached_context);
> +       ceph_put_snap_context(realm->cached_context);
>         realm->cached_context = snapc;
>         return 0;
>
> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
> *realm)

The patch was corrupted, that should have been a single line.  I fixed
it up but you may want to look into your email client settings.

Thanks,

                Ilya

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

* Re: [PATCH 1/1] ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-03 10:35                                     ` Ilya Dryomov
  0 siblings, 0 replies; 3633+ messages in thread
From: Ilya Dryomov @ 2014-11-03 10:35 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sage Weil, Ceph Development, Linux Kernel Mailing List,
	kernel-janitors, trivial, Coccinelle, Yan, Zheng

On Sun, Nov 2, 2014 at 5:20 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> The functions ceph_put_snap_context() and iput() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ceph/caps.c       | 3 +--
>  fs/ceph/mds_client.c | 6 ++----
>  fs/ceph/snap.c       | 9 +++------
>  3 files changed, 6 insertions(+), 12 deletions(-)

[CC'ed Zheng]

Applied, but see below.

>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index 6d1cd45..7d99fc8 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -3136,8 +3136,7 @@ flush_cap_releases:
>  done:
>         mutex_unlock(&session->s_mutex);
>  done_unlocked:
> -       if (inode)
> -               iput(inode);
> +       iput(inode);
>         return;
>
>  bad:
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index bad07c0..3b0ab05 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -523,8 +523,7 @@ void ceph_mdsc_release_request(struct kref *kref)
>         }
>         if (req->r_locked_dir)
>                 ceph_put_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
> -       if (req->r_target_inode)
> -               iput(req->r_target_inode);
> +       iput(req->r_target_inode);
>         if (req->r_dentry)
>                 dput(req->r_dentry);

dput() also checks for NULL argument, but the check is wrapped into
unlikely(), which is why I presume it wasn't picked up.  It would be
great if you could improve your coccinelle script to handle
{un,}likely() as well.

>         if (req->r_old_dentry)
> @@ -995,8 +994,7 @@ out:
>         session->s_cap_iterator = NULL;
>         spin_unlock(&session->s_cap_lock);
>
> -       if (last_inode)
> -               iput(last_inode);
> +       iput(last_inode);
>         if (old_cap)
>                 ceph_put_cap(session->s_mdsc, old_cap);
>
> diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
> index f01645a..c1cc993 100644
> --- a/fs/ceph/snap.c
> +++ b/fs/ceph/snap.c
> @@ -365,8 +365,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
>              realm->ino, realm, snapc, snapc->seq,
>              (unsigned int) snapc->num_snaps);
>
> -       if (realm->cached_context)
> -               ceph_put_snap_context(realm->cached_context);
> +       ceph_put_snap_context(realm->cached_context);
>         realm->cached_context = snapc;
>         return 0;
>
> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
> *realm)

The patch was corrupted, that should have been a single line.  I fixed
it up but you may want to look into your email client settings.

Thanks,

                Ilya

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

* [Cocci] [PATCH 1/1] ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-03 10:35                                     ` Ilya Dryomov
  0 siblings, 0 replies; 3633+ messages in thread
From: Ilya Dryomov @ 2014-11-03 10:35 UTC (permalink / raw)
  To: cocci

On Sun, Nov 2, 2014 at 5:20 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> The functions ceph_put_snap_context() and iput() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ceph/caps.c       | 3 +--
>  fs/ceph/mds_client.c | 6 ++----
>  fs/ceph/snap.c       | 9 +++------
>  3 files changed, 6 insertions(+), 12 deletions(-)

[CC'ed Zheng]

Applied, but see below.

>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index 6d1cd45..7d99fc8 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -3136,8 +3136,7 @@ flush_cap_releases:
>  done:
>         mutex_unlock(&session->s_mutex);
>  done_unlocked:
> -       if (inode)
> -               iput(inode);
> +       iput(inode);
>         return;
>
>  bad:
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index bad07c0..3b0ab05 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -523,8 +523,7 @@ void ceph_mdsc_release_request(struct kref *kref)
>         }
>         if (req->r_locked_dir)
>                 ceph_put_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
> -       if (req->r_target_inode)
> -               iput(req->r_target_inode);
> +       iput(req->r_target_inode);
>         if (req->r_dentry)
>                 dput(req->r_dentry);

dput() also checks for NULL argument, but the check is wrapped into
unlikely(), which is why I presume it wasn't picked up.  It would be
great if you could improve your coccinelle script to handle
{un,}likely() as well.

>         if (req->r_old_dentry)
> @@ -995,8 +994,7 @@ out:
>         session->s_cap_iterator = NULL;
>         spin_unlock(&session->s_cap_lock);
>
> -       if (last_inode)
> -               iput(last_inode);
> +       iput(last_inode);
>         if (old_cap)
>                 ceph_put_cap(session->s_mdsc, old_cap);
>
> diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
> index f01645a..c1cc993 100644
> --- a/fs/ceph/snap.c
> +++ b/fs/ceph/snap.c
> @@ -365,8 +365,7 @@ static int build_snap_context(struct ceph_snap_realm *realm)
>              realm->ino, realm, snapc, snapc->seq,
>              (unsigned int) snapc->num_snaps);
>
> -       if (realm->cached_context)
> -               ceph_put_snap_context(realm->cached_context);
> +       ceph_put_snap_context(realm->cached_context);
>         realm->cached_context = snapc;
>         return 0;
>
> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
> *realm)

The patch was corrupted, that should have been a single line.  I fixed
it up but you may want to look into your email client settings.

Thanks,

                Ilya

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

* Re: [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls
  2014-10-31 17:40                                   ` SF Markus Elfring
  (?)
@ 2014-11-03 11:04                                     ` Ursula Braun
  -1 siblings, 0 replies; 3633+ messages in thread
From: Ursula Braun @ 2014-11-03 11:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ursula Braun, Martin Schwidefsky, Heiko Carstens, Frank Blaschka,
	linux390, linux-s390, linux-kernel, kernel-janitors, trivial,
	Coccinelle

I agree with your proposed debug_unregister() changes, but not with your
kfree_fsm() change.

Regards, Ursula Braun

On Fri, 2014-10-31 at 18:40 +0100, SF Markus Elfring wrote:
> The functions debug_unregister() and kfree_fsm() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/s390/net/claw.c      |  6 ++----
>  drivers/s390/net/ctcm_main.c |  6 ++----
>  drivers/s390/net/lcs.c       |  6 ++----
>  drivers/s390/net/netiucv.c   | 12 ++++--------
>  4 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
> index 213e54e..d609ca0 100644
> --- a/drivers/s390/net/claw.c
> +++ b/drivers/s390/net/claw.c
> @@ -109,10 +109,8 @@ static debug_info_t *claw_dbf_trace;
>  static void
>  claw_unregister_debug_facility(void)
>  {
> -	if (claw_dbf_setup)
> -		debug_unregister(claw_dbf_setup);
> -	if (claw_dbf_trace)
> -		debug_unregister(claw_dbf_trace);
> +	debug_unregister(claw_dbf_setup);
> +	debug_unregister(claw_dbf_trace);
>  }
> 
>  static int
> diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
> index e056dd4..34dc0f3 100644
> --- a/drivers/s390/net/ctcm_main.c
> +++ b/drivers/s390/net/ctcm_main.c
> @@ -1074,8 +1074,7 @@ static void ctcm_free_netdevice(struct net_device *dev)
>  	if (priv) {
>  		grp = priv->mpcg;
>  		if (grp) {
> -			if (grp->fsm)
> -				kfree_fsm(grp->fsm);
> +			kfree_fsm(grp->fsm);
>  			if (grp->xid_skb)
>  				dev_kfree_skb(grp->xid_skb);
>  			if (grp->rcvd_xid_skb)
> @@ -1672,8 +1671,7 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)
>  		ctcm_free_netdevice(dev);
>  	}
> 
> -	if (priv->fsm)
> -		kfree_fsm(priv->fsm);
> +	kfree_fsm(priv->fsm);
> 
>  	ccw_device_set_offline(cgdev->cdev[1]);
>  	ccw_device_set_offline(cgdev->cdev[0]);
> diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
> index 0a7d87c..5dfa7dd 100644
> --- a/drivers/s390/net/lcs.c
> +++ b/drivers/s390/net/lcs.c
> @@ -88,10 +88,8 @@ static debug_info_t *lcs_dbf_trace;
>  static void
>  lcs_unregister_debug_facility(void)
>  {
> -	if (lcs_dbf_setup)
> -		debug_unregister(lcs_dbf_setup);
> -	if (lcs_dbf_trace)
> -		debug_unregister(lcs_dbf_trace);
> +	debug_unregister(lcs_dbf_setup);
> +	debug_unregister(lcs_dbf_trace);
>  }
> 
>  static int
> diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
> index 0a87809..bdcc3fe 100644
> --- a/drivers/s390/net/netiucv.c
> +++ b/drivers/s390/net/netiucv.c
> @@ -487,12 +487,9 @@ DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);
> 
>  static void iucv_unregister_dbf_views(void)
>  {
> -	if (iucv_dbf_setup)
> -		debug_unregister(iucv_dbf_setup);
> -	if (iucv_dbf_data)
> -		debug_unregister(iucv_dbf_data);
> -	if (iucv_dbf_trace)
> -		debug_unregister(iucv_dbf_trace);
> +	debug_unregister(iucv_dbf_setup);
> +	debug_unregister(iucv_dbf_data);
> +	debug_unregister(iucv_dbf_trace);
>  }
>  static int iucv_register_dbf_views(void)
>  {
> @@ -1975,8 +1972,7 @@ static void netiucv_free_netdevice(struct net_device *dev)
>  	if (privptr) {
>  		if (privptr->conn)
>  			netiucv_remove_connection(privptr->conn);
> -		if (privptr->fsm)
> -			kfree_fsm(privptr->fsm);
> +		kfree_fsm(privptr->fsm);
>  		privptr->conn = NULL; privptr->fsm = NULL;
>  		/* privptr gets freed by free_netdev() */
>  	}



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

* Re: [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 11:04                                     ` Ursula Braun
  0 siblings, 0 replies; 3633+ messages in thread
From: Ursula Braun @ 2014-11-03 11:04 UTC (permalink / raw)
  To: cocci

I agree with your proposed debug_unregister() changes, but not with your
kfree_fsm() change.

Regards, Ursula Braun

On Fri, 2014-10-31 at 18:40 +0100, SF Markus Elfring wrote:
> The functions debug_unregister() and kfree_fsm() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/s390/net/claw.c      |  6 ++----
>  drivers/s390/net/ctcm_main.c |  6 ++----
>  drivers/s390/net/lcs.c       |  6 ++----
>  drivers/s390/net/netiucv.c   | 12 ++++--------
>  4 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
> index 213e54e..d609ca0 100644
> --- a/drivers/s390/net/claw.c
> +++ b/drivers/s390/net/claw.c
> @@ -109,10 +109,8 @@ static debug_info_t *claw_dbf_trace;
>  static void
>  claw_unregister_debug_facility(void)
>  {
> -	if (claw_dbf_setup)
> -		debug_unregister(claw_dbf_setup);
> -	if (claw_dbf_trace)
> -		debug_unregister(claw_dbf_trace);
> +	debug_unregister(claw_dbf_setup);
> +	debug_unregister(claw_dbf_trace);
>  }
> 
>  static int
> diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
> index e056dd4..34dc0f3 100644
> --- a/drivers/s390/net/ctcm_main.c
> +++ b/drivers/s390/net/ctcm_main.c
> @@ -1074,8 +1074,7 @@ static void ctcm_free_netdevice(struct net_device *dev)
>  	if (priv) {
>  		grp = priv->mpcg;
>  		if (grp) {
> -			if (grp->fsm)
> -				kfree_fsm(grp->fsm);
> +			kfree_fsm(grp->fsm);
>  			if (grp->xid_skb)
>  				dev_kfree_skb(grp->xid_skb);
>  			if (grp->rcvd_xid_skb)
> @@ -1672,8 +1671,7 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)
>  		ctcm_free_netdevice(dev);
>  	}
> 
> -	if (priv->fsm)
> -		kfree_fsm(priv->fsm);
> +	kfree_fsm(priv->fsm);
> 
>  	ccw_device_set_offline(cgdev->cdev[1]);
>  	ccw_device_set_offline(cgdev->cdev[0]);
> diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
> index 0a7d87c..5dfa7dd 100644
> --- a/drivers/s390/net/lcs.c
> +++ b/drivers/s390/net/lcs.c
> @@ -88,10 +88,8 @@ static debug_info_t *lcs_dbf_trace;
>  static void
>  lcs_unregister_debug_facility(void)
>  {
> -	if (lcs_dbf_setup)
> -		debug_unregister(lcs_dbf_setup);
> -	if (lcs_dbf_trace)
> -		debug_unregister(lcs_dbf_trace);
> +	debug_unregister(lcs_dbf_setup);
> +	debug_unregister(lcs_dbf_trace);
>  }
> 
>  static int
> diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
> index 0a87809..bdcc3fe 100644
> --- a/drivers/s390/net/netiucv.c
> +++ b/drivers/s390/net/netiucv.c
> @@ -487,12 +487,9 @@ DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);
> 
>  static void iucv_unregister_dbf_views(void)
>  {
> -	if (iucv_dbf_setup)
> -		debug_unregister(iucv_dbf_setup);
> -	if (iucv_dbf_data)
> -		debug_unregister(iucv_dbf_data);
> -	if (iucv_dbf_trace)
> -		debug_unregister(iucv_dbf_trace);
> +	debug_unregister(iucv_dbf_setup);
> +	debug_unregister(iucv_dbf_data);
> +	debug_unregister(iucv_dbf_trace);
>  }
>  static int iucv_register_dbf_views(void)
>  {
> @@ -1975,8 +1972,7 @@ static void netiucv_free_netdevice(struct net_device *dev)
>  	if (privptr) {
>  		if (privptr->conn)
>  			netiucv_remove_connection(privptr->conn);
> -		if (privptr->fsm)
> -			kfree_fsm(privptr->fsm);
> +		kfree_fsm(privptr->fsm);
>  		privptr->conn = NULL; privptr->fsm = NULL;
>  		/* privptr gets freed by free_netdev() */
>  	}



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

* [Cocci] [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 11:04                                     ` Ursula Braun
  0 siblings, 0 replies; 3633+ messages in thread
From: Ursula Braun @ 2014-11-03 11:04 UTC (permalink / raw)
  To: cocci

I agree with your proposed debug_unregister() changes, but not with your
kfree_fsm() change.

Regards, Ursula Braun

On Fri, 2014-10-31 at 18:40 +0100, SF Markus Elfring wrote:
> The functions debug_unregister() and kfree_fsm() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/s390/net/claw.c      |  6 ++----
>  drivers/s390/net/ctcm_main.c |  6 ++----
>  drivers/s390/net/lcs.c       |  6 ++----
>  drivers/s390/net/netiucv.c   | 12 ++++--------
>  4 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
> index 213e54e..d609ca0 100644
> --- a/drivers/s390/net/claw.c
> +++ b/drivers/s390/net/claw.c
> @@ -109,10 +109,8 @@ static debug_info_t *claw_dbf_trace;
>  static void
>  claw_unregister_debug_facility(void)
>  {
> -	if (claw_dbf_setup)
> -		debug_unregister(claw_dbf_setup);
> -	if (claw_dbf_trace)
> -		debug_unregister(claw_dbf_trace);
> +	debug_unregister(claw_dbf_setup);
> +	debug_unregister(claw_dbf_trace);
>  }
> 
>  static int
> diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
> index e056dd4..34dc0f3 100644
> --- a/drivers/s390/net/ctcm_main.c
> +++ b/drivers/s390/net/ctcm_main.c
> @@ -1074,8 +1074,7 @@ static void ctcm_free_netdevice(struct net_device *dev)
>  	if (priv) {
>  		grp = priv->mpcg;
>  		if (grp) {
> -			if (grp->fsm)
> -				kfree_fsm(grp->fsm);
> +			kfree_fsm(grp->fsm);
>  			if (grp->xid_skb)
>  				dev_kfree_skb(grp->xid_skb);
>  			if (grp->rcvd_xid_skb)
> @@ -1672,8 +1671,7 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)
>  		ctcm_free_netdevice(dev);
>  	}
> 
> -	if (priv->fsm)
> -		kfree_fsm(priv->fsm);
> +	kfree_fsm(priv->fsm);
> 
>  	ccw_device_set_offline(cgdev->cdev[1]);
>  	ccw_device_set_offline(cgdev->cdev[0]);
> diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
> index 0a7d87c..5dfa7dd 100644
> --- a/drivers/s390/net/lcs.c
> +++ b/drivers/s390/net/lcs.c
> @@ -88,10 +88,8 @@ static debug_info_t *lcs_dbf_trace;
>  static void
>  lcs_unregister_debug_facility(void)
>  {
> -	if (lcs_dbf_setup)
> -		debug_unregister(lcs_dbf_setup);
> -	if (lcs_dbf_trace)
> -		debug_unregister(lcs_dbf_trace);
> +	debug_unregister(lcs_dbf_setup);
> +	debug_unregister(lcs_dbf_trace);
>  }
> 
>  static int
> diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
> index 0a87809..bdcc3fe 100644
> --- a/drivers/s390/net/netiucv.c
> +++ b/drivers/s390/net/netiucv.c
> @@ -487,12 +487,9 @@ DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);
> 
>  static void iucv_unregister_dbf_views(void)
>  {
> -	if (iucv_dbf_setup)
> -		debug_unregister(iucv_dbf_setup);
> -	if (iucv_dbf_data)
> -		debug_unregister(iucv_dbf_data);
> -	if (iucv_dbf_trace)
> -		debug_unregister(iucv_dbf_trace);
> +	debug_unregister(iucv_dbf_setup);
> +	debug_unregister(iucv_dbf_data);
> +	debug_unregister(iucv_dbf_trace);
>  }
>  static int iucv_register_dbf_views(void)
>  {
> @@ -1975,8 +1972,7 @@ static void netiucv_free_netdevice(struct net_device *dev)
>  	if (privptr) {
>  		if (privptr->conn)
>  			netiucv_remove_connection(privptr->conn);
> -		if (privptr->fsm)
> -			kfree_fsm(privptr->fsm);
> +		kfree_fsm(privptr->fsm);
>  		privptr->conn = NULL; privptr->fsm = NULL;
>  		/* privptr gets freed by free_netdev() */
>  	}

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

* Re: ceph: Deletion of unnecessary checks before two function calls
  2014-11-03 10:35                                     ` Ilya Dryomov
  (?)
  (?)
@ 2014-11-03 13:27                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 13:27 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Sage Weil, Ceph Development, Linux Kernel Mailing List,
	kernel-janitors, trivial, Coccinelle, Yan, Zheng

> dput() also checks for NULL argument, but the check is wrapped into
> unlikely(), which is why I presume it wasn't picked up.  It would be
> great if you could improve your coccinelle script to handle
> {un,}likely() as well.

Thanks for your suggestion.

Should I consider any more fine-tuning for the affected script
"list_input_parameter_validation1.cocci" in the near future?
https://lkml.org/lkml/2014/3/5/362
http://article.gmane.org/gmane.comp.version-control.coccinelle/3514


>> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
>> *realm)
> 
> The patch was corrupted, that should have been a single line.  I fixed
> it up but you may want to look into your email client settings.

Thanks for your feedback.

Does this example show a conflict between long comments after patch ranges and
line length limitation for email eventually?

Regards,
Markus

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

* Re: ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-03 13:27                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 13:27 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Sage Weil, Ceph Development, Linux Kernel Mailing List,
	kernel-janitors, trivial, Coccinelle, Yan, Zheng

> dput() also checks for NULL argument, but the check is wrapped into
> unlikely(), which is why I presume it wasn't picked up.  It would be
> great if you could improve your coccinelle script to handle
> {un,}likely() as well.

Thanks for your suggestion.

Should I consider any more fine-tuning for the affected script
"list_input_parameter_validation1.cocci" in the near future?
https://lkml.org/lkml/2014/3/5/362
http://article.gmane.org/gmane.comp.version-control.coccinelle/3514


>> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
>> *realm)
> 
> The patch was corrupted, that should have been a single line.  I fixed
> it up but you may want to look into your email client settings.

Thanks for your feedback.

Does this example show a conflict between long comments after patch ranges and
line length limitation for email eventually?

Regards,
Markus

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

* Re: ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-03 13:27                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 13:27 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Sage Weil, Ceph Development, Linux Kernel Mailing List,
	kernel-janitors, trivial, Coccinelle, Yan, Zheng

> dput() also checks for NULL argument, but the check is wrapped into
> unlikely(), which is why I presume it wasn't picked up.  It would be
> great if you could improve your coccinelle script to handle
> {un,}likely() as well.

Thanks for your suggestion.

Should I consider any more fine-tuning for the affected script
"list_input_parameter_validation1.cocci" in the near future?
https://lkml.org/lkml/2014/3/5/362
http://article.gmane.org/gmane.comp.version-control.coccinelle/3514


>> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
>> *realm)
> 
> The patch was corrupted, that should have been a single line.  I fixed
> it up but you may want to look into your email client settings.

Thanks for your feedback.

Does this example show a conflict between long comments after patch ranges and
line length limitation for email eventually?

Regards,
Markus

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

* [Cocci] ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-03 13:27                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 13:27 UTC (permalink / raw)
  To: cocci

> dput() also checks for NULL argument, but the check is wrapped into
> unlikely(), which is why I presume it wasn't picked up.  It would be
> great if you could improve your coccinelle script to handle
> {un,}likely() as well.

Thanks for your suggestion.

Should I consider any more fine-tuning for the affected script
"list_input_parameter_validation1.cocci" in the near future?
https://lkml.org/lkml/2014/3/5/362
http://article.gmane.org/gmane.comp.version-control.coccinelle/3514


>> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
>> *realm)
> 
> The patch was corrupted, that should have been a single line.  I fixed
> it up but you may want to look into your email client settings.

Thanks for your feedback.

Does this example show a conflict between long comments after patch ranges and
line length limitation for email eventually?

Regards,
Markus

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

* Re: [PATCH resent] ALSA: emu10k1: Deletion of unnecessary checks before three function calls
  2014-11-03  9:45                                     ` Takashi Iwai
  (?)
  (?)
@ 2014-11-03 14:10                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 14:10 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, alsa-devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

> Your patch can't be applied cleanly due to your MUA breaking the
> lines.  Please fix your MUA setup, or use an attachment if it's
> impossible, and resend the patch.

Thanks for your feedback.

Does this example show a conflict between long comments like
"snd_emu10k1_ctl_private_free( ... *kctl)" after patch ranges and line length
limitation for email eventually?


> Also, try to align the subject line with the relevant commits.  See
> "git log sound/pci/emu10k1"

I have attached my update suggestion with a slightly different commit title as
before. Is this variant acceptable?

Regards,
Markus

[-- Attachment #2: 0001-ALSA-emu10k1-Deletion-of-unnecessary-checks-before-t.patch --]
[-- Type: text/x-patch, Size: 2120 bytes --]

>From 23bb7bd1325b7c9cc81761db3ebf3ea19f85338d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 3 Nov 2014 14:54:36 +0100
Subject: [PATCH] ALSA: emu10k1: Deletion of unnecessary checks before three
 function calls

The functions kfree(), release_firmware() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/emu10k1/emu10k1_main.c | 9 +++------
 sound/pci/emu10k1/emufx.c        | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 2292697..b4458a6 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 	}
 	if (emu->emu1010.firmware_thread)
 		kthread_stop(emu->emu1010.firmware_thread);
-	if (emu->firmware)
-		release_firmware(emu->firmware);
-	if (emu->dock_fw)
-		release_firmware(emu->dock_fw);
+	release_firmware(emu->firmware);
+	release_firmware(emu->dock_fw);
 	if (emu->irq >= 0)
 		free_irq(emu->irq, emu);
 	/* remove reserved page */
@@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 			(struct snd_util_memblk *)emu->reserved_page);
 		emu->reserved_page = NULL;
 	}
-	if (emu->memhdr)
-		snd_util_memhdr_free(emu->memhdr);
+	snd_util_memhdr_free(emu->memhdr);
 	if (emu->silent_page.area)
 		snd_dma_free_pages(&emu->silent_page);
 	if (emu->ptb_pages.area)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 745f062..eb5c0ab 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol *kctl)
 	kctl->private_value = 0;
 	list_del(&ctl->list);
 	kfree(ctl);
-	if (kctl->tlv.p)
-		kfree(kctl->tlv.p);
+	kfree(kctl->tlv.p);
 }
 
 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
-- 
2.1.3


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

* Re: [PATCH resent] ALSA: emu10k1: Deletion of unnecessary checks before three function calls
@ 2014-11-03 14:10                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 14:10 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, alsa-devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

> Your patch can't be applied cleanly due to your MUA breaking the
> lines.  Please fix your MUA setup, or use an attachment if it's
> impossible, and resend the patch.

Thanks for your feedback.

Does this example show a conflict between long comments like
"snd_emu10k1_ctl_private_free( ... *kctl)" after patch ranges and line length
limitation for email eventually?


> Also, try to align the subject line with the relevant commits.  See
> "git log sound/pci/emu10k1"

I have attached my update suggestion with a slightly different commit title as
before. Is this variant acceptable?

Regards,
Markus

[-- Attachment #2: 0001-ALSA-emu10k1-Deletion-of-unnecessary-checks-before-t.patch --]
[-- Type: text/x-patch, Size: 2119 bytes --]

From 23bb7bd1325b7c9cc81761db3ebf3ea19f85338d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 3 Nov 2014 14:54:36 +0100
Subject: [PATCH] ALSA: emu10k1: Deletion of unnecessary checks before three
 function calls

The functions kfree(), release_firmware() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/emu10k1/emu10k1_main.c | 9 +++------
 sound/pci/emu10k1/emufx.c        | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 2292697..b4458a6 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 	}
 	if (emu->emu1010.firmware_thread)
 		kthread_stop(emu->emu1010.firmware_thread);
-	if (emu->firmware)
-		release_firmware(emu->firmware);
-	if (emu->dock_fw)
-		release_firmware(emu->dock_fw);
+	release_firmware(emu->firmware);
+	release_firmware(emu->dock_fw);
 	if (emu->irq >= 0)
 		free_irq(emu->irq, emu);
 	/* remove reserved page */
@@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 			(struct snd_util_memblk *)emu->reserved_page);
 		emu->reserved_page = NULL;
 	}
-	if (emu->memhdr)
-		snd_util_memhdr_free(emu->memhdr);
+	snd_util_memhdr_free(emu->memhdr);
 	if (emu->silent_page.area)
 		snd_dma_free_pages(&emu->silent_page);
 	if (emu->ptb_pages.area)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 745f062..eb5c0ab 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol *kctl)
 	kctl->private_value = 0;
 	list_del(&ctl->list);
 	kfree(ctl);
-	if (kctl->tlv.p)
-		kfree(kctl->tlv.p);
+	kfree(kctl->tlv.p);
 }
 
 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
-- 
2.1.3


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

* Re: [PATCH resent] ALSA: emu10k1: Deletion of unnecessary checks before three function calls
@ 2014-11-03 14:10                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 14:10 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, alsa-devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

> Your patch can't be applied cleanly due to your MUA breaking the
> lines.  Please fix your MUA setup, or use an attachment if it's
> impossible, and resend the patch.

Thanks for your feedback.

Does this example show a conflict between long comments like
"snd_emu10k1_ctl_private_free( ... *kctl)" after patch ranges and line length
limitation for email eventually?


> Also, try to align the subject line with the relevant commits.  See
> "git log sound/pci/emu10k1"

I have attached my update suggestion with a slightly different commit title as
before. Is this variant acceptable?

Regards,
Markus

[-- Attachment #2: 0001-ALSA-emu10k1-Deletion-of-unnecessary-checks-before-t.patch --]
[-- Type: text/x-patch, Size: 2120 bytes --]

>From 23bb7bd1325b7c9cc81761db3ebf3ea19f85338d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 3 Nov 2014 14:54:36 +0100
Subject: [PATCH] ALSA: emu10k1: Deletion of unnecessary checks before three
 function calls

The functions kfree(), release_firmware() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/emu10k1/emu10k1_main.c | 9 +++------
 sound/pci/emu10k1/emufx.c        | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 2292697..b4458a6 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1289,10 +1289,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 	}
 	if (emu->emu1010.firmware_thread)
 		kthread_stop(emu->emu1010.firmware_thread);
-	if (emu->firmware)
-		release_firmware(emu->firmware);
-	if (emu->dock_fw)
-		release_firmware(emu->dock_fw);
+	release_firmware(emu->firmware);
+	release_firmware(emu->dock_fw);
 	if (emu->irq >= 0)
 		free_irq(emu->irq, emu);
 	/* remove reserved page */
@@ -1301,8 +1299,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
 			(struct snd_util_memblk *)emu->reserved_page);
 		emu->reserved_page = NULL;
 	}
-	if (emu->memhdr)
-		snd_util_memhdr_free(emu->memhdr);
+	snd_util_memhdr_free(emu->memhdr);
 	if (emu->silent_page.area)
 		snd_dma_free_pages(&emu->silent_page);
 	if (emu->ptb_pages.area)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 745f062..eb5c0ab 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -777,8 +777,7 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol *kctl)
 	kctl->private_value = 0;
 	list_del(&ctl->list);
 	kfree(ctl);
-	if (kctl->tlv.p)
-		kfree(kctl->tlv.p);
+	kfree(kctl->tlv.p);
 }
 
 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
-- 
2.1.3


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

* [Cocci] [PATCH resent] ALSA: emu10k1: Deletion of unnecessary checks before three function calls
@ 2014-11-03 14:10                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 14:10 UTC (permalink / raw)
  To: cocci

> Your patch can't be applied cleanly due to your MUA breaking the
> lines.  Please fix your MUA setup, or use an attachment if it's
> impossible, and resend the patch.

Thanks for your feedback.

Does this example show a conflict between long comments like
"snd_emu10k1_ctl_private_free( ... *kctl)" after patch ranges and line length
limitation for email eventually?


> Also, try to align the subject line with the relevant commits.  See
> "git log sound/pci/emu10k1"

I have attached my update suggestion with a slightly different commit title as
before. Is this variant acceptable?

Regards,
Markus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ALSA-emu10k1-Deletion-of-unnecessary-checks-before-t.patch
Type: text/x-patch
Size: 2120 bytes
Desc: not available
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20141103/7a73952b/attachment.bin>

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

* Re: [PATCH resent] ALSA: emu10k1: Deletion of unnecessary checks before three function calls
  2014-11-03 14:10                                       ` SF Markus Elfring
  (?)
@ 2014-11-03 14:17                                         ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-03 14:17 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

At Mon, 03 Nov 2014 15:10:40 +0100,
SF Markus Elfring wrote:
> 
> > Your patch can't be applied cleanly due to your MUA breaking the
> > lines.  Please fix your MUA setup, or use an attachment if it's
> > impossible, and resend the patch.
> 
> Thanks for your feedback.
> 
> Does this example show a conflict between long comments like
> "snd_emu10k1_ctl_private_free( ... *kctl)" after patch ranges and line length
> limitation for email eventually?

Conflict?  It's your MUA that is broken.

> > Also, try to align the subject line with the relevant commits.  See
> > "git log sound/pci/emu10k1"
> 
> I have attached my update suggestion with a slightly different commit title as
> before. Is this variant acceptable?

So, you couldn't fix your MUA?  That's bad for you.  Many maintainers
dislike attachments and won't accept such patches.

Couldn't you simply send a patch via git-send-email?

In anyway, I applied the patch now.  Thanks.


Takashi

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

* Re: [PATCH resent] ALSA: emu10k1: Deletion of unnecessary checks before three function calls
@ 2014-11-03 14:17                                         ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-03 14:17 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

At Mon, 03 Nov 2014 15:10:40 +0100,
SF Markus Elfring wrote:
> 
> > Your patch can't be applied cleanly due to your MUA breaking the
> > lines.  Please fix your MUA setup, or use an attachment if it's
> > impossible, and resend the patch.
> 
> Thanks for your feedback.
> 
> Does this example show a conflict between long comments like
> "snd_emu10k1_ctl_private_free( ... *kctl)" after patch ranges and line length
> limitation for email eventually?

Conflict?  It's your MUA that is broken.

> > Also, try to align the subject line with the relevant commits.  See
> > "git log sound/pci/emu10k1"
> 
> I have attached my update suggestion with a slightly different commit title as
> before. Is this variant acceptable?

So, you couldn't fix your MUA?  That's bad for you.  Many maintainers
dislike attachments and won't accept such patches.

Couldn't you simply send a patch via git-send-email?

In anyway, I applied the patch now.  Thanks.


Takashi

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

* [Cocci] [PATCH resent] ALSA: emu10k1: Deletion of unnecessary checks before three function calls
@ 2014-11-03 14:17                                         ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-03 14:17 UTC (permalink / raw)
  To: cocci

At Mon, 03 Nov 2014 15:10:40 +0100,
SF Markus Elfring wrote:
> 
> > Your patch can't be applied cleanly due to your MUA breaking the
> > lines.  Please fix your MUA setup, or use an attachment if it's
> > impossible, and resend the patch.
> 
> Thanks for your feedback.
> 
> Does this example show a conflict between long comments like
> "snd_emu10k1_ctl_private_free( ... *kctl)" after patch ranges and line length
> limitation for email eventually?

Conflict?  It's your MUA that is broken.

> > Also, try to align the subject line with the relevant commits.  See
> > "git log sound/pci/emu10k1"
> 
> I have attached my update suggestion with a slightly different commit title as
> before. Is this variant acceptable?

So, you couldn't fix your MUA?  That's bad for you.  Many maintainers
dislike attachments and won't accept such patches.

Couldn't you simply send a patch via git-send-email?

In anyway, I applied the patch now.  Thanks.


Takashi

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

* Re: ceph: Deletion of unnecessary checks before two function calls
  2014-11-03 13:27                                       ` SF Markus Elfring
  (?)
@ 2014-11-03 14:23                                         ` Ilya Dryomov
  -1 siblings, 0 replies; 3633+ messages in thread
From: Ilya Dryomov @ 2014-11-03 14:23 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sage Weil, Ceph Development, Linux Kernel Mailing List,
	kernel-janitors, trivial, Coccinelle, Yan, Zheng

On Mon, Nov 3, 2014 at 4:27 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> dput() also checks for NULL argument, but the check is wrapped into
>> unlikely(), which is why I presume it wasn't picked up.  It would be
>> great if you could improve your coccinelle script to handle
>> {un,}likely() as well.
>
> Thanks for your suggestion.
>
> Should I consider any more fine-tuning for the affected script
> "list_input_parameter_validation1.cocci" in the near future?
> https://lkml.org/lkml/2014/3/5/362
> http://article.gmane.org/gmane.comp.version-control.coccinelle/3514

Make sure it at least catches stuff like:

{
    if (input) {

    }
}

{
    if (likely(input)) {

    }
}

{
    if (!input)
        return;

    ...
}

{
    if (unlikely(!input))
        return;

    ...
}

And of course each match then has to be validated manually.

>
>
>>> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
>>> *realm)
>>
>> The patch was corrupted, that should have been a single line.  I fixed
>> it up but you may want to look into your email client settings.
>
> Thanks for your feedback.
>
> Does this example show a conflict between long comments after patch ranges and
> line length limitation for email eventually?

There is no line length limitation for email, at least one that would
be relevant here.  Patches should be sent verbatim, no line wrapping,
expandtab, etc or they won't apply.  I'd recommend git-send-email, but
if you want to make thunderbird work for patches (which is what you
seem to be using) have a look at the "Thunderbird (GUI)" section of
Documentation/email-clients.txt in the kernel tree.

Thanks,

                Ilya

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

* Re: ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-03 14:23                                         ` Ilya Dryomov
  0 siblings, 0 replies; 3633+ messages in thread
From: Ilya Dryomov @ 2014-11-03 14:23 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sage Weil, Ceph Development, Linux Kernel Mailing List,
	kernel-janitors, trivial, Coccinelle, Yan, Zheng

On Mon, Nov 3, 2014 at 4:27 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> dput() also checks for NULL argument, but the check is wrapped into
>> unlikely(), which is why I presume it wasn't picked up.  It would be
>> great if you could improve your coccinelle script to handle
>> {un,}likely() as well.
>
> Thanks for your suggestion.
>
> Should I consider any more fine-tuning for the affected script
> "list_input_parameter_validation1.cocci" in the near future?
> https://lkml.org/lkml/2014/3/5/362
> http://article.gmane.org/gmane.comp.version-control.coccinelle/3514

Make sure it at least catches stuff like:

{
    if (input) {

    }
}

{
    if (likely(input)) {

    }
}

{
    if (!input)
        return;

    ...
}

{
    if (unlikely(!input))
        return;

    ...
}

And of course each match then has to be validated manually.

>
>
>>> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
>>> *realm)
>>
>> The patch was corrupted, that should have been a single line.  I fixed
>> it up but you may want to look into your email client settings.
>
> Thanks for your feedback.
>
> Does this example show a conflict between long comments after patch ranges and
> line length limitation for email eventually?

There is no line length limitation for email, at least one that would
be relevant here.  Patches should be sent verbatim, no line wrapping,
expandtab, etc or they won't apply.  I'd recommend git-send-email, but
if you want to make thunderbird work for patches (which is what you
seem to be using) have a look at the "Thunderbird (GUI)" section of
Documentation/email-clients.txt in the kernel tree.

Thanks,

                Ilya

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

* [Cocci] ceph: Deletion of unnecessary checks before two function calls
@ 2014-11-03 14:23                                         ` Ilya Dryomov
  0 siblings, 0 replies; 3633+ messages in thread
From: Ilya Dryomov @ 2014-11-03 14:23 UTC (permalink / raw)
  To: cocci

On Mon, Nov 3, 2014 at 4:27 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> dput() also checks for NULL argument, but the check is wrapped into
>> unlikely(), which is why I presume it wasn't picked up.  It would be
>> great if you could improve your coccinelle script to handle
>> {un,}likely() as well.
>
> Thanks for your suggestion.
>
> Should I consider any more fine-tuning for the affected script
> "list_input_parameter_validation1.cocci" in the near future?
> https://lkml.org/lkml/2014/3/5/362
> http://article.gmane.org/gmane.comp.version-control.coccinelle/3514

Make sure it at least catches stuff like:

{
    if (input) {

    }
}

{
    if (likely(input)) {

    }
}

{
    if (!input)
        return;

    ...
}

{
    if (unlikely(!input))
        return;

    ...
}

And of course each match then has to be validated manually.

>
>
>>> @@ -590,15 +589,13 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm
>>> *realm)
>>
>> The patch was corrupted, that should have been a single line.  I fixed
>> it up but you may want to look into your email client settings.
>
> Thanks for your feedback.
>
> Does this example show a conflict between long comments after patch ranges and
> line length limitation for email eventually?

There is no line length limitation for email, at least one that would
be relevant here.  Patches should be sent verbatim, no line wrapping,
expandtab, etc or they won't apply.  I'd recommend git-send-email, but
if you want to make thunderbird work for patches (which is what you
seem to be using) have a look at the "Thunderbird (GUI)" section of
Documentation/email-clients.txt in the kernel tree.

Thanks,

                Ilya

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03  9:50                                     ` Dan Carpenter
  (?)
@ 2014-11-03 15:55                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 15:55 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Ursula Braun, Martin Schwidefsky, Heiko Carstens, Frank Blaschka,
	linux390, linux-s390, linux-kernel, kernel-janitors, trivial,
	Coccinelle

> This one is buggy.

I am still interested to clarify this opinion a bit more.


> I'm sorry, but please stop sending these.

I am going to improve more implementation details in affected source files.


> But for this one:
> 1) I don't know what the functions do so I have to look at the code.

I hope that static source code analysis can help here.


> 2) It's in a arch that I don't compile so cscope isn't set up meaning
>    it's hard to find the functions.

Do you find the Coccinelle software also useful for your area?


> You're sending a lot of patches and they are all hard to review and some
> of them are buggy and none of them really add any value.

Thanks for your feedback.


The suggested source code clean-up might result in a measurable effect
depending on the call frequency for the changed functions.
Can I help you in any ways to make corresponding review easier?


> It's a waste of your time and it's a waste of my time.

It can be your choice to reject my update suggestion.

Regards,
Markus

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 15:55                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 15:55 UTC (permalink / raw)
  To: cocci

> This one is buggy.

I am still interested to clarify this opinion a bit more.


> I'm sorry, but please stop sending these.

I am going to improve more implementation details in affected source files.


> But for this one:
> 1) I don't know what the functions do so I have to look at the code.

I hope that static source code analysis can help here.


> 2) It's in a arch that I don't compile so cscope isn't set up meaning
>    it's hard to find the functions.

Do you find the Coccinelle software also useful for your area?


> You're sending a lot of patches and they are all hard to review and some
> of them are buggy and none of them really add any value.

Thanks for your feedback.


The suggested source code clean-up might result in a measurable effect
depending on the call frequency for the changed functions.
Can I help you in any ways to make corresponding review easier?


> It's a waste of your time and it's a waste of my time.

It can be your choice to reject my update suggestion.

Regards,
Markus

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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 15:55                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 15:55 UTC (permalink / raw)
  To: cocci

> This one is buggy.

I am still interested to clarify this opinion a bit more.


> I'm sorry, but please stop sending these.

I am going to improve more implementation details in affected source files.


> But for this one:
> 1) I don't know what the functions do so I have to look at the code.

I hope that static source code analysis can help here.


> 2) It's in a arch that I don't compile so cscope isn't set up meaning
>    it's hard to find the functions.

Do you find the Coccinelle software also useful for your area?


> You're sending a lot of patches and they are all hard to review and some
> of them are buggy and none of them really add any value.

Thanks for your feedback.


The suggested source code clean-up might result in a measurable effect
depending on the call frequency for the changed functions.
Can I help you in any ways to make corresponding review easier?


> It's a waste of your time and it's a waste of my time.

It can be your choice to reject my update suggestion.

Regards,
Markus

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03 11:04                                     ` Ursula Braun
  (?)
@ 2014-11-03 16:10                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 16:10 UTC (permalink / raw)
  To: Ursula Braun
  Cc: Ursula Braun, Martin Schwidefsky, Heiko Carstens, Frank Blaschka,
	linux390, linux-s390, linux-kernel, kernel-janitors, trivial,
	Coccinelle

> I agree with your proposed debug_unregister() changes, but not with your
> kfree_fsm() change.

Why do you want to keep an additional null pointer check before the call
of the kfree_fsm() function within the implementation of the
netiucv_free_netdevice() function?

Regards,
Markus

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 16:10                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 16:10 UTC (permalink / raw)
  To: cocci

> I agree with your proposed debug_unregister() changes, but not with your
> kfree_fsm() change.

Why do you want to keep an additional null pointer check before the call
of the kfree_fsm() function within the implementation of the
netiucv_free_netdevice() function?

Regards,
Markus

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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 16:10                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 16:10 UTC (permalink / raw)
  To: cocci

> I agree with your proposed debug_unregister() changes, but not with your
> kfree_fsm() change.

Why do you want to keep an additional null pointer check before the call
of the kfree_fsm() function within the implementation of the
netiucv_free_netdevice() function?

Regards,
Markus

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03 15:55                                       ` SF Markus Elfring
  (?)
@ 2014-11-03 16:25                                         ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03 16:25 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ursula Braun, Martin Schwidefsky, Heiko Carstens, Frank Blaschka,
	linux390, linux-s390, linux-kernel, kernel-janitors, trivial,
	Coccinelle

On Mon, Nov 03, 2014 at 04:55:12PM +0100, SF Markus Elfring wrote:
> > This one is buggy.
> 
> I am still interested to clarify this opinion a bit more.
> 

After your patch then it will print warning messages.

The truth is I think that all these patches are bad and they make the
code harder to read.

Before:  The code is clear and there is no NULL dereference.
 After:  You have to remember that rtw_free_netdev() accepts NULL
	 pointers but free_netdev() does not accept NULL pointers.

The if statements are there for *human* readers to understand and you are
making it harder for humans to understand the code.

Even for kfree(), just removing the if statement is not really the right
fix.  We do it because everyone knows kfree(), but what Julia Lawall
said is the real correct way change the code and make it simpler for
people to understand:

https://lkml.org/lkml/2014/10/31/452

I know it's fun to send automated patches but these make the code worse
and they waste reviewer time.

regards,
dan carpenter

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 16:25                                         ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03 16:25 UTC (permalink / raw)
  To: cocci

On Mon, Nov 03, 2014 at 04:55:12PM +0100, SF Markus Elfring wrote:
> > This one is buggy.
> 
> I am still interested to clarify this opinion a bit more.
> 

After your patch then it will print warning messages.

The truth is I think that all these patches are bad and they make the
code harder to read.

Before:  The code is clear and there is no NULL dereference.
 After:  You have to remember that rtw_free_netdev() accepts NULL
	 pointers but free_netdev() does not accept NULL pointers.

The if statements are there for *human* readers to understand and you are
making it harder for humans to understand the code.

Even for kfree(), just removing the if statement is not really the right
fix.  We do it because everyone knows kfree(), but what Julia Lawall
said is the real correct way change the code and make it simpler for
people to understand:

https://lkml.org/lkml/2014/10/31/452

I know it's fun to send automated patches but these make the code worse
and they waste reviewer time.

regards,
dan carpenter

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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 16:25                                         ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03 16:25 UTC (permalink / raw)
  To: cocci

On Mon, Nov 03, 2014 at 04:55:12PM +0100, SF Markus Elfring wrote:
> > This one is buggy.
> 
> I am still interested to clarify this opinion a bit more.
> 

After your patch then it will print warning messages.

The truth is I think that all these patches are bad and they make the
code harder to read.

Before:  The code is clear and there is no NULL dereference.
 After:  You have to remember that rtw_free_netdev() accepts NULL
	 pointers but free_netdev() does not accept NULL pointers.

The if statements are there for *human* readers to understand and you are
making it harder for humans to understand the code.

Even for kfree(), just removing the if statement is not really the right
fix.  We do it because everyone knows kfree(), but what Julia Lawall
said is the real correct way change the code and make it simpler for
people to understand:

https://lkml.org/lkml/2014/10/31/452

I know it's fun to send automated patches but these make the code worse
and they waste reviewer time.

regards,
dan carpenter

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03 16:10                                       ` SF Markus Elfring
  (?)
@ 2014-11-03 16:28                                         ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03 16:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ursula Braun, Ursula Braun, Martin Schwidefsky, Heiko Carstens,
	Frank Blaschka, linux390, linux-s390, linux-kernel,
	kernel-janitors, trivial, Coccinelle

On Mon, Nov 03, 2014 at 05:10:35PM +0100, SF Markus Elfring wrote:
> > I agree with your proposed debug_unregister() changes, but not with your
> > kfree_fsm() change.
> 
> Why do you want to keep an additional null pointer check before the call
> of the kfree_fsm() function within the implementation of the
> netiucv_free_netdevice() function?

Think about how long it takes you to figure this out what the bug is and
then remember that we have to spend that same amount of time multiplied
by the number of patches you have sent.

regards,
dan carpenter


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

* Re: s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 16:28                                         ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03 16:28 UTC (permalink / raw)
  To: cocci

On Mon, Nov 03, 2014 at 05:10:35PM +0100, SF Markus Elfring wrote:
> > I agree with your proposed debug_unregister() changes, but not with your
> > kfree_fsm() change.
> 
> Why do you want to keep an additional null pointer check before the call
> of the kfree_fsm() function within the implementation of the
> netiucv_free_netdevice() function?

Think about how long it takes you to figure this out what the bug is and
then remember that we have to spend that same amount of time multiplied
by the number of patches you have sent.

regards,
dan carpenter


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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 16:28                                         ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03 16:28 UTC (permalink / raw)
  To: cocci

On Mon, Nov 03, 2014 at 05:10:35PM +0100, SF Markus Elfring wrote:
> > I agree with your proposed debug_unregister() changes, but not with your
> > kfree_fsm() change.
> 
> Why do you want to keep an additional null pointer check before the call
> of the kfree_fsm() function within the implementation of the
> netiucv_free_netdevice() function?

Think about how long it takes you to figure this out what the bug is and
then remember that we have to spend that same amount of time multiplied
by the number of patches you have sent.

regards,
dan carpenter

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03 16:25                                         ` Dan Carpenter
  (?)
@ 2014-11-03 16:50                                           ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 16:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Ursula Braun, Martin Schwidefsky, Heiko Carstens, Frank Blaschka,
	linux390, linux-s390, linux-kernel, kernel-janitors, trivial,
	Coccinelle

> After your patch then it will print warning messages.

To which messages do you refer to?


> The truth is I think that all these patches are bad and they make the
> code harder to read.
> 
> Before:  The code is clear and there is no NULL dereference.

Where do you stumble on a null pointer access?


>  After:  You have to remember that rtw_free_netdev() accepts NULL
> 	 pointers but free_netdev() does not accept NULL pointers.

Are any improvements needed for the corresponding documentation to make it
better accessible besides the source code?


> The if statements are there for *human* readers to understand and you are
> making it harder for humans to understand the code.

Is there a target conflict between source code understandability
and software efficiency?


> Even for kfree(), just removing the if statement is not really the right
> fix.  We do it because everyone knows kfree(), but what Julia Lawall
> said is the real correct way change the code and make it simpler for
> people to understand:
> 
> https://lkml.org/lkml/2014/10/31/452

You refer to another update suggestion for the software area
"staging: rtl8188eu".
Do you find adjustments for jump labels easier to accept than the simple
deletion of specific null pointer checks?


> I know it's fun to send automated patches but these make the code worse
> and they waste reviewer time.

I hope that small automated changes can also help to improve affected
source files.

Regards,
Markus

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 16:50                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 16:50 UTC (permalink / raw)
  To: cocci

> After your patch then it will print warning messages.

To which messages do you refer to?


> The truth is I think that all these patches are bad and they make the
> code harder to read.
> 
> Before:  The code is clear and there is no NULL dereference.

Where do you stumble on a null pointer access?


>  After:  You have to remember that rtw_free_netdev() accepts NULL
> 	 pointers but free_netdev() does not accept NULL pointers.

Are any improvements needed for the corresponding documentation to make it
better accessible besides the source code?


> The if statements are there for *human* readers to understand and you are
> making it harder for humans to understand the code.

Is there a target conflict between source code understandability
and software efficiency?


> Even for kfree(), just removing the if statement is not really the right
> fix.  We do it because everyone knows kfree(), but what Julia Lawall
> said is the real correct way change the code and make it simpler for
> people to understand:
> 
> https://lkml.org/lkml/2014/10/31/452

You refer to another update suggestion for the software area
"staging: rtl8188eu".
Do you find adjustments for jump labels easier to accept than the simple
deletion of specific null pointer checks?


> I know it's fun to send automated patches but these make the code worse
> and they waste reviewer time.

I hope that small automated changes can also help to improve affected
source files.

Regards,
Markus

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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 16:50                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 16:50 UTC (permalink / raw)
  To: cocci

> After your patch then it will print warning messages.

To which messages do you refer to?


> The truth is I think that all these patches are bad and they make the
> code harder to read.
> 
> Before:  The code is clear and there is no NULL dereference.

Where do you stumble on a null pointer access?


>  After:  You have to remember that rtw_free_netdev() accepts NULL
> 	 pointers but free_netdev() does not accept NULL pointers.

Are any improvements needed for the corresponding documentation to make it
better accessible besides the source code?


> The if statements are there for *human* readers to understand and you are
> making it harder for humans to understand the code.

Is there a target conflict between source code understandability
and software efficiency?


> Even for kfree(), just removing the if statement is not really the right
> fix.  We do it because everyone knows kfree(), but what Julia Lawall
> said is the real correct way change the code and make it simpler for
> people to understand:
> 
> https://lkml.org/lkml/2014/10/31/452

You refer to another update suggestion for the software area
"staging: rtl8188eu".
Do you find adjustments for jump labels easier to accept than the simple
deletion of specific null pointer checks?


> I know it's fun to send automated patches but these make the code worse
> and they waste reviewer time.

I hope that small automated changes can also help to improve affected
source files.

Regards,
Markus

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03 16:50                                           ` SF Markus Elfring
  (?)
@ 2014-11-03 17:02                                             ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-03 17:02 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, Ursula Braun, Martin Schwidefsky, Heiko Carstens,
	Frank Blaschka, linux390, linux-s390, linux-kernel,
	kernel-janitors, trivial, Coccinelle

> > After your patch then it will print warning messages.
> >  After:  You have to remember that rtw_free_netdev() accepts NULL
> > 	 pointers but free_netdev() does not accept NULL pointers.
>
> Are any improvements needed for the corresponding documentation to make it
> better accessible besides the source code?

When people are writing or reading code, they will not necessarily look at
the documentation for every function that they use.

> > The if statements are there for *human* readers to understand and you are
> > making it harder for humans to understand the code.
>
> Is there a target conflict between source code understandability
> and software efficiency?

Efficiency is not an issue.  This code is all in rare error handling paths
or in service removal functions.  None of it is in a critical path.  What
is important is to be able to easily check that what needs to be done is
actually done.  Removing null tests makes it more obscure what needs to be
done, because it means that the conditions under which a function needs to
be called (which may be different than the conditions under which it can
be called) are less apparent.

julia

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 17:02                                             ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-03 17:02 UTC (permalink / raw)
  To: cocci

> > After your patch then it will print warning messages.
> >  After:  You have to remember that rtw_free_netdev() accepts NULL
> > 	 pointers but free_netdev() does not accept NULL pointers.
>
> Are any improvements needed for the corresponding documentation to make it
> better accessible besides the source code?

When people are writing or reading code, they will not necessarily look at
the documentation for every function that they use.

> > The if statements are there for *human* readers to understand and you are
> > making it harder for humans to understand the code.
>
> Is there a target conflict between source code understandability
> and software efficiency?

Efficiency is not an issue.  This code is all in rare error handling paths
or in service removal functions.  None of it is in a critical path.  What
is important is to be able to easily check that what needs to be done is
actually done.  Removing null tests makes it more obscure what needs to be
done, because it means that the conditions under which a function needs to
be called (which may be different than the conditions under which it can
be called) are less apparent.

julia

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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 17:02                                             ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-03 17:02 UTC (permalink / raw)
  To: cocci

> > After your patch then it will print warning messages.
> >  After:  You have to remember that rtw_free_netdev() accepts NULL
> > 	 pointers but free_netdev() does not accept NULL pointers.
>
> Are any improvements needed for the corresponding documentation to make it
> better accessible besides the source code?

When people are writing or reading code, they will not necessarily look at
the documentation for every function that they use.

> > The if statements are there for *human* readers to understand and you are
> > making it harder for humans to understand the code.
>
> Is there a target conflict between source code understandability
> and software efficiency?

Efficiency is not an issue.  This code is all in rare error handling paths
or in service removal functions.  None of it is in a critical path.  What
is important is to be able to easily check that what needs to be done is
actually done.  Removing null tests makes it more obscure what needs to be
done, because it means that the conditions under which a function needs to
be called (which may be different than the conditions under which it can
be called) are less apparent.

julia

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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03 16:25                                         ` Dan Carpenter
                                                           ` (2 preceding siblings ...)
  (?)
@ 2014-11-03 17:05                                         ` Derek M Jones
  2014-11-03 17:32                                           ` Julia Lawall
  2014-11-03 21:30                                           ` [Cocci] Are defensive checks treated differently in specific areas? SF Markus Elfring
  -1 siblings, 2 replies; 3633+ messages in thread
From: Derek M Jones @ 2014-11-03 17:05 UTC (permalink / raw)
  To: cocci

Dan

> The truth is I think that all these patches are bad and they make the
> code harder to read.

I disagree, I think the code requires less effort to read without the
if test.

A developer reading the code will wonder why kfree does not handle the
case when its argument is NULL.  This takes effort.

Now there might be a reason while kfree (or any other function) does
not handle NULL, in which case the test is necessary for that reason.
Or perhaps calling kfree has other consequences and this means it is
good to minimise the number of calls, fair enough.

> The if statements are there for *human* readers to understand and you are
> making it harder for humans to understand the code.

The reverse is true.

But if there are other reasons, then leave the test in.

-- 
Derek M. Jones                  tel: +44 (0) 1252 520 667
Knowledge Software Ltd          blog:shape-of-code.coding-guidelines.com
Software analysis               http://www.knosof.co.uk

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03 16:50                                           ` SF Markus Elfring
  (?)
@ 2014-11-03 17:16                                             ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03 17:16 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ursula Braun, Martin Schwidefsky, Heiko Carstens, Frank Blaschka,
	linux390, linux-s390, linux-kernel, kernel-janitors, trivial,
	Coccinelle

On Mon, Nov 03, 2014 at 05:50:48PM +0100, SF Markus Elfring wrote:
> > After your patch then it will print warning messages.
> 
> To which messages do you refer to?
> 

Open your eyeballs up and read the code.

> 
> > The truth is I think that all these patches are bad and they make the
> > code harder to read.
> > 
> > Before:  The code is clear and there is no NULL dereference.
> 
> Where do you stumble on a null pointer access?
> 

I'm not talking about bugs, I'm talking about code clarity.  Before is
more clear than after.

> 
> >  After:  You have to remember that rtw_free_netdev() accepts NULL
> > 	 pointers but free_netdev() does not accept NULL pointers.
> 
> Are any improvements needed for the corresponding documentation to make it
> better accessible besides the source code?
> 

Documentation doesn't reduce the number of things to remember it just
documents it.  Meanwhile if we leave the code as-is there is no need for
documentation because the code is clear.

> 
> > The if statements are there for *human* readers to understand and you are
> > making it harder for humans to understand the code.
> 
> Is there a target conflict between source code understandability
> and software efficiency?

If you can benchmark the code and the new code is faster then, yes, this
patch is good and we will apply it.  If you have no benchmarks then do
not send the patch.

> 
> > Even for kfree(), just removing the if statement is not really the right
> > fix.  We do it because everyone knows kfree(), but what Julia Lawall
> > said is the real correct way change the code and make it simpler for
> > people to understand:
> > 
> > https://lkml.org/lkml/2014/10/31/452
> 
> You refer to another update suggestion for the software area
> "staging: rtl8188eu".
> Do you find adjustments for jump labels easier to accept than the simple
> deletion of specific null pointer checks?

Yes.

> 
> 
> > I know it's fun to send automated patches but these make the code worse
> > and they waste reviewer time.
> 
> I hope that small automated changes can also help to improve affected
> source files.

No.  The changes make the code less clear.

regards,
dan carpenter


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

* Re: s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 17:16                                             ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03 17:16 UTC (permalink / raw)
  To: cocci

On Mon, Nov 03, 2014 at 05:50:48PM +0100, SF Markus Elfring wrote:
> > After your patch then it will print warning messages.
> 
> To which messages do you refer to?
> 

Open your eyeballs up and read the code.

> 
> > The truth is I think that all these patches are bad and they make the
> > code harder to read.
> > 
> > Before:  The code is clear and there is no NULL dereference.
> 
> Where do you stumble on a null pointer access?
> 

I'm not talking about bugs, I'm talking about code clarity.  Before is
more clear than after.

> 
> >  After:  You have to remember that rtw_free_netdev() accepts NULL
> > 	 pointers but free_netdev() does not accept NULL pointers.
> 
> Are any improvements needed for the corresponding documentation to make it
> better accessible besides the source code?
> 

Documentation doesn't reduce the number of things to remember it just
documents it.  Meanwhile if we leave the code as-is there is no need for
documentation because the code is clear.

> 
> > The if statements are there for *human* readers to understand and you are
> > making it harder for humans to understand the code.
> 
> Is there a target conflict between source code understandability
> and software efficiency?

If you can benchmark the code and the new code is faster then, yes, this
patch is good and we will apply it.  If you have no benchmarks then do
not send the patch.

> 
> > Even for kfree(), just removing the if statement is not really the right
> > fix.  We do it because everyone knows kfree(), but what Julia Lawall
> > said is the real correct way change the code and make it simpler for
> > people to understand:
> > 
> > https://lkml.org/lkml/2014/10/31/452
> 
> You refer to another update suggestion for the software area
> "staging: rtl8188eu".
> Do you find adjustments for jump labels easier to accept than the simple
> deletion of specific null pointer checks?

Yes.

> 
> 
> > I know it's fun to send automated patches but these make the code worse
> > and they waste reviewer time.
> 
> I hope that small automated changes can also help to improve affected
> source files.

No.  The changes make the code less clear.

regards,
dan carpenter


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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 17:16                                             ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-03 17:16 UTC (permalink / raw)
  To: cocci

On Mon, Nov 03, 2014 at 05:50:48PM +0100, SF Markus Elfring wrote:
> > After your patch then it will print warning messages.
> 
> To which messages do you refer to?
> 

Open your eyeballs up and read the code.

> 
> > The truth is I think that all these patches are bad and they make the
> > code harder to read.
> > 
> > Before:  The code is clear and there is no NULL dereference.
> 
> Where do you stumble on a null pointer access?
> 

I'm not talking about bugs, I'm talking about code clarity.  Before is
more clear than after.

> 
> >  After:  You have to remember that rtw_free_netdev() accepts NULL
> > 	 pointers but free_netdev() does not accept NULL pointers.
> 
> Are any improvements needed for the corresponding documentation to make it
> better accessible besides the source code?
> 

Documentation doesn't reduce the number of things to remember it just
documents it.  Meanwhile if we leave the code as-is there is no need for
documentation because the code is clear.

> 
> > The if statements are there for *human* readers to understand and you are
> > making it harder for humans to understand the code.
> 
> Is there a target conflict between source code understandability
> and software efficiency?

If you can benchmark the code and the new code is faster then, yes, this
patch is good and we will apply it.  If you have no benchmarks then do
not send the patch.

> 
> > Even for kfree(), just removing the if statement is not really the right
> > fix.  We do it because everyone knows kfree(), but what Julia Lawall
> > said is the real correct way change the code and make it simpler for
> > people to understand:
> > 
> > https://lkml.org/lkml/2014/10/31/452
> 
> You refer to another update suggestion for the software area
> "staging: rtl8188eu".
> Do you find adjustments for jump labels easier to accept than the simple
> deletion of specific null pointer checks?

Yes.

> 
> 
> > I know it's fun to send automated patches but these make the code worse
> > and they waste reviewer time.
> 
> I hope that small automated changes can also help to improve affected
> source files.

No.  The changes make the code less clear.

regards,
dan carpenter

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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03 17:05                                         ` [Cocci] " Derek M Jones
@ 2014-11-03 17:32                                           ` Julia Lawall
  2014-11-03 21:30                                           ` [Cocci] Are defensive checks treated differently in specific areas? SF Markus Elfring
  1 sibling, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-03 17:32 UTC (permalink / raw)
  To: cocci

On Mon, 3 Nov 2014, Derek M Jones wrote:

> Dan
>
> > The truth is I think that all these patches are bad and they make the
> > code harder to read.
>
> I disagree, I think the code requires less effort to read without the
> if test.
>
> A developer reading the code will wonder why kfree does not handle the
> case when its argument is NULL.  This takes effort.
>
> Now there might be a reason while kfree (or any other function) does
> not handle NULL, in which case the test is necessary for that reason.
> Or perhaps calling kfree has other consequences and this means it is
> good to minimise the number of calls, fair enough.

This may be true in general, but the standard assumption about kernel
functions is that they are not defensive.  Everything used in the kernel
is defined in the kernel, and is normally written in a way to be optimal
for in-kernel usage.

> > The if statements are there for *human* readers to understand and you are
> > making it harder for humans to understand the code.
>
> The reverse is true.
>
> But if there are other reasons, then leave the test in.

The point about a null test is that it makes it apparent at the current
point that the value can be null.  The default assumption is that it
cannot, ie that functions are only called when doing so is useful.

Actually, this assumption can be exploited by automatic tools for finding
out what needs to be done when:

Suman Saha, Jean-Pierre Lozi, Ga?l Thomas, Julia L. Lawall, Gilles Muller:
Hector: Detecting Resource-Release Omission Faults in error-handling code
for systems software. DSN 2013: 1-12

The point is that Linux code contains a huge number of alloc and free
functions, many of which are not very well known.  If free functions are
only called when they are useful, then you can infer which free functions
go with which alloc functions.  If all free functions are just lumped
together and called at random, then you lose a lot of information.

Similarly, as a human, when I look at code I don't know, it is very
confusing to have functions called when as far as I can tell they don't
need to be.  A bunch of validity tests at the beginning of the
called function doesn't really help, because as Dan points out the code is
not always easy to find, and in the function definition itself one doesn't
know in what contexts that code is intended to be used.

In separate cleanup functions (destroy_xxx) perhaps the tests are more or
less noise.  But in the error handling code of an initialization function,
no test means to me that the call is needed at the current point, and a
test means to me that for some reason it is not statically known whether a
call is needed or not.  This is information that is really useful for
understanding the code, for both humans and for tools.

julia

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
  2014-11-03 17:16                                             ` Dan Carpenter
  (?)
@ 2014-11-03 17:40                                               ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 17:40 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Ursula Braun, Martin Schwidefsky, Heiko Carstens, Frank Blaschka,
	linux390, linux-s390, linux-kernel, kernel-janitors, trivial,
	Coccinelle

> If you can benchmark the code and the new code is faster then, yes, this
> patch is good and we will apply it.

I guess that I do not have enough resources myself to measure different run time
effects in a S390 environment.


> If you have no benchmarks then do not send the patch.

Are other software developers and testers eventually interested to try a few
pointer check adjustments out a bit more?

Regards,
Markus

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 17:40                                               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 17:40 UTC (permalink / raw)
  To: cocci

> If you can benchmark the code and the new code is faster then, yes, this
> patch is good and we will apply it.

I guess that I do not have enough resources myself to measure different run time
effects in a S390 environment.


> If you have no benchmarks then do not send the patch.

Are other software developers and testers eventually interested to try a few
pointer check adjustments out a bit more?

Regards,
Markus

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

* [Cocci] s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-03 17:40                                               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 17:40 UTC (permalink / raw)
  To: cocci

> If you can benchmark the code and the new code is faster then, yes, this
> patch is good and we will apply it.

I guess that I do not have enough resources myself to measure different run time
effects in a S390 environment.


> If you have no benchmarks then do not send the patch.

Are other software developers and testers eventually interested to try a few
pointer check adjustments out a bit more?

Regards,
Markus

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

* [PATCH v2] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value"
  2014-11-02 19:42                                   ` SF Markus Elfring
  (?)
@ 2014-11-03 18:40                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 18:40 UTC (permalink / raw)
  To: Yann E. MORIN, linux-kbuild
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>

The sym_calc_value() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Paul Bolle <pebolle@tiscali.nl>
---
 scripts/kconfig/confdata.c | 6 ++----
 scripts/kconfig/symbol.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..3073cb6 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -262,8 +262,7 @@ int conf_read_simple(const char *name, int def)
 			goto load;
 		sym_add_change_count(1);
 		if (!sym_defconfig_list) {
-			if (modules_sym)
-				sym_calc_value(modules_sym);
+			sym_calc_value(modules_sym);
 			return 1;
 		}
 
@@ -399,8 +398,7 @@ setsym:
 	free(line);
 	fclose(in);
 
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 	return 0;
 }
 
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 7caabdb..3f7797b 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -447,8 +447,7 @@ void sym_clear_all_valid(void)
 	for_all_symbols(i, sym)
 		sym->flags &= ~SYMBOL_VALID;
 	sym_add_change_count(1);
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 }
 
 void sym_set_changed(struct symbol *sym)
-- 
2.1.3



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

* [PATCH v2] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value"
@ 2014-11-03 18:40                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 18:40 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>

The sym_calc_value() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Paul Bolle <pebolle@tiscali.nl>
---
 scripts/kconfig/confdata.c | 6 ++----
 scripts/kconfig/symbol.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..3073cb6 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -262,8 +262,7 @@ int conf_read_simple(const char *name, int def)
 			goto load;
 		sym_add_change_count(1);
 		if (!sym_defconfig_list) {
-			if (modules_sym)
-				sym_calc_value(modules_sym);
+			sym_calc_value(modules_sym);
 			return 1;
 		}
 
@@ -399,8 +398,7 @@ setsym:
 	free(line);
 	fclose(in);
 
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 	return 0;
 }
 
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 7caabdb..3f7797b 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -447,8 +447,7 @@ void sym_clear_all_valid(void)
 	for_all_symbols(i, sym)
 		sym->flags &= ~SYMBOL_VALID;
 	sym_add_change_count(1);
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 }
 
 void sym_set_changed(struct symbol *sym)
-- 
2.1.3



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

* [Cocci] [PATCH v2] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value"
@ 2014-11-03 18:40                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 18:40 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>

The sym_calc_value() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Paul Bolle <pebolle@tiscali.nl>
---
 scripts/kconfig/confdata.c | 6 ++----
 scripts/kconfig/symbol.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..3073cb6 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -262,8 +262,7 @@ int conf_read_simple(const char *name, int def)
 			goto load;
 		sym_add_change_count(1);
 		if (!sym_defconfig_list) {
-			if (modules_sym)
-				sym_calc_value(modules_sym);
+			sym_calc_value(modules_sym);
 			return 1;
 		}
 
@@ -399,8 +398,7 @@ setsym:
 	free(line);
 	fclose(in);
 
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 	return 0;
 }
 
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 7caabdb..3f7797b 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -447,8 +447,7 @@ void sym_clear_all_valid(void)
 	for_all_symbols(i, sym)
 		sym->flags &= ~SYMBOL_VALID;
 	sym_add_change_count(1);
-	if (modules_sym)
-		sym_calc_value(modules_sym);
+	sym_calc_value(modules_sym);
 }
 
 void sym_set_changed(struct symbol *sym)
-- 
2.1.3

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

* [Cocci] Are defensive checks treated differently in specific areas?
  2014-11-03 17:05                                         ` [Cocci] " Derek M Jones
  2014-11-03 17:32                                           ` Julia Lawall
@ 2014-11-03 21:30                                           ` SF Markus Elfring
  1 sibling, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-03 21:30 UTC (permalink / raw)
  To: cocci

>> The truth is I think that all these patches are bad and they make the
>> code harder to read.
> 
> I disagree, I think the code requires less effort to read without the
> if test.
> 
> A developer reading the code will wonder why kfree does not handle the
> case when its argument is NULL.  This takes effort.

Does it make a difference for you where such safety checks should be
finally placed in the source code?

Do you consider different assumptions for function implementations from
an operating system in comparison to user applications?

How much will corresponding expectations need adjustments with the
software evolution?

Regards,
Markus

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

* Re: [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls
  2014-11-02 15:12                                   ` SF Markus Elfring
  (?)
@ 2014-11-11  4:07                                     ` Bjorn Helgaas
  -1 siblings, 0 replies; 3633+ messages in thread
From: Bjorn Helgaas @ 2014-11-11  4:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Boris Ostrovsky, David Vrabel, Konrad Rzeszutek Wilk, Len Brown,
	Rafael J. Wysocki, linux-pci, linux-acpi, linux-kernel,
	xen-devel, kernel-janitors, trivial, Coccinelle

On Sun, Nov 02, 2014 at 04:12:30PM +0100, SF Markus Elfring wrote:
> The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test
> whether their argument is NULL and then return immediately. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to pci/misc for v3.19, thanks!

> ---
>  drivers/pci/pci-acpi.c     | 3 +--
>  drivers/pci/probe.c        | 3 +--
>  drivers/pci/search.c       | 3 +--
>  drivers/pci/xen-pcifront.c | 3 +--
>  4 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index 37263b0..a8fe5de 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
>  	pci_wakeup_event(pci_dev);
>  	pm_runtime_resume(&pci_dev->dev);
> 
> -	if (pci_dev->subordinate)
> -		pci_pme_wakeup_bus(pci_dev->subordinate);
> +	pci_pme_wakeup_bus(pci_dev->subordinate);
>  }
> 
>  /**
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 4170113..e93f16e 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev)
>  {
>  	struct pci_bus *pci_bus = to_pci_bus(dev);
> 
> -	if (pci_bus->bridge)
> -		put_device(pci_bus->bridge);
> +	put_device(pci_bus->bridge);
>  	pci_bus_remove_resources(pci_bus);
>  	pci_release_bus_of_node(pci_bus);
>  	kfree(pci_bus);
> diff --git a/drivers/pci/search.c b/drivers/pci/search.c
> index 827ad83..2d806bd 100644
> --- a/drivers/pci/search.c
> +++ b/drivers/pci/search.c
> @@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct
> pci_device_id *id,
>  			      match_pci_dev_by_id);
>  	if (dev)
>  		pdev = to_pci_dev(dev);
> -	if (from)
> -		pci_dev_put(from);
> +	pci_dev_put(from);
>  	return pdev;
>  }
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 53df39a..46664cc 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
>  	pcidev = pci_get_bus_and_slot(bus, devfn);
>  	if (!pcidev || !pcidev->driver) {
>  		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
> -		if (pcidev)
> -			pci_dev_put(pcidev);
> +		pci_dev_put(pcidev);
>  		return result;
>  	}
>  	pdrv = pcidev->driver;
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls
@ 2014-11-11  4:07                                     ` Bjorn Helgaas
  0 siblings, 0 replies; 3633+ messages in thread
From: Bjorn Helgaas @ 2014-11-11  4:07 UTC (permalink / raw)
  To: cocci

On Sun, Nov 02, 2014 at 04:12:30PM +0100, SF Markus Elfring wrote:
> The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test
> whether their argument is NULL and then return immediately. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to pci/misc for v3.19, thanks!

> ---
>  drivers/pci/pci-acpi.c     | 3 +--
>  drivers/pci/probe.c        | 3 +--
>  drivers/pci/search.c       | 3 +--
>  drivers/pci/xen-pcifront.c | 3 +--
>  4 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index 37263b0..a8fe5de 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
>  	pci_wakeup_event(pci_dev);
>  	pm_runtime_resume(&pci_dev->dev);
> 
> -	if (pci_dev->subordinate)
> -		pci_pme_wakeup_bus(pci_dev->subordinate);
> +	pci_pme_wakeup_bus(pci_dev->subordinate);
>  }
> 
>  /**
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 4170113..e93f16e 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev)
>  {
>  	struct pci_bus *pci_bus = to_pci_bus(dev);
> 
> -	if (pci_bus->bridge)
> -		put_device(pci_bus->bridge);
> +	put_device(pci_bus->bridge);
>  	pci_bus_remove_resources(pci_bus);
>  	pci_release_bus_of_node(pci_bus);
>  	kfree(pci_bus);
> diff --git a/drivers/pci/search.c b/drivers/pci/search.c
> index 827ad83..2d806bd 100644
> --- a/drivers/pci/search.c
> +++ b/drivers/pci/search.c
> @@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct
> pci_device_id *id,
>  			      match_pci_dev_by_id);
>  	if (dev)
>  		pdev = to_pci_dev(dev);
> -	if (from)
> -		pci_dev_put(from);
> +	pci_dev_put(from);
>  	return pdev;
>  }
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 53df39a..46664cc 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
>  	pcidev = pci_get_bus_and_slot(bus, devfn);
>  	if (!pcidev || !pcidev->driver) {
>  		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
> -		if (pcidev)
> -			pci_dev_put(pcidev);
> +		pci_dev_put(pcidev);
>  		return result;
>  	}
>  	pdrv = pcidev->driver;
> -- 
> 2.1.3
> 
> 

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

* [Cocci] [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls
@ 2014-11-11  4:07                                     ` Bjorn Helgaas
  0 siblings, 0 replies; 3633+ messages in thread
From: Bjorn Helgaas @ 2014-11-11  4:07 UTC (permalink / raw)
  To: cocci

On Sun, Nov 02, 2014 at 04:12:30PM +0100, SF Markus Elfring wrote:
> The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test
> whether their argument is NULL and then return immediately. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to pci/misc for v3.19, thanks!

> ---
>  drivers/pci/pci-acpi.c     | 3 +--
>  drivers/pci/probe.c        | 3 +--
>  drivers/pci/search.c       | 3 +--
>  drivers/pci/xen-pcifront.c | 3 +--
>  4 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index 37263b0..a8fe5de 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
>  	pci_wakeup_event(pci_dev);
>  	pm_runtime_resume(&pci_dev->dev);
> 
> -	if (pci_dev->subordinate)
> -		pci_pme_wakeup_bus(pci_dev->subordinate);
> +	pci_pme_wakeup_bus(pci_dev->subordinate);
>  }
> 
>  /**
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 4170113..e93f16e 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev)
>  {
>  	struct pci_bus *pci_bus = to_pci_bus(dev);
> 
> -	if (pci_bus->bridge)
> -		put_device(pci_bus->bridge);
> +	put_device(pci_bus->bridge);
>  	pci_bus_remove_resources(pci_bus);
>  	pci_release_bus_of_node(pci_bus);
>  	kfree(pci_bus);
> diff --git a/drivers/pci/search.c b/drivers/pci/search.c
> index 827ad83..2d806bd 100644
> --- a/drivers/pci/search.c
> +++ b/drivers/pci/search.c
> @@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct
> pci_device_id *id,
>  			      match_pci_dev_by_id);
>  	if (dev)
>  		pdev = to_pci_dev(dev);
> -	if (from)
> -		pci_dev_put(from);
> +	pci_dev_put(from);
>  	return pdev;
>  }
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 53df39a..46664cc 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
>  	pcidev = pci_get_bus_and_slot(bus, devfn);
>  	if (!pcidev || !pcidev->driver) {
>  		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
> -		if (pcidev)
> -			pci_dev_put(pcidev);
> +		pci_dev_put(pcidev);
>  		return result;
>  	}
>  	pdrv = pcidev->driver;
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls
  2014-11-02 15:12                                   ` SF Markus Elfring
                                                     ` (2 preceding siblings ...)
  (?)
@ 2014-11-11  4:07                                   ` Bjorn Helgaas
  -1 siblings, 0 replies; 3633+ messages in thread
From: Bjorn Helgaas @ 2014-11-11  4:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kernel-janitors, trivial, linux-pci, Rafael J. Wysocki,
	linux-kernel, linux-acpi, David Vrabel, xen-devel,
	Boris Ostrovsky, Coccinelle, Len Brown

On Sun, Nov 02, 2014 at 04:12:30PM +0100, SF Markus Elfring wrote:
> The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test
> whether their argument is NULL and then return immediately. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to pci/misc for v3.19, thanks!

> ---
>  drivers/pci/pci-acpi.c     | 3 +--
>  drivers/pci/probe.c        | 3 +--
>  drivers/pci/search.c       | 3 +--
>  drivers/pci/xen-pcifront.c | 3 +--
>  4 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index 37263b0..a8fe5de 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
>  	pci_wakeup_event(pci_dev);
>  	pm_runtime_resume(&pci_dev->dev);
> 
> -	if (pci_dev->subordinate)
> -		pci_pme_wakeup_bus(pci_dev->subordinate);
> +	pci_pme_wakeup_bus(pci_dev->subordinate);
>  }
> 
>  /**
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 4170113..e93f16e 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev)
>  {
>  	struct pci_bus *pci_bus = to_pci_bus(dev);
> 
> -	if (pci_bus->bridge)
> -		put_device(pci_bus->bridge);
> +	put_device(pci_bus->bridge);
>  	pci_bus_remove_resources(pci_bus);
>  	pci_release_bus_of_node(pci_bus);
>  	kfree(pci_bus);
> diff --git a/drivers/pci/search.c b/drivers/pci/search.c
> index 827ad83..2d806bd 100644
> --- a/drivers/pci/search.c
> +++ b/drivers/pci/search.c
> @@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct
> pci_device_id *id,
>  			      match_pci_dev_by_id);
>  	if (dev)
>  		pdev = to_pci_dev(dev);
> -	if (from)
> -		pci_dev_put(from);
> +	pci_dev_put(from);
>  	return pdev;
>  }
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 53df39a..46664cc 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd,
>  	pcidev = pci_get_bus_and_slot(bus, devfn);
>  	if (!pcidev || !pcidev->driver) {
>  		dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
> -		if (pcidev)
> -			pci_dev_put(pcidev);
> +		pci_dev_put(pcidev);
>  		return result;
>  	}
>  	pdrv = pcidev->driver;
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH with SmPL?] staging: rtl8188eu: Adjustments around jump labels
  2014-10-31 18:11                                             ` Julia Lawall
  (?)
@ 2014-11-12 10:51                                               ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 10:51 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Greg Kroah-Hartman, devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

>>>> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
>>>> _size_byte, u8  *pbuf)
>>>>  exit:
>>>>  	kfree(efuseTbl);
>>>>
>>>> -	if (eFuseWord)
>>>> -		kfree(eFuseWord);
>>>> +	kfree(eFuseWord);
>>>
>>> I think that this code has been updated already.  It would be better to
>>> add labels so that kfree is only executed when needed.
>>
>> Are there any chances to achieve the suggested fine-tuning for jump labels
>> also with another semantic patch approach?
> 
> No, I don't think so.  The pattern is not regular enough.

Now I have got a different impression for corresponding improvement possibilities.


elfring@Sonne:~/Projekte/Linux/stable-patched> spatch.opt -debug -sp-file ~/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci drivers/staging/rtl8188eu/core/rtw_efuse.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
-----------------------------------------------------------------------
processing semantic patch file: /home/elfring/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci
with isos from: /usr/local/share/coccinelle/standard.iso
-----------------------------------------------------------------------
@move_function_call_before_jump_label@
expression x;
identifier fu, label;
type t;
@@
 t fu(...)
 {
  ... when any
  x = kzalloc(...);
  if (x == NULL) {
     ...
     goto label;
  }
  ... when any
+    kfree(x);
  label:
-    kfree(x);
  ...
 }

HANDLING: drivers/staging/rtl8188eu/core/rtw_efuse.c
-----------------------------------------------------------------------
let's go
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
move_function_call_before_jump_label = 
-----------------------------------------------------------------------
dependencies for rule move_function_call_before_jump_label satisfied:
binding in = []
binding relevant in = []
     (ONCE) USING optional_storage builtin isomorphism
     transformation info returned:
          transform state: 5
               with rule_elem: 
                                 <<< kfree(move_function_call_before_jump_label:x);
                               move_function_call_before_jump_label:label:
               with binding: [move_function_call_before_jump_label.x --> efuseTbl]
          transform state: 204
               with rule_elem: -kfree-(-move_function_call_before_jump_label:x-)-;
               with binding: [move_function_call_before_jump_label.x --> efuseTbl]
     binding out = []
     transform one node: 204
     transform one node: 5
-----------------------------------------------------------------------
Finished
-----------------------------------------------------------------------
diff = 
--- drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ /tmp/cocci-output-4498-349827-rtw_efuse.c
@@ -209,8 +209,8 @@ efuse_phymap_to_logical(u8 *phymap, u16
        /*  5. Calculate Efuse utilization. */
        /*  */
 
+kfree(efuseTbl);
 exit:
-       kfree(efuseTbl);
 
        kfree(eFuseWord);
 }
Check duplication for 1 files



Can my update suggestion be generalised a bit more for the movement of specific jump labels
towards the end of a function implementation like in the use case "efuse_phymap_to_logical()"?

Regards,
Markus

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

* Re: [PATCH with SmPL?] staging: rtl8188eu: Adjustments around jump labels
@ 2014-11-12 10:51                                               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 10:51 UTC (permalink / raw)
  To: cocci

>>>> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
>>>> _size_byte, u8  *pbuf)
>>>>  exit:
>>>>  	kfree(efuseTbl);
>>>>
>>>> -	if (eFuseWord)
>>>> -		kfree(eFuseWord);
>>>> +	kfree(eFuseWord);
>>>
>>> I think that this code has been updated already.  It would be better to
>>> add labels so that kfree is only executed when needed.
>>
>> Are there any chances to achieve the suggested fine-tuning for jump labels
>> also with another semantic patch approach?
> 
> No, I don't think so.  The pattern is not regular enough.

Now I have got a different impression for corresponding improvement possibilities.


elfring@Sonne:~/Projekte/Linux/stable-patched> spatch.opt -debug -sp-file ~/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci drivers/staging/rtl8188eu/core/rtw_efuse.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
-----------------------------------------------------------------------
processing semantic patch file: /home/elfring/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci
with isos from: /usr/local/share/coccinelle/standard.iso
-----------------------------------------------------------------------
@move_function_call_before_jump_label@
expression x;
identifier fu, label;
type t;
@@
 t fu(...)
 {
  ... when any
  x = kzalloc(...);
  if (x = NULL) {
     ...
     goto label;
  }
  ... when any
+    kfree(x);
  label:
-    kfree(x);
  ...
 }

HANDLING: drivers/staging/rtl8188eu/core/rtw_efuse.c
-----------------------------------------------------------------------
let's go
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
move_function_call_before_jump_label = 
-----------------------------------------------------------------------
dependencies for rule move_function_call_before_jump_label satisfied:
binding in = []
binding relevant in = []
     (ONCE) USING optional_storage builtin isomorphism
     transformation info returned:
          transform state: 5
               with rule_elem: 
                                 <<< kfree(move_function_call_before_jump_label:x);
                               move_function_call_before_jump_label:label:
               with binding: [move_function_call_before_jump_label.x --> efuseTbl]
          transform state: 204
               with rule_elem: -kfree-(-move_function_call_before_jump_label:x-)-;
               with binding: [move_function_call_before_jump_label.x --> efuseTbl]
     binding out = []
     transform one node: 204
     transform one node: 5
-----------------------------------------------------------------------
Finished
-----------------------------------------------------------------------
diff = 
--- drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ /tmp/cocci-output-4498-349827-rtw_efuse.c
@@ -209,8 +209,8 @@ efuse_phymap_to_logical(u8 *phymap, u16
        /*  5. Calculate Efuse utilization. */
        /*  */
 
+kfree(efuseTbl);
 exit:
-       kfree(efuseTbl);
 
        kfree(eFuseWord);
 }
Check duplication for 1 files



Can my update suggestion be generalised a bit more for the movement of specific jump labels
towards the end of a function implementation like in the use case "efuse_phymap_to_logical()"?

Regards,
Markus

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

* [Cocci] [PATCH with SmPL?] staging: rtl8188eu: Adjustments around jump labels
@ 2014-11-12 10:51                                               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 10:51 UTC (permalink / raw)
  To: cocci

>>>> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
>>>> _size_byte, u8  *pbuf)
>>>>  exit:
>>>>  	kfree(efuseTbl);
>>>>
>>>> -	if (eFuseWord)
>>>> -		kfree(eFuseWord);
>>>> +	kfree(eFuseWord);
>>>
>>> I think that this code has been updated already.  It would be better to
>>> add labels so that kfree is only executed when needed.
>>
>> Are there any chances to achieve the suggested fine-tuning for jump labels
>> also with another semantic patch approach?
> 
> No, I don't think so.  The pattern is not regular enough.

Now I have got a different impression for corresponding improvement possibilities.


elfring at Sonne:~/Projekte/Linux/stable-patched> spatch.opt -debug -sp-file ~/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci drivers/staging/rtl8188eu/core/rtw_efuse.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
-----------------------------------------------------------------------
processing semantic patch file: /home/elfring/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci
with isos from: /usr/local/share/coccinelle/standard.iso
-----------------------------------------------------------------------
@move_function_call_before_jump_label@
expression x;
identifier fu, label;
type t;
@@
 t fu(...)
 {
  ... when any
  x = kzalloc(...);
  if (x == NULL) {
     ...
     goto label;
  }
  ... when any
+    kfree(x);
  label:
-    kfree(x);
  ...
 }

HANDLING: drivers/staging/rtl8188eu/core/rtw_efuse.c
-----------------------------------------------------------------------
let's go
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
move_function_call_before_jump_label = 
-----------------------------------------------------------------------
dependencies for rule move_function_call_before_jump_label satisfied:
binding in = []
binding relevant in = []
     (ONCE) USING optional_storage builtin isomorphism
     transformation info returned:
          transform state: 5
               with rule_elem: 
                                 <<< kfree(move_function_call_before_jump_label:x);
                               move_function_call_before_jump_label:label:
               with binding: [move_function_call_before_jump_label.x --> efuseTbl]
          transform state: 204
               with rule_elem: -kfree-(-move_function_call_before_jump_label:x-)-;
               with binding: [move_function_call_before_jump_label.x --> efuseTbl]
     binding out = []
     transform one node: 204
     transform one node: 5
-----------------------------------------------------------------------
Finished
-----------------------------------------------------------------------
diff = 
--- drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ /tmp/cocci-output-4498-349827-rtw_efuse.c
@@ -209,8 +209,8 @@ efuse_phymap_to_logical(u8 *phymap, u16
        /*  5. Calculate Efuse utilization. */
        /*  */
 
+kfree(efuseTbl);
 exit:
-       kfree(efuseTbl);
 
        kfree(eFuseWord);
 }
Check duplication for 1 files



Can my update suggestion be generalised a bit more for the movement of specific jump labels
towards the end of a function implementation like in the use case "efuse_phymap_to_logical()"?

Regards,
Markus

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

* [PATCH v2 0/2] staging: rtl8188eu: Deletion of a few unnecessary checks
  2014-10-31 18:01                                         ` Julia Lawall
  (?)
@ 2014-11-12 20:20                                           ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 20:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 12 Nov 2014 20:42:18 +0100

Another update suggestion was taken into account after patches were applied
from static source code analysis.

Markus Elfring (2):
  staging: rtl8188eu: Deletion of unnecessary checks before three
    function calls
  staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()

 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 13 ++++++++-----
 drivers/staging/rtl8188eu/core/rtw_mlme.c    |  3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c |  3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    |  6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  |  6 +++---
 5 files changed, 15 insertions(+), 16 deletions(-)

-- 
2.1.3



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

* [PATCH v2 0/2] staging: rtl8188eu: Deletion of a few unnecessary checks
@ 2014-11-12 20:20                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 20:20 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 12 Nov 2014 20:42:18 +0100

Another update suggestion was taken into account after patches were applied
from static source code analysis.

Markus Elfring (2):
  staging: rtl8188eu: Deletion of unnecessary checks before three
    function calls
  staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()

 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 13 ++++++++-----
 drivers/staging/rtl8188eu/core/rtw_mlme.c    |  3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c |  3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    |  6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  |  6 +++---
 5 files changed, 15 insertions(+), 16 deletions(-)

-- 
2.1.3



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

* [Cocci] [PATCH v2 0/2] staging: rtl8188eu: Deletion of a few unnecessary checks
@ 2014-11-12 20:20                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 20:20 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 12 Nov 2014 20:42:18 +0100

Another update suggestion was taken into account after patches were applied
from static source code analysis.

Markus Elfring (2):
  staging: rtl8188eu: Deletion of unnecessary checks before three
    function calls
  staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()

 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 13 ++++++++-----
 drivers/staging/rtl8188eu/core/rtw_mlme.c    |  3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c |  3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    |  6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  |  6 +++---
 5 files changed, 15 insertions(+), 16 deletions(-)

-- 
2.1.3

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

* [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-11-12 20:20                                           ` SF Markus Elfring
  (?)
@ 2014-11-12 20:25                                             ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 20:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 12 Nov 2014 20:25:49 +0100

The functions kfree(), rtw_free_netdev() and vfree() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 6 +++---
 5 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 5b997b2..697876b 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 exit:
 	kfree(efuseTbl);
 
-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(eFuseWord);
 }
 
 static void efuse_read_phymap_from_txpktbuf(
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 149c271..df54350 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 	rtw_free_mlme_priv_ie_data(pmlmepriv);
 
 	if (pmlmepriv) {
-		if (pmlmepriv->free_bss_buf)
-			vfree(pmlmepriv->free_bss_buf);
+		vfree(pmlmepriv->free_bss_buf);
 	}
 }
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index e1dc8fa..af1de9c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
 
 		rtw_mfree_sta_priv_lock(pstapriv);
 
-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
+		vfree(pstapriv->pallocated_stainfo_buf);
 	}
 
 	return _SUCCESS;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 639ace0..011c9cf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
 		pxmitbuf++;
 	}
 
-	if (pxmitpriv->pallocated_frame_buf)
-		vfree(pxmitpriv->pallocated_frame_buf);
+	vfree(pxmitpriv->pallocated_frame_buf);
 
-	if (pxmitpriv->pallocated_xmitbuf)
-		vfree(pxmitpriv->pallocated_xmitbuf);
+	vfree(pxmitpriv->pallocated_xmitbuf);
 
 	/*  free xmit extension buff */
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318..4e2c34b 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -456,8 +456,9 @@ free_adapter:
 	if (status != _SUCCESS) {
 		if (pnetdev)
 			rtw_free_netdev(pnetdev);
-		else if (padapter)
+		else
 			vfree(padapter);
+
 		padapter = NULL;
 	}
 exit:
@@ -487,8 +488,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
 	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
 		if1->hw_init_completed);
 	rtw_free_drv_sw(if1);
-	if (pnetdev)
-		rtw_free_netdev(pnetdev);
+	rtw_free_netdev(pnetdev);
 }
 
 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
-- 
2.1.3



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

* [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 20:25                                             ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 20:25 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 12 Nov 2014 20:25:49 +0100

The functions kfree(), rtw_free_netdev() and vfree() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 6 +++---
 5 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 5b997b2..697876b 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 exit:
 	kfree(efuseTbl);
 
-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(eFuseWord);
 }
 
 static void efuse_read_phymap_from_txpktbuf(
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 149c271..df54350 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 	rtw_free_mlme_priv_ie_data(pmlmepriv);
 
 	if (pmlmepriv) {
-		if (pmlmepriv->free_bss_buf)
-			vfree(pmlmepriv->free_bss_buf);
+		vfree(pmlmepriv->free_bss_buf);
 	}
 }
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index e1dc8fa..af1de9c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
 
 		rtw_mfree_sta_priv_lock(pstapriv);
 
-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
+		vfree(pstapriv->pallocated_stainfo_buf);
 	}
 
 	return _SUCCESS;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 639ace0..011c9cf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
 		pxmitbuf++;
 	}
 
-	if (pxmitpriv->pallocated_frame_buf)
-		vfree(pxmitpriv->pallocated_frame_buf);
+	vfree(pxmitpriv->pallocated_frame_buf);
 
-	if (pxmitpriv->pallocated_xmitbuf)
-		vfree(pxmitpriv->pallocated_xmitbuf);
+	vfree(pxmitpriv->pallocated_xmitbuf);
 
 	/*  free xmit extension buff */
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318..4e2c34b 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -456,8 +456,9 @@ free_adapter:
 	if (status != _SUCCESS) {
 		if (pnetdev)
 			rtw_free_netdev(pnetdev);
-		else if (padapter)
+		else
 			vfree(padapter);
+
 		padapter = NULL;
 	}
 exit:
@@ -487,8 +488,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
 	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
 		if1->hw_init_completed);
 	rtw_free_drv_sw(if1);
-	if (pnetdev)
-		rtw_free_netdev(pnetdev);
+	rtw_free_netdev(pnetdev);
 }
 
 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
-- 
2.1.3



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

* [Cocci] [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 20:25                                             ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 20:25 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 12 Nov 2014 20:25:49 +0100

The functions kfree(), rtw_free_netdev() and vfree() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
 drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 6 +++---
 5 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 5b997b2..697876b 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 exit:
 	kfree(efuseTbl);
 
-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(eFuseWord);
 }
 
 static void efuse_read_phymap_from_txpktbuf(
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 149c271..df54350 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -122,8 +122,7 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 	rtw_free_mlme_priv_ie_data(pmlmepriv);
 
 	if (pmlmepriv) {
-		if (pmlmepriv->free_bss_buf)
-			vfree(pmlmepriv->free_bss_buf);
+		vfree(pmlmepriv->free_bss_buf);
 	}
 }
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index e1dc8fa..af1de9c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -201,8 +201,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
 
 		rtw_mfree_sta_priv_lock(pstapriv);
 
-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
+		vfree(pstapriv->pallocated_stainfo_buf);
 	}
 
 	return _SUCCESS;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 639ace0..011c9cf 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -246,11 +246,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
 		pxmitbuf++;
 	}
 
-	if (pxmitpriv->pallocated_frame_buf)
-		vfree(pxmitpriv->pallocated_frame_buf);
+	vfree(pxmitpriv->pallocated_frame_buf);
 
-	if (pxmitpriv->pallocated_xmitbuf)
-		vfree(pxmitpriv->pallocated_xmitbuf);
+	vfree(pxmitpriv->pallocated_xmitbuf);
 
 	/*  free xmit extension buff */
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318..4e2c34b 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -456,8 +456,9 @@ free_adapter:
 	if (status != _SUCCESS) {
 		if (pnetdev)
 			rtw_free_netdev(pnetdev);
-		else if (padapter)
+		else
 			vfree(padapter);
+
 		padapter = NULL;
 	}
 exit:
@@ -487,8 +488,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
 	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
 		if1->hw_init_completed);
 	rtw_free_drv_sw(if1);
-	if (pnetdev)
-		rtw_free_netdev(pnetdev);
+	rtw_free_netdev(pnetdev);
 }
 
 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
-- 
2.1.3

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

* [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
  2014-11-12 20:20                                           ` SF Markus Elfring
  (?)
@ 2014-11-12 20:30                                             ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 20:30 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 12 Nov 2014 20:40:12 +0100

Memory releases were handled in an inefficient way by the implementation of
the efuse_phymap_to_logical() function in case of an allocation failure.
The corresponding clean-up was improved by reordering of kfree() calls
and a few adjustments for jump labels.

Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 697876b..359f169 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -112,7 +112,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 	eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
 	if (eFuseWord == NULL) {
 		DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
-		goto exit;
+		goto cleanup1;
 	}
 
 	/*  0. Refresh efuse init map as all oxFF. */
@@ -130,7 +130,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 		eFuse_Addr++;
 	} else {
 		DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, rtemp8);
-		goto exit;
+		goto cleanup2;
 	}
 
 	/*  */
@@ -209,10 +209,14 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 	/*  5. Calculate Efuse utilization. */
 	/*  */
 
-exit:
+cleanup2:
+	kfree(eFuseWord);
+
+cleanup1:
 	kfree(efuseTbl);
 
-	kfree(eFuseWord);
+exit:
+	;
 }
 
 static void efuse_read_phymap_from_txpktbuf(
-- 
2.1.3



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

* [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-12 20:30                                             ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 20:30 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 12 Nov 2014 20:40:12 +0100

Memory releases were handled in an inefficient way by the implementation of
the efuse_phymap_to_logical() function in case of an allocation failure.
The corresponding clean-up was improved by reordering of kfree() calls
and a few adjustments for jump labels.

Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 697876b..359f169 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -112,7 +112,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 	eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
 	if (eFuseWord = NULL) {
 		DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
-		goto exit;
+		goto cleanup1;
 	}
 
 	/*  0. Refresh efuse init map as all oxFF. */
@@ -130,7 +130,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 		eFuse_Addr++;
 	} else {
 		DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, rtemp8);
-		goto exit;
+		goto cleanup2;
 	}
 
 	/*  */
@@ -209,10 +209,14 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 	/*  5. Calculate Efuse utilization. */
 	/*  */
 
-exit:
+cleanup2:
+	kfree(eFuseWord);
+
+cleanup1:
 	kfree(efuseTbl);
 
-	kfree(eFuseWord);
+exit:
+	;
 }
 
 static void efuse_read_phymap_from_txpktbuf(
-- 
2.1.3



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

* [Cocci] [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-12 20:30                                             ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 20:30 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 12 Nov 2014 20:40:12 +0100

Memory releases were handled in an inefficient way by the implementation of
the efuse_phymap_to_logical() function in case of an allocation failure.
The corresponding clean-up was improved by reordering of kfree() calls
and a few adjustments for jump labels.

Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 697876b..359f169 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -112,7 +112,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 	eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
 	if (eFuseWord == NULL) {
 		DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
-		goto exit;
+		goto cleanup1;
 	}
 
 	/*  0. Refresh efuse init map as all oxFF. */
@@ -130,7 +130,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 		eFuse_Addr++;
 	} else {
 		DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, rtemp8);
-		goto exit;
+		goto cleanup2;
 	}
 
 	/*  */
@@ -209,10 +209,14 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 	/*  5. Calculate Efuse utilization. */
 	/*  */
 
-exit:
+cleanup2:
+	kfree(eFuseWord);
+
+cleanup1:
 	kfree(efuseTbl);
 
-	kfree(eFuseWord);
+exit:
+	;
 }
 
 static void efuse_read_phymap_from_txpktbuf(
-- 
2.1.3

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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
  2014-11-12 20:30                                             ` SF Markus Elfring
  (?)
@ 2014-11-12 21:14                                               ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 21:14 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, devel, trivial, kernel-janitors,
	linux-kernel, Coccinelle

On Wed, Nov 12, 2014 at 09:30:43PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>

Please fix your email client instead.

> +		goto cleanup1;

1) Don't use GW-BASIC label names.  Label names should reflect what the
label does such as free_fuse_word or free_fuse_tabel.

2) Don't use do-nothing labels.  Just return directly.

regards,
dan carpenter


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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-12 21:14                                               ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 21:14 UTC (permalink / raw)
  To: cocci

On Wed, Nov 12, 2014 at 09:30:43PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>

Please fix your email client instead.

> +		goto cleanup1;

1) Don't use GW-BASIC label names.  Label names should reflect what the
label does such as free_fuse_word or free_fuse_tabel.

2) Don't use do-nothing labels.  Just return directly.

regards,
dan carpenter


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

* [Cocci] [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-12 21:14                                               ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 21:14 UTC (permalink / raw)
  To: cocci

On Wed, Nov 12, 2014 at 09:30:43PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>

Please fix your email client instead.

> +		goto cleanup1;

1) Don't use GW-BASIC label names.  Label names should reflect what the
label does such as free_fuse_word or free_fuse_tabel.

2) Don't use do-nothing labels.  Just return directly.

regards,
dan carpenter

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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-11-12 20:25                                             ` SF Markus Elfring
  (?)
@ 2014-11-12 21:18                                               ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 21:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, devel, trivial, kernel-janitors,
	linux-kernel, Coccinelle

On Wed, Nov 12, 2014 at 09:25:15PM +0100, SF Markus Elfring wrote:
> @@ -487,8 +488,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>  	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
>  		if1->hw_init_completed);
>  	rtw_free_drv_sw(if1);
> -	if (pnetdev)
> -		rtw_free_netdev(pnetdev);
> +	rtw_free_netdev(pnetdev);

I still feel that hiding the if statement inside the function call makes
the code more subtle and it is a bad harmful thing to do.  This is
especially true if you have trained yourself to know that free_netdev()
can't accept NULL pointers.

regards,
dan carpenter


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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 21:18                                               ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 21:18 UTC (permalink / raw)
  To: cocci

On Wed, Nov 12, 2014 at 09:25:15PM +0100, SF Markus Elfring wrote:
> @@ -487,8 +488,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>  	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
>  		if1->hw_init_completed);
>  	rtw_free_drv_sw(if1);
> -	if (pnetdev)
> -		rtw_free_netdev(pnetdev);
> +	rtw_free_netdev(pnetdev);

I still feel that hiding the if statement inside the function call makes
the code more subtle and it is a bad harmful thing to do.  This is
especially true if you have trained yourself to know that free_netdev()
can't accept NULL pointers.

regards,
dan carpenter


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

* [Cocci] [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 21:18                                               ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 21:18 UTC (permalink / raw)
  To: cocci

On Wed, Nov 12, 2014 at 09:25:15PM +0100, SF Markus Elfring wrote:
> @@ -487,8 +488,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>  	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
>  		if1->hw_init_completed);
>  	rtw_free_drv_sw(if1);
> -	if (pnetdev)
> -		rtw_free_netdev(pnetdev);
> +	rtw_free_netdev(pnetdev);

I still feel that hiding the if statement inside the function call makes
the code more subtle and it is a bad harmful thing to do.  This is
especially true if you have trained yourself to know that free_netdev()
can't accept NULL pointers.

regards,
dan carpenter

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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-11-12 21:18                                               ` Dan Carpenter
  (?)
@ 2014-11-12 21:28                                                 ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 21:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, devel, trivial, kernel-janitors,
	linux-kernel, Coccinelle

>> @@ -487,8 +488,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>>  	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
>>  		if1->hw_init_completed);
>>  	rtw_free_drv_sw(if1);
>> -	if (pnetdev)
>> -		rtw_free_netdev(pnetdev);
>> +	rtw_free_netdev(pnetdev);
> 
> I still feel that hiding the if statement inside the function call makes
> the code more subtle and it is a bad harmful thing to do.

I find your feedback interesting.


> This is especially true if you have trained yourself to know that
> free_netdev() can't accept NULL pointers.

Do you need to adjust your concerns a bit over time when function variants
provide a corresponding safety check in their implementations?

Regards,
Markus

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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 21:28                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 21:28 UTC (permalink / raw)
  To: cocci

>> @@ -487,8 +488,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>>  	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
>>  		if1->hw_init_completed);
>>  	rtw_free_drv_sw(if1);
>> -	if (pnetdev)
>> -		rtw_free_netdev(pnetdev);
>> +	rtw_free_netdev(pnetdev);
> 
> I still feel that hiding the if statement inside the function call makes
> the code more subtle and it is a bad harmful thing to do.

I find your feedback interesting.


> This is especially true if you have trained yourself to know that
> free_netdev() can't accept NULL pointers.

Do you need to adjust your concerns a bit over time when function variants
provide a corresponding safety check in their implementations?

Regards,
Markus

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

* [Cocci] [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 21:28                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 21:28 UTC (permalink / raw)
  To: cocci

>> @@ -487,8 +488,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
>>  	DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
>>  		if1->hw_init_completed);
>>  	rtw_free_drv_sw(if1);
>> -	if (pnetdev)
>> -		rtw_free_netdev(pnetdev);
>> +	rtw_free_netdev(pnetdev);
> 
> I still feel that hiding the if statement inside the function call makes
> the code more subtle and it is a bad harmful thing to do.

I find your feedback interesting.


> This is especially true if you have trained yourself to know that
> free_netdev() can't accept NULL pointers.

Do you need to adjust your concerns a bit over time when function variants
provide a corresponding safety check in their implementations?

Regards,
Markus

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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-11-12 21:28                                                 ` SF Markus Elfring
  (?)
@ 2014-11-12 21:40                                                   ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-12 21:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, Greg Kroah-Hartman, devel, trivial,
	kernel-janitors, linux-kernel, Coccinelle

> > This is especially true if you have trained yourself to know that
> > free_netdev() can't accept NULL pointers.
> 
> Do you need to adjust your concerns a bit over time when function variants
> provide a corresponding safety check in their implementations?

There would not seem to be any _need_ to do so.  An unnecessary null test 
is always safe.  The only real problem that I can see with an unnecessary 
null test in error handling code (intrinsically not critical performance 
wise) is if it gives the illusion that a value can be null when it cannot.

julia

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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 21:40                                                   ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-12 21:40 UTC (permalink / raw)
  To: cocci

> > This is especially true if you have trained yourself to know that
> > free_netdev() can't accept NULL pointers.
> 
> Do you need to adjust your concerns a bit over time when function variants
> provide a corresponding safety check in their implementations?

There would not seem to be any _need_ to do so.  An unnecessary null test 
is always safe.  The only real problem that I can see with an unnecessary 
null test in error handling code (intrinsically not critical performance 
wise) is if it gives the illusion that a value can be null when it cannot.

julia

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

* [Cocci] [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 21:40                                                   ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-12 21:40 UTC (permalink / raw)
  To: cocci

> > This is especially true if you have trained yourself to know that
> > free_netdev() can't accept NULL pointers.
> 
> Do you need to adjust your concerns a bit over time when function variants
> provide a corresponding safety check in their implementations?

There would not seem to be any _need_ to do so.  An unnecessary null test 
is always safe.  The only real problem that I can see with an unnecessary 
null test in error handling code (intrinsically not critical performance 
wise) is if it gives the illusion that a value can be null when it cannot.

julia

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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
  2014-11-12 21:14                                               ` Dan Carpenter
  (?)
@ 2014-11-12 21:50                                                 ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 21:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, devel, trivial, kernel-janitors,
	linux-kernel, Coccinelle

>> +		goto cleanup1;
> 
> 1) Don't use GW-BASIC label names.  Label names should reflect what the
> label does such as free_fuse_word or free_fuse_tabel.
> 
> 2) Don't use do-nothing labels.  Just return directly.

Does the document "CodingStyle" need any extensions for special cases?
Are there any update candidates in the chapter "7: Centralized exiting of functions"?

Regards,
Markus

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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-12 21:50                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 21:50 UTC (permalink / raw)
  To: cocci

>> +		goto cleanup1;
> 
> 1) Don't use GW-BASIC label names.  Label names should reflect what the
> label does such as free_fuse_word or free_fuse_tabel.
> 
> 2) Don't use do-nothing labels.  Just return directly.

Does the document "CodingStyle" need any extensions for special cases?
Are there any update candidates in the chapter "7: Centralized exiting of functions"?

Regards,
Markus

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

* [Cocci] [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-12 21:50                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-12 21:50 UTC (permalink / raw)
  To: cocci

>> +		goto cleanup1;
> 
> 1) Don't use GW-BASIC label names.  Label names should reflect what the
> label does such as free_fuse_word or free_fuse_tabel.
> 
> 2) Don't use do-nothing labels.  Just return directly.

Does the document "CodingStyle" need any extensions for special cases?
Are there any update candidates in the chapter "7: Centralized exiting of functions"?

Regards,
Markus

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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
  2014-11-12 21:50                                                 ` SF Markus Elfring
  (?)
@ 2014-11-12 22:05                                                   ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 22:05 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, devel, trivial, kernel-janitors,
	linux-kernel, Coccinelle

On Wed, Nov 12, 2014 at 10:50:37PM +0100, SF Markus Elfring wrote:
> >> +		goto cleanup1;
> > 
> > 1) Don't use GW-BASIC label names.  Label names should reflect what the
> > label does such as free_fuse_word or free_fuse_tabel.
> > 
> > 2) Don't use do-nothing labels.  Just return directly.
> 
> Does the document "CodingStyle" need any extensions for special cases?

I don't understand.

> Are there any update candidates in the chapter "7: Centralized exiting of functions"?

CodingStyle says:

"If there is no cleanup needed then just return directly."

What is not clear about that?

regards,
dan carpenter


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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-12 22:05                                                   ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 22:05 UTC (permalink / raw)
  To: cocci

On Wed, Nov 12, 2014 at 10:50:37PM +0100, SF Markus Elfring wrote:
> >> +		goto cleanup1;
> > 
> > 1) Don't use GW-BASIC label names.  Label names should reflect what the
> > label does such as free_fuse_word or free_fuse_tabel.
> > 
> > 2) Don't use do-nothing labels.  Just return directly.
> 
> Does the document "CodingStyle" need any extensions for special cases?

I don't understand.

> Are there any update candidates in the chapter "7: Centralized exiting of functions"?

CodingStyle says:

"If there is no cleanup needed then just return directly."

What is not clear about that?

regards,
dan carpenter


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

* [Cocci] [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-12 22:05                                                   ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 22:05 UTC (permalink / raw)
  To: cocci

On Wed, Nov 12, 2014 at 10:50:37PM +0100, SF Markus Elfring wrote:
> >> +		goto cleanup1;
> > 
> > 1) Don't use GW-BASIC label names.  Label names should reflect what the
> > label does such as free_fuse_word or free_fuse_tabel.
> > 
> > 2) Don't use do-nothing labels.  Just return directly.
> 
> Does the document "CodingStyle" need any extensions for special cases?

I don't understand.

> Are there any update candidates in the chapter "7: Centralized exiting of functions"?

CodingStyle says:

"If there is no cleanup needed then just return directly."

What is not clear about that?

regards,
dan carpenter

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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-11-12 21:28                                                 ` SF Markus Elfring
  (?)
@ 2014-11-12 22:08                                                   ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 22:08 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, devel, trivial, kernel-janitors,
	linux-kernel, Coccinelle

On Wed, Nov 12, 2014 at 10:28:41PM +0100, SF Markus Elfring wrote:
> > This is especially true if you have trained yourself to know that
> > free_netdev() can't accept NULL pointers.
> 
> Do you need to adjust your concerns a bit over time when function variants
> provide a corresponding safety check in their implementations?

No.  Really, free_netdev vs rtw_free_netdev is just an example where it
is really bad, but I feel that all of these patches are misguided and
harmful.

We should have an if statement if the allocation is optional, we should
not have an if statement if the allocation is required.

regards,
dan carpenter


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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 22:08                                                   ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 22:08 UTC (permalink / raw)
  To: cocci

On Wed, Nov 12, 2014 at 10:28:41PM +0100, SF Markus Elfring wrote:
> > This is especially true if you have trained yourself to know that
> > free_netdev() can't accept NULL pointers.
> 
> Do you need to adjust your concerns a bit over time when function variants
> provide a corresponding safety check in their implementations?

No.  Really, free_netdev vs rtw_free_netdev is just an example where it
is really bad, but I feel that all of these patches are misguided and
harmful.

We should have an if statement if the allocation is optional, we should
not have an if statement if the allocation is required.

regards,
dan carpenter


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

* [Cocci] [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-12 22:08                                                   ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-12 22:08 UTC (permalink / raw)
  To: cocci

On Wed, Nov 12, 2014 at 10:28:41PM +0100, SF Markus Elfring wrote:
> > This is especially true if you have trained yourself to know that
> > free_netdev() can't accept NULL pointers.
> 
> Do you need to adjust your concerns a bit over time when function variants
> provide a corresponding safety check in their implementations?

No.  Really, free_netdev vs rtw_free_netdev is just an example where it
is really bad, but I feel that all of these patches are misguided and
harmful.

We should have an if statement if the allocation is optional, we should
not have an if statement if the allocation is required.

regards,
dan carpenter

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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
  2014-11-12 20:30                                             ` SF Markus Elfring
  (?)
@ 2014-11-13  8:43                                               ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-13  8:43 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 697876b..359f169 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
[...]
> -exit:
> +cleanup2:
> +	kfree(eFuseWord);
> +
> +cleanup1:
>  	kfree(efuseTbl);
>
> -	kfree(eFuseWord);
> +exit:
> +	;
>  }

You are not using the most recent version of the code.  The issue has
already been fixed. Concretely, this part of the function now reads:

exit:
        kfree(eFuseWord);

eFuseWord_failed:
	kfree(efuseTbl);

julia

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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-13  8:43                                               ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-13  8:43 UTC (permalink / raw)
  To: cocci

> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 697876b..359f169 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
[...]
> -exit:
> +cleanup2:
> +	kfree(eFuseWord);
> +
> +cleanup1:
>  	kfree(efuseTbl);
>
> -	kfree(eFuseWord);
> +exit:
> +	;
>  }

You are not using the most recent version of the code.  The issue has
already been fixed. Concretely, this part of the function now reads:

exit:
        kfree(eFuseWord);

eFuseWord_failed:
	kfree(efuseTbl);

julia

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

* [Cocci] [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-13  8:43                                               ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-13  8:43 UTC (permalink / raw)
  To: cocci

> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 697876b..359f169 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
[...]
> -exit:
> +cleanup2:
> +	kfree(eFuseWord);
> +
> +cleanup1:
>  	kfree(efuseTbl);
>
> -	kfree(eFuseWord);
> +exit:
> +	;
>  }

You are not using the most recent version of the code.  The issue has
already been fixed. Concretely, this part of the function now reads:

exit:
        kfree(eFuseWord);

eFuseWord_failed:
	kfree(efuseTbl);

julia

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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
  2014-11-12 20:25                                             ` SF Markus Elfring
  (?)
@ 2014-11-13  8:47                                               ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-13  8:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle



On Wed, 12 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 12 Nov 2014 20:25:49 +0100
>
> The functions kfree(), rtw_free_netdev() and vfree() test whether their
> argument is NULL and then return immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 6 +++---
>  5 files changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 5b997b2..697876b 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
>  exit:
>  	kfree(efuseTbl);
>
> -	if (eFuseWord)
> -		kfree(eFuseWord);
> +	kfree(eFuseWord);
>  }

As far as I can tell, the 2/2 patch in this series proposes a completely
different fix for this code.  When you send a series, patch n+1/m is
supposed to apply to the result of patch n/m.

In any case, you can let this one go, because the problem has been fixed
already.

julia

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

* Re: [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-13  8:47                                               ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-13  8:47 UTC (permalink / raw)
  To: cocci



On Wed, 12 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 12 Nov 2014 20:25:49 +0100
>
> The functions kfree(), rtw_free_netdev() and vfree() test whether their
> argument is NULL and then return immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 6 +++---
>  5 files changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 5b997b2..697876b 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
>  exit:
>  	kfree(efuseTbl);
>
> -	if (eFuseWord)
> -		kfree(eFuseWord);
> +	kfree(eFuseWord);
>  }

As far as I can tell, the 2/2 patch in this series proposes a completely
different fix for this code.  When you send a series, patch n+1/m is
supposed to apply to the result of patch n/m.

In any case, you can let this one go, because the problem has been fixed
already.

julia

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

* [Cocci] [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls
@ 2014-11-13  8:47                                               ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-13  8:47 UTC (permalink / raw)
  To: cocci



On Wed, 12 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 12 Nov 2014 20:25:49 +0100
>
> The functions kfree(), rtw_free_netdev() and vfree() test whether their
> argument is NULL and then return immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/staging/rtl8188eu/core/rtw_efuse.c   | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_mlme.c    | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 3 +--
>  drivers/staging/rtl8188eu/core/rtw_xmit.c    | 6 ++----
>  drivers/staging/rtl8188eu/os_dep/usb_intf.c  | 6 +++---
>  5 files changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 5b997b2..697876b 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
>  exit:
>  	kfree(efuseTbl);
>
> -	if (eFuseWord)
> -		kfree(eFuseWord);
> +	kfree(eFuseWord);
>  }

As far as I can tell, the 2/2 patch in this series proposes a completely
different fix for this code.  When you send a series, patch n+1/m is
supposed to apply to the result of patch n/m.

In any case, you can let this one go, because the problem has been fixed
already.

julia

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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
  2014-11-12 22:05                                                   ` Dan Carpenter
  (?)
@ 2014-11-13  8:50                                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-13  8:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, devel, trivial, kernel-janitors,
	linux-kernel, Coccinelle

>>>> +		goto cleanup1;
>>>
>>> 1) Don't use GW-BASIC label names.  Label names should reflect what the
>>> label does such as free_fuse_word or free_fuse_tabel.
>>>
>>> 2) Don't use do-nothing labels.  Just return directly.
>>
>> Does the document "CodingStyle" need any extensions for special cases?
> 
> I don't understand.

Should the naming convention become more explicit for jump labels?


> CodingStyle says:
> 
> "If there is no cleanup needed then just return directly."

Do you want that I send another update suggestion with other corrections
for jump labels in the affected function implementation?

Regards,
Markus


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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-13  8:50                                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-13  8:50 UTC (permalink / raw)
  To: cocci

>>>> +		goto cleanup1;
>>>
>>> 1) Don't use GW-BASIC label names.  Label names should reflect what the
>>> label does such as free_fuse_word or free_fuse_tabel.
>>>
>>> 2) Don't use do-nothing labels.  Just return directly.
>>
>> Does the document "CodingStyle" need any extensions for special cases?
> 
> I don't understand.

Should the naming convention become more explicit for jump labels?


> CodingStyle says:
> 
> "If there is no cleanup needed then just return directly."

Do you want that I send another update suggestion with other corrections
for jump labels in the affected function implementation?

Regards,
Markus


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

* [Cocci] [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-13  8:50                                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-13  8:50 UTC (permalink / raw)
  To: cocci

>>>> +		goto cleanup1;
>>>
>>> 1) Don't use GW-BASIC label names.  Label names should reflect what the
>>> label does such as free_fuse_word or free_fuse_tabel.
>>>
>>> 2) Don't use do-nothing labels.  Just return directly.
>>
>> Does the document "CodingStyle" need any extensions for special cases?
> 
> I don't understand.

Should the naming convention become more explicit for jump labels?


> CodingStyle says:
> 
> "If there is no cleanup needed then just return directly."

Do you want that I send another update suggestion with other corrections
for jump labels in the affected function implementation?

Regards,
Markus

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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
  2014-11-13  8:43                                               ` Julia Lawall
  (?)
@ 2014-11-13  9:33                                                 ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-13  9:33 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Greg Kroah-Hartman, devel, linux-kernel, kernel-janitors,
	trivial, Coccinelle

> You are not using the most recent version of the code.  The issue has
> already been fixed.

Thanks for your reminder.

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/staging/rtl8188eu/core/rtw_efuse.c?id=3cfab18ce55282a85e2c7e5db15c5daf065efdb4

Regards,
Markus

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

* Re: [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-13  9:33                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-13  9:33 UTC (permalink / raw)
  To: cocci

> You are not using the most recent version of the code.  The issue has
> already been fixed.

Thanks for your reminder.

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/staging/rtl8188eu/core/rtw_efuse.c?id<fab18ce55282a85e2c7e5db15c5daf065efdb4

Regards,
Markus

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

* [Cocci] [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical()
@ 2014-11-13  9:33                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-13  9:33 UTC (permalink / raw)
  To: cocci

> You are not using the most recent version of the code.  The issue has
> already been fixed.

Thanks for your reminder.

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/staging/rtl8188eu/core/rtw_efuse.c?id=3cfab18ce55282a85e2c7e5db15c5daf065efdb4

Regards,
Markus

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

* [PATCH 1/1] fs-ext4: Deletion of an unnecessary check before the function call "iput"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-15 18:19                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 18:19 UTC (permalink / raw)
  To: Andreas Dilger, Theodore Ts'o, linux-ext4
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 19:04:06 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ext4/mballoc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 8b0f9ef..e1a2521 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2712,8 +2712,7 @@ int ext4_mb_release(struct super_block *sb)
 	}
 	kfree(sbi->s_mb_offsets);
 	kfree(sbi->s_mb_maxs);
-	if (sbi->s_buddy_cache)
-		iput(sbi->s_buddy_cache);
+	iput(sbi->s_buddy_cache);
 	if (sbi->s_mb_stats) {
 		ext4_msg(sb, KERN_INFO,
 		       "mballoc: %u blocks %u reqs (%u success)",
-- 
2.1.3



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

* [PATCH 1/1] fs-ext4: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-15 18:19                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 18:19 UTC (permalink / raw)
  To: Andreas Dilger, Theodore Ts'o, linux-ext4
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 19:04:06 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ext4/mballoc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 8b0f9ef..e1a2521 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2712,8 +2712,7 @@ int ext4_mb_release(struct super_block *sb)
 	}
 	kfree(sbi->s_mb_offsets);
 	kfree(sbi->s_mb_maxs);
-	if (sbi->s_buddy_cache)
-		iput(sbi->s_buddy_cache);
+	iput(sbi->s_buddy_cache);
 	if (sbi->s_mb_stats) {
 		ext4_msg(sb, KERN_INFO,
 		       "mballoc: %u blocks %u reqs (%u success)",
-- 
2.1.3



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

* [PATCH 1/1] fs-ext4: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-15 18:19                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 18:19 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 19:04:06 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ext4/mballoc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 8b0f9ef..e1a2521 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2712,8 +2712,7 @@ int ext4_mb_release(struct super_block *sb)
 	}
 	kfree(sbi->s_mb_offsets);
 	kfree(sbi->s_mb_maxs);
-	if (sbi->s_buddy_cache)
-		iput(sbi->s_buddy_cache);
+	iput(sbi->s_buddy_cache);
 	if (sbi->s_mb_stats) {
 		ext4_msg(sb, KERN_INFO,
 		       "mballoc: %u blocks %u reqs (%u success)",
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] fs-ext4: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-15 18:19                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 18:19 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 19:04:06 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ext4/mballoc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 8b0f9ef..e1a2521 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2712,8 +2712,7 @@ int ext4_mb_release(struct super_block *sb)
 	}
 	kfree(sbi->s_mb_offsets);
 	kfree(sbi->s_mb_maxs);
-	if (sbi->s_buddy_cache)
-		iput(sbi->s_buddy_cache);
+	iput(sbi->s_buddy_cache);
 	if (sbi->s_mb_stats) {
 		ext4_msg(sb, KERN_INFO,
 		       "mballoc: %u blocks %u reqs (%u success)",
-- 
2.1.3

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

* [PATCH 1/1] ntfs: Deletion of unnecessary checks before the function call "iput"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-15 18:42                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 18:42 UTC (permalink / raw)
  To: Anton Altaparmakov, linux-ntfs-dev
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 19:35:05 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ntfs/super.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 6c3296e..8f22a47 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -2204,17 +2204,12 @@ get_ctx_vol_failed:
 	return true;
 #ifdef NTFS_RW
 iput_usnjrnl_err_out:
-	if (vol->usnjrnl_j_ino)
-		iput(vol->usnjrnl_j_ino);
-	if (vol->usnjrnl_max_ino)
-		iput(vol->usnjrnl_max_ino);
-	if (vol->usnjrnl_ino)
-		iput(vol->usnjrnl_ino);
+	iput(vol->usnjrnl_j_ino);
+	iput(vol->usnjrnl_max_ino);
+	iput(vol->usnjrnl_ino);
 iput_quota_err_out:
-	if (vol->quota_q_ino)
-		iput(vol->quota_q_ino);
-	if (vol->quota_ino)
-		iput(vol->quota_ino);
+	iput(vol->quota_q_ino);
+	iput(vol->quota_ino);
 	iput(vol->extend_ino);
 #endif /* NTFS_RW */
 iput_sec_err_out:
@@ -2223,8 +2218,7 @@ iput_root_err_out:
 	iput(vol->root_ino);
 iput_logfile_err_out:
 #ifdef NTFS_RW
-	if (vol->logfile_ino)
-		iput(vol->logfile_ino);
+	iput(vol->logfile_ino);
 iput_vol_err_out:
 #endif /* NTFS_RW */
 	iput(vol->vol_ino);
@@ -2254,8 +2248,7 @@ iput_mftbmp_err_out:
 	iput(vol->mftbmp_ino);
 iput_mirr_err_out:
 #ifdef NTFS_RW
-	if (vol->mftmirr_ino)
-		iput(vol->mftmirr_ino);
+	iput(vol->mftmirr_ino);
 #endif /* NTFS_RW */
 	return false;
 }
-- 
2.1.3



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

* [PATCH 1/1] ntfs: Deletion of unnecessary checks before the function call "iput"
@ 2014-11-15 18:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 18:42 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 19:35:05 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ntfs/super.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 6c3296e..8f22a47 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -2204,17 +2204,12 @@ get_ctx_vol_failed:
 	return true;
 #ifdef NTFS_RW
 iput_usnjrnl_err_out:
-	if (vol->usnjrnl_j_ino)
-		iput(vol->usnjrnl_j_ino);
-	if (vol->usnjrnl_max_ino)
-		iput(vol->usnjrnl_max_ino);
-	if (vol->usnjrnl_ino)
-		iput(vol->usnjrnl_ino);
+	iput(vol->usnjrnl_j_ino);
+	iput(vol->usnjrnl_max_ino);
+	iput(vol->usnjrnl_ino);
 iput_quota_err_out:
-	if (vol->quota_q_ino)
-		iput(vol->quota_q_ino);
-	if (vol->quota_ino)
-		iput(vol->quota_ino);
+	iput(vol->quota_q_ino);
+	iput(vol->quota_ino);
 	iput(vol->extend_ino);
 #endif /* NTFS_RW */
 iput_sec_err_out:
@@ -2223,8 +2218,7 @@ iput_root_err_out:
 	iput(vol->root_ino);
 iput_logfile_err_out:
 #ifdef NTFS_RW
-	if (vol->logfile_ino)
-		iput(vol->logfile_ino);
+	iput(vol->logfile_ino);
 iput_vol_err_out:
 #endif /* NTFS_RW */
 	iput(vol->vol_ino);
@@ -2254,8 +2248,7 @@ iput_mftbmp_err_out:
 	iput(vol->mftbmp_ino);
 iput_mirr_err_out:
 #ifdef NTFS_RW
-	if (vol->mftmirr_ino)
-		iput(vol->mftmirr_ino);
+	iput(vol->mftmirr_ino);
 #endif /* NTFS_RW */
 	return false;
 }
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] ntfs: Deletion of unnecessary checks before the function call "iput"
@ 2014-11-15 18:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 18:42 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 19:35:05 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ntfs/super.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 6c3296e..8f22a47 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -2204,17 +2204,12 @@ get_ctx_vol_failed:
 	return true;
 #ifdef NTFS_RW
 iput_usnjrnl_err_out:
-	if (vol->usnjrnl_j_ino)
-		iput(vol->usnjrnl_j_ino);
-	if (vol->usnjrnl_max_ino)
-		iput(vol->usnjrnl_max_ino);
-	if (vol->usnjrnl_ino)
-		iput(vol->usnjrnl_ino);
+	iput(vol->usnjrnl_j_ino);
+	iput(vol->usnjrnl_max_ino);
+	iput(vol->usnjrnl_ino);
 iput_quota_err_out:
-	if (vol->quota_q_ino)
-		iput(vol->quota_q_ino);
-	if (vol->quota_ino)
-		iput(vol->quota_ino);
+	iput(vol->quota_q_ino);
+	iput(vol->quota_ino);
 	iput(vol->extend_ino);
 #endif /* NTFS_RW */
 iput_sec_err_out:
@@ -2223,8 +2218,7 @@ iput_root_err_out:
 	iput(vol->root_ino);
 iput_logfile_err_out:
 #ifdef NTFS_RW
-	if (vol->logfile_ino)
-		iput(vol->logfile_ino);
+	iput(vol->logfile_ino);
 iput_vol_err_out:
 #endif /* NTFS_RW */
 	iput(vol->vol_ino);
@@ -2254,8 +2248,7 @@ iput_mftbmp_err_out:
 	iput(vol->mftbmp_ino);
 iput_mirr_err_out:
 #ifdef NTFS_RW
-	if (vol->mftmirr_ino)
-		iput(vol->mftmirr_ino);
+	iput(vol->mftmirr_ino);
 #endif /* NTFS_RW */
 	return false;
 }
-- 
2.1.3

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

* Re: [Cocci] [PATCH 1/1] ntfs: Deletion of unnecessary checks before the function call "iput"
  2014-11-15 18:42                                   ` SF Markus Elfring
  (?)
@ 2014-11-15 19:54                                     ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-15 19:54 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Anton Altaparmakov, linux-ntfs-dev, trivial, kernel-janitors,
	linux-kernel, Coccinelle

On Sat, 15 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 15 Nov 2014 19:35:05 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ntfs/super.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> index 6c3296e..8f22a47 100644
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -2204,17 +2204,12 @@ get_ctx_vol_failed:
>  	return true;
>  #ifdef NTFS_RW
>  iput_usnjrnl_err_out:

I don't have time to look at the code now, but since there is an exit 
label here, have you checked whether you could improve the gotos in these 
cases?

julia

> -	if (vol->usnjrnl_j_ino)
> -		iput(vol->usnjrnl_j_ino);
> -	if (vol->usnjrnl_max_ino)
> -		iput(vol->usnjrnl_max_ino);
> -	if (vol->usnjrnl_ino)
> -		iput(vol->usnjrnl_ino);
> +	iput(vol->usnjrnl_j_ino);
> +	iput(vol->usnjrnl_max_ino);
> +	iput(vol->usnjrnl_ino);
>  iput_quota_err_out:
> -	if (vol->quota_q_ino)
> -		iput(vol->quota_q_ino);
> -	if (vol->quota_ino)
> -		iput(vol->quota_ino);
> +	iput(vol->quota_q_ino);
> +	iput(vol->quota_ino);
>  	iput(vol->extend_ino);
>  #endif /* NTFS_RW */
>  iput_sec_err_out:
> @@ -2223,8 +2218,7 @@ iput_root_err_out:
>  	iput(vol->root_ino);
>  iput_logfile_err_out:
>  #ifdef NTFS_RW
> -	if (vol->logfile_ino)
> -		iput(vol->logfile_ino);
> +	iput(vol->logfile_ino);
>  iput_vol_err_out:
>  #endif /* NTFS_RW */
>  	iput(vol->vol_ino);
> @@ -2254,8 +2248,7 @@ iput_mftbmp_err_out:
>  	iput(vol->mftbmp_ino);
>  iput_mirr_err_out:
>  #ifdef NTFS_RW
> -	if (vol->mftmirr_ino)
> -		iput(vol->mftmirr_ino);
> +	iput(vol->mftmirr_ino);
>  #endif /* NTFS_RW */
>  	return false;
>  }
> -- 
> 2.1.3
> 
> 
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
> 

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

* Re: [Cocci] [PATCH 1/1] ntfs: Deletion of unnecessary checks before the function call "iput"
@ 2014-11-15 19:54                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-15 19:54 UTC (permalink / raw)
  To: cocci

On Sat, 15 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 15 Nov 2014 19:35:05 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ntfs/super.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> index 6c3296e..8f22a47 100644
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -2204,17 +2204,12 @@ get_ctx_vol_failed:
>  	return true;
>  #ifdef NTFS_RW
>  iput_usnjrnl_err_out:

I don't have time to look at the code now, but since there is an exit 
label here, have you checked whether you could improve the gotos in these 
cases?

julia

> -	if (vol->usnjrnl_j_ino)
> -		iput(vol->usnjrnl_j_ino);
> -	if (vol->usnjrnl_max_ino)
> -		iput(vol->usnjrnl_max_ino);
> -	if (vol->usnjrnl_ino)
> -		iput(vol->usnjrnl_ino);
> +	iput(vol->usnjrnl_j_ino);
> +	iput(vol->usnjrnl_max_ino);
> +	iput(vol->usnjrnl_ino);
>  iput_quota_err_out:
> -	if (vol->quota_q_ino)
> -		iput(vol->quota_q_ino);
> -	if (vol->quota_ino)
> -		iput(vol->quota_ino);
> +	iput(vol->quota_q_ino);
> +	iput(vol->quota_ino);
>  	iput(vol->extend_ino);
>  #endif /* NTFS_RW */
>  iput_sec_err_out:
> @@ -2223,8 +2218,7 @@ iput_root_err_out:
>  	iput(vol->root_ino);
>  iput_logfile_err_out:
>  #ifdef NTFS_RW
> -	if (vol->logfile_ino)
> -		iput(vol->logfile_ino);
> +	iput(vol->logfile_ino);
>  iput_vol_err_out:
>  #endif /* NTFS_RW */
>  	iput(vol->vol_ino);
> @@ -2254,8 +2248,7 @@ iput_mftbmp_err_out:
>  	iput(vol->mftbmp_ino);
>  iput_mirr_err_out:
>  #ifdef NTFS_RW
> -	if (vol->mftmirr_ino)
> -		iput(vol->mftmirr_ino);
> +	iput(vol->mftmirr_ino);
>  #endif /* NTFS_RW */
>  	return false;
>  }
> -- 
> 2.1.3
> 
> 
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
> 

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

* [Cocci] [PATCH 1/1] ntfs: Deletion of unnecessary checks before the function call "iput"
@ 2014-11-15 19:54                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-15 19:54 UTC (permalink / raw)
  To: cocci

On Sat, 15 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 15 Nov 2014 19:35:05 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/ntfs/super.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> index 6c3296e..8f22a47 100644
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -2204,17 +2204,12 @@ get_ctx_vol_failed:
>  	return true;
>  #ifdef NTFS_RW
>  iput_usnjrnl_err_out:

I don't have time to look at the code now, but since there is an exit 
label here, have you checked whether you could improve the gotos in these 
cases?

julia

> -	if (vol->usnjrnl_j_ino)
> -		iput(vol->usnjrnl_j_ino);
> -	if (vol->usnjrnl_max_ino)
> -		iput(vol->usnjrnl_max_ino);
> -	if (vol->usnjrnl_ino)
> -		iput(vol->usnjrnl_ino);
> +	iput(vol->usnjrnl_j_ino);
> +	iput(vol->usnjrnl_max_ino);
> +	iput(vol->usnjrnl_ino);
>  iput_quota_err_out:
> -	if (vol->quota_q_ino)
> -		iput(vol->quota_q_ino);
> -	if (vol->quota_ino)
> -		iput(vol->quota_ino);
> +	iput(vol->quota_q_ino);
> +	iput(vol->quota_ino);
>  	iput(vol->extend_ino);
>  #endif /* NTFS_RW */
>  iput_sec_err_out:
> @@ -2223,8 +2218,7 @@ iput_root_err_out:
>  	iput(vol->root_ino);
>  iput_logfile_err_out:
>  #ifdef NTFS_RW
> -	if (vol->logfile_ino)
> -		iput(vol->logfile_ino);
> +	iput(vol->logfile_ino);
>  iput_vol_err_out:
>  #endif /* NTFS_RW */
>  	iput(vol->vol_ino);
> @@ -2254,8 +2248,7 @@ iput_mftbmp_err_out:
>  	iput(vol->mftbmp_ino);
>  iput_mirr_err_out:
>  #ifdef NTFS_RW
> -	if (vol->mftmirr_ino)
> -		iput(vol->mftmirr_ino);
> +	iput(vol->mftmirr_ino);
>  #endif /* NTFS_RW */
>  	return false;
>  }
> -- 
> 2.1.3
> 
> 
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
> 

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

* [PATCH 1/1] fs-fat: Less function calls in fat_fill_super() after error detection
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-15 20:01                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 20:01 UTC (permalink / raw)
  To: OGAWA Hirofumi; +Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 20:55:23 +0100

The iput() function was called in an inefficient way by the implementation
of the fat_fill_super() function in case of an allocation failure.
The corresponding source code was improved by deletion of two unnecessary
null pointer checks and a few adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/fat/inode.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 756aead..138ab9a 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1716,20 +1716,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 
 	fsinfo_inode = new_inode(sb);
 	if (!fsinfo_inode)
-		goto out_fail;
+		goto fsinfo_inode_failure;
 	fsinfo_inode->i_ino = MSDOS_FSINFO_INO;
 	sbi->fsinfo_inode = fsinfo_inode;
 	insert_inode_hash(fsinfo_inode);
 
 	root_inode = new_inode(sb);
 	if (!root_inode)
-		goto out_fail;
+		goto other_failure;
 	root_inode->i_ino = MSDOS_ROOT_INO;
 	root_inode->i_version = 1;
 	error = fat_read_root(root_inode);
 	if (error < 0) {
 		iput(root_inode);
-		goto out_fail;
+		goto other_failure;
 	}
 	error = -ENOMEM;
 	insert_inode_hash(root_inode);
@@ -1737,7 +1737,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 	sb->s_root = d_make_root(root_inode);
 	if (!sb->s_root) {
 		fat_msg(sb, KERN_ERR, "get root inode failed");
-		goto out_fail;
+		goto other_failure;
 	}
 
 	if (sbi->options.discard) {
@@ -1756,11 +1756,13 @@ out_invalid:
 	if (!silent)
 		fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
 
+other_failure:
+	iput(fsinfo_inode);
+
+fsinfo_inode_failure:
+	iput(fat_inode);
+
 out_fail:
-	if (fsinfo_inode)
-		iput(fsinfo_inode);
-	if (fat_inode)
-		iput(fat_inode);
 	unload_nls(sbi->nls_io);
 	unload_nls(sbi->nls_disk);
 	if (sbi->options.iocharset != fat_default_iocharset)
-- 
2.1.3



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

* [PATCH 1/1] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-15 20:01                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 20:01 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 20:55:23 +0100

The iput() function was called in an inefficient way by the implementation
of the fat_fill_super() function in case of an allocation failure.
The corresponding source code was improved by deletion of two unnecessary
null pointer checks and a few adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/fat/inode.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 756aead..138ab9a 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1716,20 +1716,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 
 	fsinfo_inode = new_inode(sb);
 	if (!fsinfo_inode)
-		goto out_fail;
+		goto fsinfo_inode_failure;
 	fsinfo_inode->i_ino = MSDOS_FSINFO_INO;
 	sbi->fsinfo_inode = fsinfo_inode;
 	insert_inode_hash(fsinfo_inode);
 
 	root_inode = new_inode(sb);
 	if (!root_inode)
-		goto out_fail;
+		goto other_failure;
 	root_inode->i_ino = MSDOS_ROOT_INO;
 	root_inode->i_version = 1;
 	error = fat_read_root(root_inode);
 	if (error < 0) {
 		iput(root_inode);
-		goto out_fail;
+		goto other_failure;
 	}
 	error = -ENOMEM;
 	insert_inode_hash(root_inode);
@@ -1737,7 +1737,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 	sb->s_root = d_make_root(root_inode);
 	if (!sb->s_root) {
 		fat_msg(sb, KERN_ERR, "get root inode failed");
-		goto out_fail;
+		goto other_failure;
 	}
 
 	if (sbi->options.discard) {
@@ -1756,11 +1756,13 @@ out_invalid:
 	if (!silent)
 		fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
 
+other_failure:
+	iput(fsinfo_inode);
+
+fsinfo_inode_failure:
+	iput(fat_inode);
+
 out_fail:
-	if (fsinfo_inode)
-		iput(fsinfo_inode);
-	if (fat_inode)
-		iput(fat_inode);
 	unload_nls(sbi->nls_io);
 	unload_nls(sbi->nls_disk);
 	if (sbi->options.iocharset != fat_default_iocharset)
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-15 20:01                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 20:01 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 20:55:23 +0100

The iput() function was called in an inefficient way by the implementation
of the fat_fill_super() function in case of an allocation failure.
The corresponding source code was improved by deletion of two unnecessary
null pointer checks and a few adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/fat/inode.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 756aead..138ab9a 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1716,20 +1716,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 
 	fsinfo_inode = new_inode(sb);
 	if (!fsinfo_inode)
-		goto out_fail;
+		goto fsinfo_inode_failure;
 	fsinfo_inode->i_ino = MSDOS_FSINFO_INO;
 	sbi->fsinfo_inode = fsinfo_inode;
 	insert_inode_hash(fsinfo_inode);
 
 	root_inode = new_inode(sb);
 	if (!root_inode)
-		goto out_fail;
+		goto other_failure;
 	root_inode->i_ino = MSDOS_ROOT_INO;
 	root_inode->i_version = 1;
 	error = fat_read_root(root_inode);
 	if (error < 0) {
 		iput(root_inode);
-		goto out_fail;
+		goto other_failure;
 	}
 	error = -ENOMEM;
 	insert_inode_hash(root_inode);
@@ -1737,7 +1737,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 	sb->s_root = d_make_root(root_inode);
 	if (!sb->s_root) {
 		fat_msg(sb, KERN_ERR, "get root inode failed");
-		goto out_fail;
+		goto other_failure;
 	}
 
 	if (sbi->options.discard) {
@@ -1756,11 +1756,13 @@ out_invalid:
 	if (!silent)
 		fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
 
+other_failure:
+	iput(fsinfo_inode);
+
+fsinfo_inode_failure:
+	iput(fat_inode);
+
 out_fail:
-	if (fsinfo_inode)
-		iput(fsinfo_inode);
-	if (fat_inode)
-		iput(fat_inode);
 	unload_nls(sbi->nls_io);
 	unload_nls(sbi->nls_disk);
 	if (sbi->options.iocharset != fat_default_iocharset)
-- 
2.1.3

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

* Re: [PATCH 1/1] fs-fat: Less function calls in fat_fill_super() after error detection
  2014-11-15 20:01                                   ` SF Markus Elfring
  (?)
@ 2014-11-15 20:18                                     ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-15 20:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: OGAWA Hirofumi, linux-kernel, kernel-janitors, trivial, Coccinelle

On Sat, 15 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 15 Nov 2014 20:55:23 +0100
> 
> The iput() function was called in an inefficient way by the implementation
> of the fat_fill_super() function in case of an allocation failure.
> The corresponding source code was improved by deletion of two unnecessary
> null pointer checks and a few adjustments for jump labels.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/fat/inode.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
> index 756aead..138ab9a 100644
> --- a/fs/fat/inode.c
> +++ b/fs/fat/inode.c
> @@ -1716,20 +1716,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
>  
>  	fsinfo_inode = new_inode(sb);
>  	if (!fsinfo_inode)
> -		goto out_fail;
> +		goto fsinfo_inode_failure;
>  	fsinfo_inode->i_ino = MSDOS_FSINFO_INO;
>  	sbi->fsinfo_inode = fsinfo_inode;
>  	insert_inode_hash(fsinfo_inode);
>  
>  	root_inode = new_inode(sb);
>  	if (!root_inode)
> -		goto out_fail;
> +		goto other_failure;

Other_failure is not such a good name.  The one above is better.

julia

>  	root_inode->i_ino = MSDOS_ROOT_INO;
>  	root_inode->i_version = 1;
>  	error = fat_read_root(root_inode);
>  	if (error < 0) {
>  		iput(root_inode);
> -		goto out_fail;
> +		goto other_failure;
>  	}
>  	error = -ENOMEM;
>  	insert_inode_hash(root_inode);
> @@ -1737,7 +1737,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
>  	sb->s_root = d_make_root(root_inode);
>  	if (!sb->s_root) {
>  		fat_msg(sb, KERN_ERR, "get root inode failed");
> -		goto out_fail;
> +		goto other_failure;
>  	}
>  
>  	if (sbi->options.discard) {
> @@ -1756,11 +1756,13 @@ out_invalid:
>  	if (!silent)
>  		fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
>  
> +other_failure:
> +	iput(fsinfo_inode);
> +
> +fsinfo_inode_failure:
> +	iput(fat_inode);
> +
>  out_fail:
> -	if (fsinfo_inode)
> -		iput(fsinfo_inode);
> -	if (fat_inode)
> -		iput(fat_inode);
>  	unload_nls(sbi->nls_io);
>  	unload_nls(sbi->nls_disk);
>  	if (sbi->options.iocharset != fat_default_iocharset)
> -- 
> 2.1.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 1/1] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-15 20:18                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-15 20:18 UTC (permalink / raw)
  To: cocci

On Sat, 15 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 15 Nov 2014 20:55:23 +0100
> 
> The iput() function was called in an inefficient way by the implementation
> of the fat_fill_super() function in case of an allocation failure.
> The corresponding source code was improved by deletion of two unnecessary
> null pointer checks and a few adjustments for jump labels.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/fat/inode.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
> index 756aead..138ab9a 100644
> --- a/fs/fat/inode.c
> +++ b/fs/fat/inode.c
> @@ -1716,20 +1716,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
>  
>  	fsinfo_inode = new_inode(sb);
>  	if (!fsinfo_inode)
> -		goto out_fail;
> +		goto fsinfo_inode_failure;
>  	fsinfo_inode->i_ino = MSDOS_FSINFO_INO;
>  	sbi->fsinfo_inode = fsinfo_inode;
>  	insert_inode_hash(fsinfo_inode);
>  
>  	root_inode = new_inode(sb);
>  	if (!root_inode)
> -		goto out_fail;
> +		goto other_failure;

Other_failure is not such a good name.  The one above is better.

julia

>  	root_inode->i_ino = MSDOS_ROOT_INO;
>  	root_inode->i_version = 1;
>  	error = fat_read_root(root_inode);
>  	if (error < 0) {
>  		iput(root_inode);
> -		goto out_fail;
> +		goto other_failure;
>  	}
>  	error = -ENOMEM;
>  	insert_inode_hash(root_inode);
> @@ -1737,7 +1737,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
>  	sb->s_root = d_make_root(root_inode);
>  	if (!sb->s_root) {
>  		fat_msg(sb, KERN_ERR, "get root inode failed");
> -		goto out_fail;
> +		goto other_failure;
>  	}
>  
>  	if (sbi->options.discard) {
> @@ -1756,11 +1756,13 @@ out_invalid:
>  	if (!silent)
>  		fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
>  
> +other_failure:
> +	iput(fsinfo_inode);
> +
> +fsinfo_inode_failure:
> +	iput(fat_inode);
> +
>  out_fail:
> -	if (fsinfo_inode)
> -		iput(fsinfo_inode);
> -	if (fat_inode)
> -		iput(fat_inode);
>  	unload_nls(sbi->nls_io);
>  	unload_nls(sbi->nls_disk);
>  	if (sbi->options.iocharset != fat_default_iocharset)
> -- 
> 2.1.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* [Cocci] [PATCH 1/1] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-15 20:18                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-15 20:18 UTC (permalink / raw)
  To: cocci

On Sat, 15 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 15 Nov 2014 20:55:23 +0100
> 
> The iput() function was called in an inefficient way by the implementation
> of the fat_fill_super() function in case of an allocation failure.
> The corresponding source code was improved by deletion of two unnecessary
> null pointer checks and a few adjustments for jump labels.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/fat/inode.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
> index 756aead..138ab9a 100644
> --- a/fs/fat/inode.c
> +++ b/fs/fat/inode.c
> @@ -1716,20 +1716,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
>  
>  	fsinfo_inode = new_inode(sb);
>  	if (!fsinfo_inode)
> -		goto out_fail;
> +		goto fsinfo_inode_failure;
>  	fsinfo_inode->i_ino = MSDOS_FSINFO_INO;
>  	sbi->fsinfo_inode = fsinfo_inode;
>  	insert_inode_hash(fsinfo_inode);
>  
>  	root_inode = new_inode(sb);
>  	if (!root_inode)
> -		goto out_fail;
> +		goto other_failure;

Other_failure is not such a good name.  The one above is better.

julia

>  	root_inode->i_ino = MSDOS_ROOT_INO;
>  	root_inode->i_version = 1;
>  	error = fat_read_root(root_inode);
>  	if (error < 0) {
>  		iput(root_inode);
> -		goto out_fail;
> +		goto other_failure;
>  	}
>  	error = -ENOMEM;
>  	insert_inode_hash(root_inode);
> @@ -1737,7 +1737,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
>  	sb->s_root = d_make_root(root_inode);
>  	if (!sb->s_root) {
>  		fat_msg(sb, KERN_ERR, "get root inode failed");
> -		goto out_fail;
> +		goto other_failure;
>  	}
>  
>  	if (sbi->options.discard) {
> @@ -1756,11 +1756,13 @@ out_invalid:
>  	if (!silent)
>  		fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
>  
> +other_failure:
> +	iput(fsinfo_inode);
> +
> +fsinfo_inode_failure:
> +	iput(fat_inode);
> +
>  out_fail:
> -	if (fsinfo_inode)
> -		iput(fsinfo_inode);
> -	if (fat_inode)
> -		iput(fat_inode);
>  	unload_nls(sbi->nls_io);
>  	unload_nls(sbi->nls_disk);
>  	if (sbi->options.iocharset != fat_default_iocharset)
> -- 
> 2.1.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* [PATCH 1/1] lib/mpi: Deletion of unnecessary checks before the function call "mpi_free_limb_space"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-15 20:44                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 20:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 21:33:26 +0100

The mpi_free_limb_space() function tests whether its argument is NULL and
then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 lib/mpi/mpi-pow.c  | 15 +++++----------
 lib/mpi/mpih-mul.c | 21 +++++++--------------
 2 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c
index 5464c87..c28882f 100644
--- a/lib/mpi/mpi-pow.c
+++ b/lib/mpi/mpi-pow.c
@@ -308,16 +308,11 @@ leave:
 enomem:
 	if (assign_rp)
 		mpi_assign_limb_space(res, rp, size);
-	if (mp_marker)
-		mpi_free_limb_space(mp_marker);
-	if (bp_marker)
-		mpi_free_limb_space(bp_marker);
-	if (ep_marker)
-		mpi_free_limb_space(ep_marker);
-	if (xp_marker)
-		mpi_free_limb_space(xp_marker);
-	if (tspace)
-		mpi_free_limb_space(tspace);
+	mpi_free_limb_space(mp_marker);
+	mpi_free_limb_space(bp_marker);
+	mpi_free_limb_space(ep_marker);
+	mpi_free_limb_space(xp_marker);
+	mpi_free_limb_space(tspace);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(mpi_powm);
diff --git a/lib/mpi/mpih-mul.c b/lib/mpi/mpih-mul.c
index 7c84171..ff021cc 100644
--- a/lib/mpi/mpih-mul.c
+++ b/lib/mpi/mpih-mul.c
@@ -339,8 +339,7 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
 	mpi_limb_t cy;
 
 	if (!ctx->tspace || ctx->tspace_size < vsize) {
-		if (ctx->tspace)
-			mpi_free_limb_space(ctx->tspace);
+		mpi_free_limb_space(ctx->tspace);
 		ctx->tspace = mpi_alloc_limb_space(2 * vsize);
 		if (!ctx->tspace)
 			return -ENOMEM;
@@ -354,12 +353,10 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
 	usize -= vsize;
 	if (usize >= vsize) {
 		if (!ctx->tp || ctx->tp_size < vsize) {
-			if (ctx->tp)
-				mpi_free_limb_space(ctx->tp);
+			mpi_free_limb_space(ctx->tp);
 			ctx->tp = mpi_alloc_limb_space(2 * vsize);
 			if (!ctx->tp) {
-				if (ctx->tspace)
-					mpi_free_limb_space(ctx->tspace);
+				mpi_free_limb_space(ctx->tspace);
 				ctx->tspace = NULL;
 				return -ENOMEM;
 			}
@@ -407,16 +404,12 @@ void mpihelp_release_karatsuba_ctx(struct karatsuba_ctx *ctx)
 {
 	struct karatsuba_ctx *ctx2;
 
-	if (ctx->tp)
-		mpi_free_limb_space(ctx->tp);
-	if (ctx->tspace)
-		mpi_free_limb_space(ctx->tspace);
+	mpi_free_limb_space(ctx->tp);
+	mpi_free_limb_space(ctx->tspace);
 	for (ctx = ctx->next; ctx; ctx = ctx2) {
 		ctx2 = ctx->next;
-		if (ctx->tp)
-			mpi_free_limb_space(ctx->tp);
-		if (ctx->tspace)
-			mpi_free_limb_space(ctx->tspace);
+		mpi_free_limb_space(ctx->tp);
+		mpi_free_limb_space(ctx->tspace);
 		kfree(ctx);
 	}
 }
-- 
2.1.3



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

* [PATCH 1/1] lib/mpi: Deletion of unnecessary checks before the function call "mpi_free_limb_space"
@ 2014-11-15 20:44                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 20:44 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 21:33:26 +0100

The mpi_free_limb_space() function tests whether its argument is NULL and
then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 lib/mpi/mpi-pow.c  | 15 +++++----------
 lib/mpi/mpih-mul.c | 21 +++++++--------------
 2 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c
index 5464c87..c28882f 100644
--- a/lib/mpi/mpi-pow.c
+++ b/lib/mpi/mpi-pow.c
@@ -308,16 +308,11 @@ leave:
 enomem:
 	if (assign_rp)
 		mpi_assign_limb_space(res, rp, size);
-	if (mp_marker)
-		mpi_free_limb_space(mp_marker);
-	if (bp_marker)
-		mpi_free_limb_space(bp_marker);
-	if (ep_marker)
-		mpi_free_limb_space(ep_marker);
-	if (xp_marker)
-		mpi_free_limb_space(xp_marker);
-	if (tspace)
-		mpi_free_limb_space(tspace);
+	mpi_free_limb_space(mp_marker);
+	mpi_free_limb_space(bp_marker);
+	mpi_free_limb_space(ep_marker);
+	mpi_free_limb_space(xp_marker);
+	mpi_free_limb_space(tspace);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(mpi_powm);
diff --git a/lib/mpi/mpih-mul.c b/lib/mpi/mpih-mul.c
index 7c84171..ff021cc 100644
--- a/lib/mpi/mpih-mul.c
+++ b/lib/mpi/mpih-mul.c
@@ -339,8 +339,7 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
 	mpi_limb_t cy;
 
 	if (!ctx->tspace || ctx->tspace_size < vsize) {
-		if (ctx->tspace)
-			mpi_free_limb_space(ctx->tspace);
+		mpi_free_limb_space(ctx->tspace);
 		ctx->tspace = mpi_alloc_limb_space(2 * vsize);
 		if (!ctx->tspace)
 			return -ENOMEM;
@@ -354,12 +353,10 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
 	usize -= vsize;
 	if (usize >= vsize) {
 		if (!ctx->tp || ctx->tp_size < vsize) {
-			if (ctx->tp)
-				mpi_free_limb_space(ctx->tp);
+			mpi_free_limb_space(ctx->tp);
 			ctx->tp = mpi_alloc_limb_space(2 * vsize);
 			if (!ctx->tp) {
-				if (ctx->tspace)
-					mpi_free_limb_space(ctx->tspace);
+				mpi_free_limb_space(ctx->tspace);
 				ctx->tspace = NULL;
 				return -ENOMEM;
 			}
@@ -407,16 +404,12 @@ void mpihelp_release_karatsuba_ctx(struct karatsuba_ctx *ctx)
 {
 	struct karatsuba_ctx *ctx2;
 
-	if (ctx->tp)
-		mpi_free_limb_space(ctx->tp);
-	if (ctx->tspace)
-		mpi_free_limb_space(ctx->tspace);
+	mpi_free_limb_space(ctx->tp);
+	mpi_free_limb_space(ctx->tspace);
 	for (ctx = ctx->next; ctx; ctx = ctx2) {
 		ctx2 = ctx->next;
-		if (ctx->tp)
-			mpi_free_limb_space(ctx->tp);
-		if (ctx->tspace)
-			mpi_free_limb_space(ctx->tspace);
+		mpi_free_limb_space(ctx->tp);
+		mpi_free_limb_space(ctx->tspace);
 		kfree(ctx);
 	}
 }
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] lib/mpi: Deletion of unnecessary checks before the function call "mpi_free_limb_space"
@ 2014-11-15 20:44                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-15 20:44 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 15 Nov 2014 21:33:26 +0100

The mpi_free_limb_space() function tests whether its argument is NULL and
then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 lib/mpi/mpi-pow.c  | 15 +++++----------
 lib/mpi/mpih-mul.c | 21 +++++++--------------
 2 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c
index 5464c87..c28882f 100644
--- a/lib/mpi/mpi-pow.c
+++ b/lib/mpi/mpi-pow.c
@@ -308,16 +308,11 @@ leave:
 enomem:
 	if (assign_rp)
 		mpi_assign_limb_space(res, rp, size);
-	if (mp_marker)
-		mpi_free_limb_space(mp_marker);
-	if (bp_marker)
-		mpi_free_limb_space(bp_marker);
-	if (ep_marker)
-		mpi_free_limb_space(ep_marker);
-	if (xp_marker)
-		mpi_free_limb_space(xp_marker);
-	if (tspace)
-		mpi_free_limb_space(tspace);
+	mpi_free_limb_space(mp_marker);
+	mpi_free_limb_space(bp_marker);
+	mpi_free_limb_space(ep_marker);
+	mpi_free_limb_space(xp_marker);
+	mpi_free_limb_space(tspace);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(mpi_powm);
diff --git a/lib/mpi/mpih-mul.c b/lib/mpi/mpih-mul.c
index 7c84171..ff021cc 100644
--- a/lib/mpi/mpih-mul.c
+++ b/lib/mpi/mpih-mul.c
@@ -339,8 +339,7 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
 	mpi_limb_t cy;
 
 	if (!ctx->tspace || ctx->tspace_size < vsize) {
-		if (ctx->tspace)
-			mpi_free_limb_space(ctx->tspace);
+		mpi_free_limb_space(ctx->tspace);
 		ctx->tspace = mpi_alloc_limb_space(2 * vsize);
 		if (!ctx->tspace)
 			return -ENOMEM;
@@ -354,12 +353,10 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
 	usize -= vsize;
 	if (usize >= vsize) {
 		if (!ctx->tp || ctx->tp_size < vsize) {
-			if (ctx->tp)
-				mpi_free_limb_space(ctx->tp);
+			mpi_free_limb_space(ctx->tp);
 			ctx->tp = mpi_alloc_limb_space(2 * vsize);
 			if (!ctx->tp) {
-				if (ctx->tspace)
-					mpi_free_limb_space(ctx->tspace);
+				mpi_free_limb_space(ctx->tspace);
 				ctx->tspace = NULL;
 				return -ENOMEM;
 			}
@@ -407,16 +404,12 @@ void mpihelp_release_karatsuba_ctx(struct karatsuba_ctx *ctx)
 {
 	struct karatsuba_ctx *ctx2;
 
-	if (ctx->tp)
-		mpi_free_limb_space(ctx->tp);
-	if (ctx->tspace)
-		mpi_free_limb_space(ctx->tspace);
+	mpi_free_limb_space(ctx->tp);
+	mpi_free_limb_space(ctx->tspace);
 	for (ctx = ctx->next; ctx; ctx = ctx2) {
 		ctx2 = ctx->next;
-		if (ctx->tp)
-			mpi_free_limb_space(ctx->tp);
-		if (ctx->tspace)
-			mpi_free_limb_space(ctx->tspace);
+		mpi_free_limb_space(ctx->tp);
+		mpi_free_limb_space(ctx->tspace);
 		kfree(ctx);
 	}
 }
-- 
2.1.3

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

* [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-16 10:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 10:40 UTC (permalink / raw)
  To: Eric Paris; +Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 11:27:43 +0100

The audit_log_end() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/auditsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 21eae3c..1fed61c 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1470,8 +1470,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
 
 	/* Send end of event record to help user space know we are finished */
 	ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
-	if (ab)
-		audit_log_end(ab);
+	audit_log_end(ab);
 	if (call_panic)
 		audit_panic("error converting sid to string");
 }
-- 
2.1.3



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

* [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-16 10:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 10:40 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 11:27:43 +0100

The audit_log_end() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/auditsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 21eae3c..1fed61c 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1470,8 +1470,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
 
 	/* Send end of event record to help user space know we are finished */
 	ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
-	if (ab)
-		audit_log_end(ab);
+	audit_log_end(ab);
 	if (call_panic)
 		audit_panic("error converting sid to string");
 }
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-16 10:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 10:40 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 11:27:43 +0100

The audit_log_end() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/auditsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 21eae3c..1fed61c 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1470,8 +1470,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
 
 	/* Send end of event record to help user space know we are finished */
 	ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
-	if (ab)
-		audit_log_end(ab);
+	audit_log_end(ab);
 	if (call_panic)
 		audit_panic("error converting sid to string");
 }
-- 
2.1.3

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-16 10:40                                   ` SF Markus Elfring
  (?)
@ 2014-11-16 11:10                                     ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-16 11:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Eric Paris, linux-kernel, kernel-janitors, trivial, Coccinelle

Please don't send these to trivial, because they can introduce bugs.

The make the code less clear and they are a layering violation.  If the
other maintainers want to take them that's fine, but don't send it to
trivial.

regards,
dan carpenter


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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e
@ 2014-11-16 11:10                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-16 11:10 UTC (permalink / raw)
  To: cocci

Please don't send these to trivial, because they can introduce bugs.

The make the code less clear and they are a layering violation.  If the
other maintainers want to take them that's fine, but don't send it to
trivial.

regards,
dan carpenter


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

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-16 11:10                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-16 11:10 UTC (permalink / raw)
  To: cocci

Please don't send these to trivial, because they can introduce bugs.

The make the code less clear and they are a layering violation.  If the
other maintainers want to take them that's fine, but don't send it to
trivial.

regards,
dan carpenter

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-16 11:10                                     ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
  (?)
@ 2014-11-16 11:14                                       ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-16 11:14 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Eric Paris, linux-kernel, kernel-janitors, trivial, Coccinelle

On Sun, Nov 16, 2014 at 02:10:23PM +0300, Dan Carpenter wrote:
> Please don't send these to trivial, because they can introduce bugs.

An example of a bug introduced is here:

https://lkml.org/lkml/2014/11/3/505

regards,
dan carpenter


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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e
@ 2014-11-16 11:14                                       ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-16 11:14 UTC (permalink / raw)
  To: cocci

On Sun, Nov 16, 2014 at 02:10:23PM +0300, Dan Carpenter wrote:
> Please don't send these to trivial, because they can introduce bugs.

An example of a bug introduced is here:

https://lkml.org/lkml/2014/11/3/505

regards,
dan carpenter


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

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-16 11:14                                       ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-16 11:14 UTC (permalink / raw)
  To: cocci

On Sun, Nov 16, 2014 at 02:10:23PM +0300, Dan Carpenter wrote:
> Please don't send these to trivial, because they can introduce bugs.

An example of a bug introduced is here:

https://lkml.org/lkml/2014/11/3/505

regards,
dan carpenter

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-16 10:40                                   ` SF Markus Elfring
  (?)
@ 2014-11-16 11:24                                     ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-16 11:24 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Eric Paris, linux-kernel, kernel-janitors, trivial, Coccinelle

On Sun, Nov 16, 2014 at 11:40:26AM +0100, SF Markus Elfring wrote:
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 21eae3c..1fed61c 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -1470,8 +1470,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
>  
>  	/* Send end of event record to help user space know we are finished */
>  	ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
> -	if (ab)
> -		audit_log_end(ab);
> +	audit_log_end(ab);
>  	if (call_panic)
>  		audit_panic("error converting sid to string");
>  }

I should have tried to explain this in my earlier message...

The original code is very clear, the new code works exactly the same but
it's not clear if the author forgot about handling errors from
audit_log_start().  So now someone will come along later and add:

	if (!ab)
		return;

We get a lot of mindless "add error handling" patches like that.  Even
if no one adds that patch who ever is reading the code will think that
the error handling is missing by mistake and have to read the git log
to determine the original intention.

Instead of hiding the readable code in the git log, let's just leave it
in the source file.

regards,
dan carpenter


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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e
@ 2014-11-16 11:24                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-16 11:24 UTC (permalink / raw)
  To: cocci

On Sun, Nov 16, 2014 at 11:40:26AM +0100, SF Markus Elfring wrote:
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 21eae3c..1fed61c 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -1470,8 +1470,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
>  
>  	/* Send end of event record to help user space know we are finished */
>  	ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
> -	if (ab)
> -		audit_log_end(ab);
> +	audit_log_end(ab);
>  	if (call_panic)
>  		audit_panic("error converting sid to string");
>  }

I should have tried to explain this in my earlier message...

The original code is very clear, the new code works exactly the same but
it's not clear if the author forgot about handling errors from
audit_log_start().  So now someone will come along later and add:

	if (!ab)
		return;

We get a lot of mindless "add error handling" patches like that.  Even
if no one adds that patch who ever is reading the code will think that
the error handling is missing by mistake and have to read the git log
to determine the original intention.

Instead of hiding the readable code in the git log, let's just leave it
in the source file.

regards,
dan carpenter


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

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-16 11:24                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-16 11:24 UTC (permalink / raw)
  To: cocci

On Sun, Nov 16, 2014 at 11:40:26AM +0100, SF Markus Elfring wrote:
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 21eae3c..1fed61c 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -1470,8 +1470,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
>  
>  	/* Send end of event record to help user space know we are finished */
>  	ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
> -	if (ab)
> -		audit_log_end(ab);
> +	audit_log_end(ab);
>  	if (call_panic)
>  		audit_panic("error converting sid to string");
>  }

I should have tried to explain this in my earlier message...

The original code is very clear, the new code works exactly the same but
it's not clear if the author forgot about handling errors from
audit_log_start().  So now someone will come along later and add:

	if (!ab)
		return;

We get a lot of mindless "add error handling" patches like that.  Even
if no one adds that patch who ever is reading the code will think that
the error handling is missing by mistake and have to read the git log
to determine the original intention.

Instead of hiding the readable code in the git log, let's just leave it
in the source file.

regards,
dan carpenter

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-16 11:14                                       ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
  (?)
@ 2014-11-16 11:48                                         ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 11:48 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Eric Paris, linux-kernel, kernel-janitors, trivial, Coccinelle

> An example of a bug introduced is here:
> 
> https://lkml.org/lkml/2014/11/3/505

It seems that we try to clarify a different interpretation of "bugs", don't we?

It is an usual software development challenge to decide on the best source code places
where to put input parameter validation (and when it can be omitted), isn't it?

Regards,
Markus

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e
@ 2014-11-16 11:48                                         ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 11:48 UTC (permalink / raw)
  To: cocci

> An example of a bug introduced is here:
> 
> https://lkml.org/lkml/2014/11/3/505

It seems that we try to clarify a different interpretation of "bugs", don't we?

It is an usual software development challenge to decide on the best source code places
where to put input parameter validation (and when it can be omitted), isn't it?

Regards,
Markus

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

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-16 11:48                                         ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 11:48 UTC (permalink / raw)
  To: cocci

> An example of a bug introduced is here:
> 
> https://lkml.org/lkml/2014/11/3/505

It seems that we try to clarify a different interpretation of "bugs", don't we?

It is an usual software development challenge to decide on the best source code places
where to put input parameter validation (and when it can be omitted), isn't it?

Regards,
Markus

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" (or improve error handling?)
  2014-11-16 11:24                                     ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
  (?)
@ 2014-11-16 12:07                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 12:07 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Eric Paris, linux-kernel, kernel-janitors, Coccinelle

> The original code is very clear, the new code works exactly the same but
> it's not clear if the author forgot about handling errors from
> audit_log_start().

We have got different expectations on source code clarity here.


> So now someone will come along later and add:
> 	if (!ab)
> 		return;
> 
> We get a lot of mindless "add error handling" patches like that.

This is an interesting background information.

Do you eventually prefer to improve the affected error detection
and corresponding exception handling?
Will a condition check become absolutely necessary there?

Regards,
Markus

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e
@ 2014-11-16 12:07                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 12:07 UTC (permalink / raw)
  To: cocci

> The original code is very clear, the new code works exactly the same but
> it's not clear if the author forgot about handling errors from
> audit_log_start().

We have got different expectations on source code clarity here.


> So now someone will come along later and add:
> 	if (!ab)
> 		return;
> 
> We get a lot of mindless "add error handling" patches like that.

This is an interesting background information.

Do you eventually prefer to improve the affected error detection
and corresponding exception handling?
Will a condition check become absolutely necessary there?

Regards,
Markus

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

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" (or improve error handling?)
@ 2014-11-16 12:07                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 12:07 UTC (permalink / raw)
  To: cocci

> The original code is very clear, the new code works exactly the same but
> it's not clear if the author forgot about handling errors from
> audit_log_start().

We have got different expectations on source code clarity here.


> So now someone will come along later and add:
> 	if (!ab)
> 		return;
> 
> We get a lot of mindless "add error handling" patches like that.

This is an interesting background information.

Do you eventually prefer to improve the affected error detection
and corresponding exception handling?
Will a condition check become absolutely necessary there?

Regards,
Markus

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

* [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-16 12:34                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 12:34 UTC (permalink / raw)
  To: Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, Masami Hiramatsu
  Cc: linux-kernel, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 12:20:31 +0100

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/kprobes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 3995f54..f1e7d45 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
 out:
 	mutex_unlock(&kprobe_mutex);
 
-	if (probed_mod)
-		module_put(probed_mod);
+	module_put(probed_mod);
 
 	return ret;
 }
-- 
2.1.3



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

* [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-16 12:34                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 12:34 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 12:20:31 +0100

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/kprobes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 3995f54..f1e7d45 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
 out:
 	mutex_unlock(&kprobe_mutex);
 
-	if (probed_mod)
-		module_put(probed_mod);
+	module_put(probed_mod);
 
 	return ret;
 }
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-16 12:34                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 12:34 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 12:20:31 +0100

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/kprobes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 3995f54..f1e7d45 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
 out:
 	mutex_unlock(&kprobe_mutex);
 
-	if (probed_mod)
-		module_put(probed_mod);
+	module_put(probed_mod);
 
 	return ret;
 }
-- 
2.1.3

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

* [PATCH 1/1] kernel-power: Deletion of an unnecessary check before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-16 13:28                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 13:28 UTC (permalink / raw)
  To: Len Brown, Pavel Machek, Rafael J. Wysocki, linux-pm
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:18:28 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/power/swap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index aaa3261..337c7a9 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1374,7 +1374,7 @@ out_clean:
 				kthread_stop(data[thr].thr);
 		vfree(data);
 	}
-	if (page) vfree(page);
+	vfree(page);
 
 	return ret;
 }
-- 
2.1.3



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

* [PATCH 1/1] kernel-power: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-16 13:28                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 13:28 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:18:28 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/power/swap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index aaa3261..337c7a9 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1374,7 +1374,7 @@ out_clean:
 				kthread_stop(data[thr].thr);
 		vfree(data);
 	}
-	if (page) vfree(page);
+	vfree(page);
 
 	return ret;
 }
-- 
2.1.3



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

* [PATCH 1/1] kernel-power: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-16 13:28                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 13:28 UTC (permalink / raw)
  To: Len Brown, Pavel Machek, Rafael J. Wysocki, linux-pm
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:18:28 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/power/swap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index aaa3261..337c7a9 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1374,7 +1374,7 @@ out_clean:
 				kthread_stop(data[thr].thr);
 		vfree(data);
 	}
-	if (page) vfree(page);
+	vfree(page);
 
 	return ret;
 }
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] kernel-power: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-16 13:28                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 13:28 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:18:28 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/power/swap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index aaa3261..337c7a9 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1374,7 +1374,7 @@ out_clean:
 				kthread_stop(data[thr].thr);
 		vfree(data);
 	}
-	if (page) vfree(page);
+	vfree(page);
 
 	return ret;
 }
-- 
2.1.3

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

* Re: [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
  2014-11-16 12:34                                   ` SF Markus Elfring
  (?)
@ 2014-11-16 13:29                                     ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 13:29 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, Masami Hiramatsu, kernel-janitors, linux-kernel,
	Coccinelle

On Sun, 16 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 12:20:31 +0100
>
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/kprobes.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 3995f54..f1e7d45 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>  out:
>  	mutex_unlock(&kprobe_mutex);
>
> -	if (probed_mod)
> -		module_put(probed_mod);
> +	module_put(probed_mod);

There is an out label, so please check whether the labels could not be
better positioned to avoid calling module_put when it is not needed.

julia

>
>  	return ret;
>  }
> --
> 2.1.3
>
>
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* Re: [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p
@ 2014-11-16 13:29                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 13:29 UTC (permalink / raw)
  To: cocci

On Sun, 16 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 12:20:31 +0100
>
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/kprobes.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 3995f54..f1e7d45 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>  out:
>  	mutex_unlock(&kprobe_mutex);
>
> -	if (probed_mod)
> -		module_put(probed_mod);
> +	module_put(probed_mod);

There is an out label, so please check whether the labels could not be
better positioned to avoid calling module_put when it is not needed.

julia

>
>  	return ret;
>  }
> --
> 2.1.3
>
>
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-16 13:29                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 13:29 UTC (permalink / raw)
  To: cocci

On Sun, 16 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 12:20:31 +0100
>
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/kprobes.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 3995f54..f1e7d45 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>  out:
>  	mutex_unlock(&kprobe_mutex);
>
> -	if (probed_mod)
> -		module_put(probed_mod);
> +	module_put(probed_mod);

There is an out label, so please check whether the labels could not be
better positioned to avoid calling module_put when it is not needed.

julia

>
>  	return ret;
>  }
> --
> 2.1.3
>
>
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [PATCH 1/1] kernel-trace: Deletion of an unnecessary check before the function call "iput"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-16 13:50                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 13:50 UTC (permalink / raw)
  To: Ingo Molnar, Steven Rostedt; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:46:28 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/trace/trace_uprobe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 33ff6a2..ec002c0 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -552,8 +552,7 @@ error:
 	return ret;
 
 fail_address_parse:
-	if (inode)
-		iput(inode);
+	iput(inode);
 
 	pr_info("Failed to parse address or file.\n");
 
-- 
2.1.3



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

* [PATCH 1/1] kernel-trace: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-16 13:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 13:50 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:46:28 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/trace/trace_uprobe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 33ff6a2..ec002c0 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -552,8 +552,7 @@ error:
 	return ret;
 
 fail_address_parse:
-	if (inode)
-		iput(inode);
+	iput(inode);
 
 	pr_info("Failed to parse address or file.\n");
 
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] kernel-trace: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-16 13:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 13:50 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:46:28 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/trace/trace_uprobe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 33ff6a2..ec002c0 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -552,8 +552,7 @@ error:
 	return ret;
 
 fail_address_parse:
-	if (inode)
-		iput(inode);
+	iput(inode);
 
 	pr_info("Failed to parse address or file.\n");
 
-- 
2.1.3

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

* Re: [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
  2014-11-16 13:29                                     ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p Julia Lawall
  (?)
@ 2014-11-16 14:26                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 14:26 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, Masami Hiramatsu, kernel-janitors, linux-kernel,
	Coccinelle

>> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
>> index 3995f54..f1e7d45 100644
>> --- a/kernel/kprobes.c
>> +++ b/kernel/kprobes.c
>> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>>  out:
>>  	mutex_unlock(&kprobe_mutex);
>>
>> -	if (probed_mod)
>> -		module_put(probed_mod);
>> +	module_put(probed_mod);
> 
> There is an out label, so please check whether the labels could not be
> better positioned to avoid calling module_put when it is not needed.

I do not see refactoring opportunities around jump labels in this use case
for the implementation of the register_kprobe() function so far because
the mutex_unlock() function must be called.
Would you like to suggest any other source code fine-tuning?

Regards,
Markus

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

* Re: [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p
@ 2014-11-16 14:26                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 14:26 UTC (permalink / raw)
  To: cocci

>> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
>> index 3995f54..f1e7d45 100644
>> --- a/kernel/kprobes.c
>> +++ b/kernel/kprobes.c
>> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>>  out:
>>  	mutex_unlock(&kprobe_mutex);
>>
>> -	if (probed_mod)
>> -		module_put(probed_mod);
>> +	module_put(probed_mod);
> 
> There is an out label, so please check whether the labels could not be
> better positioned to avoid calling module_put when it is not needed.

I do not see refactoring opportunities around jump labels in this use case
for the implementation of the register_kprobe() function so far because
the mutex_unlock() function must be called.
Would you like to suggest any other source code fine-tuning?

Regards,
Markus

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

* [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-16 14:26                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 14:26 UTC (permalink / raw)
  To: cocci

>> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
>> index 3995f54..f1e7d45 100644
>> --- a/kernel/kprobes.c
>> +++ b/kernel/kprobes.c
>> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>>  out:
>>  	mutex_unlock(&kprobe_mutex);
>>
>> -	if (probed_mod)
>> -		module_put(probed_mod);
>> +	module_put(probed_mod);
> 
> There is an out label, so please check whether the labels could not be
> better positioned to avoid calling module_put when it is not needed.

I do not see refactoring opportunities around jump labels in this use case
for the implementation of the register_kprobe() function so far because
the mutex_unlock() function must be called.
Would you like to suggest any other source code fine-tuning?

Regards,
Markus

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

* Re: [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
  2014-11-16 14:26                                       ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p SF Markus Elfring
  (?)
@ 2014-11-16 15:43                                         ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 15:43 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, Masami Hiramatsu, kernel-janitors, linux-kernel,
	Coccinelle

On Sun, 16 Nov 2014, SF Markus Elfring wrote:

> >> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> >> index 3995f54..f1e7d45 100644
> >> --- a/kernel/kprobes.c
> >> +++ b/kernel/kprobes.c
> >> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
> >>  out:
> >>  	mutex_unlock(&kprobe_mutex);
> >>
> >> -	if (probed_mod)
> >> -		module_put(probed_mod);
> >> +	module_put(probed_mod);
> >
> > There is an out label, so please check whether the labels could not be
> > better positioned to avoid calling module_put when it is not needed.
>
> I do not see refactoring opportunities around jump labels in this use case
> for the implementation of the register_kprobe() function so far because
> the mutex_unlock() function must be called.
> Would you like to suggest any other source code fine-tuning?

OK.  I don't think that removing the if is a good choice in this case.
The code ret = check_kprobe_address_safe(p, &probed_mod); is unusual, in
that it can fail to do anything in two ways.  One is by setting ret, on
detecting an error, and the other is by returning 0 but still putting a
NULL value in probed_mod when there is nothing to do.  Thus, in the
successful execution of the rest of the function, a probed module might or
might not exist.  The if around the module_put is helpful to the reader to
understand that this possibility exists.

julia

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

* Re: [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p
@ 2014-11-16 15:43                                         ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 15:43 UTC (permalink / raw)
  To: cocci

On Sun, 16 Nov 2014, SF Markus Elfring wrote:

> >> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> >> index 3995f54..f1e7d45 100644
> >> --- a/kernel/kprobes.c
> >> +++ b/kernel/kprobes.c
> >> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
> >>  out:
> >>  	mutex_unlock(&kprobe_mutex);
> >>
> >> -	if (probed_mod)
> >> -		module_put(probed_mod);
> >> +	module_put(probed_mod);
> >
> > There is an out label, so please check whether the labels could not be
> > better positioned to avoid calling module_put when it is not needed.
>
> I do not see refactoring opportunities around jump labels in this use case
> for the implementation of the register_kprobe() function so far because
> the mutex_unlock() function must be called.
> Would you like to suggest any other source code fine-tuning?

OK.  I don't think that removing the if is a good choice in this case.
The code ret = check_kprobe_address_safe(p, &probed_mod); is unusual, in
that it can fail to do anything in two ways.  One is by setting ret, on
detecting an error, and the other is by returning 0 but still putting a
NULL value in probed_mod when there is nothing to do.  Thus, in the
successful execution of the rest of the function, a probed module might or
might not exist.  The if around the module_put is helpful to the reader to
understand that this possibility exists.

julia

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

* [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-16 15:43                                         ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 15:43 UTC (permalink / raw)
  To: cocci

On Sun, 16 Nov 2014, SF Markus Elfring wrote:

> >> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> >> index 3995f54..f1e7d45 100644
> >> --- a/kernel/kprobes.c
> >> +++ b/kernel/kprobes.c
> >> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
> >>  out:
> >>  	mutex_unlock(&kprobe_mutex);
> >>
> >> -	if (probed_mod)
> >> -		module_put(probed_mod);
> >> +	module_put(probed_mod);
> >
> > There is an out label, so please check whether the labels could not be
> > better positioned to avoid calling module_put when it is not needed.
>
> I do not see refactoring opportunities around jump labels in this use case
> for the implementation of the register_kprobe() function so far because
> the mutex_unlock() function must be called.
> Would you like to suggest any other source code fine-tuning?

OK.  I don't think that removing the if is a good choice in this case.
The code ret = check_kprobe_address_safe(p, &probed_mod); is unusual, in
that it can fail to do anything in two ways.  One is by setting ret, on
detecting an error, and the other is by returning 0 but still putting a
NULL value in probed_mod when there is nothing to do.  Thus, in the
successful execution of the rest of the function, a probed module might or
might not exist.  The if around the module_put is helpful to the reader to
understand that this possibility exists.

julia

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

* Re: [PATCH 1/1] kernel-trace: Deletion of an unnecessary check before the function call "iput"
  2014-11-16 13:50                                   ` SF Markus Elfring
  (?)
@ 2014-11-16 15:56                                     ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 15:56 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ingo Molnar, Steven Rostedt, LKML, kernel-janitors, Coccinelle

On Sun, 16 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 14:46:28 +0100
>
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/trace/trace_uprobe.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index 33ff6a2..ec002c0 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -552,8 +552,7 @@ error:
>  	return ret;
>
>  fail_address_parse:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);

There are jumps to fail_address_parse where the value of inode can only be
NULL.

julia

>
>  	pr_info("Failed to parse address or file.\n");
>
> --
> 2.1.3
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH 1/1] kernel-trace: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-16 15:56                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 15:56 UTC (permalink / raw)
  To: cocci

On Sun, 16 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 14:46:28 +0100
>
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/trace/trace_uprobe.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index 33ff6a2..ec002c0 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -552,8 +552,7 @@ error:
>  	return ret;
>
>  fail_address_parse:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);

There are jumps to fail_address_parse where the value of inode can only be
NULL.

julia

>
>  	pr_info("Failed to parse address or file.\n");
>
> --
> 2.1.3
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* [Cocci] [PATCH 1/1] kernel-trace: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-16 15:56                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 15:56 UTC (permalink / raw)
  To: cocci

On Sun, 16 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 14:46:28 +0100
>
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/trace/trace_uprobe.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index 33ff6a2..ec002c0 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -552,8 +552,7 @@ error:
>  	return ret;
>
>  fail_address_parse:
> -	if (inode)
> -		iput(inode);
> +	iput(inode);

There are jumps to fail_address_parse where the value of inode can only be
NULL.

julia

>
>  	pr_info("Failed to parse address or file.\n");
>
> --
> 2.1.3
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
  2014-11-16 15:43                                         ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p Julia Lawall
  (?)
@ 2014-11-16 16:57                                           ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 16:57 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, Masami Hiramatsu, kernel-janitors, linux-kernel,
	Coccinelle

> The if around the module_put is helpful to the reader to understand
> that this possibility exists.

I have got a different opinion. I would still prefer a small code clean-up there.

Regards,
Markus


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

* Re: [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p
@ 2014-11-16 16:57                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 16:57 UTC (permalink / raw)
  To: cocci

> The if around the module_put is helpful to the reader to understand
> that this possibility exists.

I have got a different opinion. I would still prefer a small code clean-up there.

Regards,
Markus


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

* [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-16 16:57                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 16:57 UTC (permalink / raw)
  To: cocci

> The if around the module_put is helpful to the reader to understand
> that this possibility exists.

I have got a different opinion. I would still prefer a small code clean-up there.

Regards,
Markus

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

* [PATCH v2 0/2] kernel-trace: Fixes around the jump label "fail_address_parse"
  2014-11-16 15:56                                     ` Julia Lawall
  (?)
@ 2014-11-16 19:13                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 19:13 UTC (permalink / raw)
  To: Ingo Molnar, Steven Rostedt; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 19:56:15 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  kernel-trace: Deletion of an unnecessary check before the function
    call "iput"
  kernel-trace: Less calls for iput() in create_trace_uprobe() after
    error detection

 kernel/trace/trace_uprobe.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

-- 
2.1.3



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

* [PATCH v2 0/2] kernel-trace: Fixes around the jump label "fail_address_parse"
@ 2014-11-16 19:13                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 19:13 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 19:56:15 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  kernel-trace: Deletion of an unnecessary check before the function
    call "iput"
  kernel-trace: Less calls for iput() in create_trace_uprobe() after
    error detection

 kernel/trace/trace_uprobe.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

-- 
2.1.3



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

* [Cocci] [PATCH v2 0/2] kernel-trace: Fixes around the jump label "fail_address_parse"
@ 2014-11-16 19:13                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 19:13 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 19:56:15 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  kernel-trace: Deletion of an unnecessary check before the function
    call "iput"
  kernel-trace: Less calls for iput() in create_trace_uprobe() after
    error detection

 kernel/trace/trace_uprobe.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

-- 
2.1.3

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

* [PATCH v2 1/2] kernel-trace: Deletion of an unnecessary check before the function call "iput"
  2014-11-16 19:13                                       ` SF Markus Elfring
  (?)
@ 2014-11-16 19:18                                         ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 19:18 UTC (permalink / raw)
  To: Ingo Molnar, Steven Rostedt; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:46:28 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/trace/trace_uprobe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 33ff6a2..ec002c0 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -552,8 +552,7 @@ error:
 	return ret;
 
 fail_address_parse:
-	if (inode)
-		iput(inode);
+	iput(inode);
 
 	pr_info("Failed to parse address or file.\n");
 
-- 
2.1.3



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

* [PATCH v2 1/2] kernel-trace: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-16 19:18                                         ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 19:18 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:46:28 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/trace/trace_uprobe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 33ff6a2..ec002c0 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -552,8 +552,7 @@ error:
 	return ret;
 
 fail_address_parse:
-	if (inode)
-		iput(inode);
+	iput(inode);
 
 	pr_info("Failed to parse address or file.\n");
 
-- 
2.1.3



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

* [Cocci] [PATCH v2 1/2] kernel-trace: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-16 19:18                                         ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 19:18 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 14:46:28 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/trace/trace_uprobe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 33ff6a2..ec002c0 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -552,8 +552,7 @@ error:
 	return ret;
 
 fail_address_parse:
-	if (inode)
-		iput(inode);
+	iput(inode);
 
 	pr_info("Failed to parse address or file.\n");
 
-- 
2.1.3

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

* [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection
  2014-11-16 19:13                                       ` SF Markus Elfring
  (?)
@ 2014-11-16 19:22                                         ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 19:22 UTC (permalink / raw)
  To: Ingo Molnar, Steven Rostedt; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 19:49:39 +0100

The iput() function was called in three cases by the create_trace_uprobe()
function during error handling even if the passed variable contained still
a null pointer. This implementation detail could be improved by the
introduction of another jump label.

Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/trace/trace_uprobe.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index ec002c0..a0288f2 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -434,19 +434,24 @@ static int create_trace_uprobe(int argc, char **argv)
 	arg = strchr(argv[1], ':');
 	if (!arg) {
 		ret = -EINVAL;
-		goto fail_address_parse;
+		goto fail_address_parse2;
 	}
 
 	*arg++ = '\0';
 	filename = argv[1];
 	ret = kern_path(filename, LOOKUP_FOLLOW, &path);
 	if (ret)
-		goto fail_address_parse;
+		goto fail_address_parse2;
 
 	inode = igrab(path.dentry->d_inode);
 	path_put(&path);
 
-	if (!inode || !S_ISREG(inode->i_mode)) {
+	if (!inode) {
+		ret = -EINVAL;
+		goto fail_address_parse2;
+	}
+
+	if (!S_ISREG(inode->i_mode)) {
 		ret = -EINVAL;
 		goto fail_address_parse;
 	}
@@ -554,6 +559,7 @@ error:
 fail_address_parse:
 	iput(inode);
 
+fail_address_parse2:
 	pr_info("Failed to parse address or file.\n");
 
 	return ret;
-- 
2.1.3



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

* [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection
@ 2014-11-16 19:22                                         ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 19:22 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 19:49:39 +0100

The iput() function was called in three cases by the create_trace_uprobe()
function during error handling even if the passed variable contained still
a null pointer. This implementation detail could be improved by the
introduction of another jump label.

Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/trace/trace_uprobe.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index ec002c0..a0288f2 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -434,19 +434,24 @@ static int create_trace_uprobe(int argc, char **argv)
 	arg = strchr(argv[1], ':');
 	if (!arg) {
 		ret = -EINVAL;
-		goto fail_address_parse;
+		goto fail_address_parse2;
 	}
 
 	*arg++ = '\0';
 	filename = argv[1];
 	ret = kern_path(filename, LOOKUP_FOLLOW, &path);
 	if (ret)
-		goto fail_address_parse;
+		goto fail_address_parse2;
 
 	inode = igrab(path.dentry->d_inode);
 	path_put(&path);
 
-	if (!inode || !S_ISREG(inode->i_mode)) {
+	if (!inode) {
+		ret = -EINVAL;
+		goto fail_address_parse2;
+	}
+
+	if (!S_ISREG(inode->i_mode)) {
 		ret = -EINVAL;
 		goto fail_address_parse;
 	}
@@ -554,6 +559,7 @@ error:
 fail_address_parse:
 	iput(inode);
 
+fail_address_parse2:
 	pr_info("Failed to parse address or file.\n");
 
 	return ret;
-- 
2.1.3



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

* [Cocci] [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection
@ 2014-11-16 19:22                                         ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 19:22 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 19:49:39 +0100

The iput() function was called in three cases by the create_trace_uprobe()
function during error handling even if the passed variable contained still
a null pointer. This implementation detail could be improved by the
introduction of another jump label.

Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/trace/trace_uprobe.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index ec002c0..a0288f2 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -434,19 +434,24 @@ static int create_trace_uprobe(int argc, char **argv)
 	arg = strchr(argv[1], ':');
 	if (!arg) {
 		ret = -EINVAL;
-		goto fail_address_parse;
+		goto fail_address_parse2;
 	}
 
 	*arg++ = '\0';
 	filename = argv[1];
 	ret = kern_path(filename, LOOKUP_FOLLOW, &path);
 	if (ret)
-		goto fail_address_parse;
+		goto fail_address_parse2;
 
 	inode = igrab(path.dentry->d_inode);
 	path_put(&path);
 
-	if (!inode || !S_ISREG(inode->i_mode)) {
+	if (!inode) {
+		ret = -EINVAL;
+		goto fail_address_parse2;
+	}
+
+	if (!S_ISREG(inode->i_mode)) {
 		ret = -EINVAL;
 		goto fail_address_parse;
 	}
@@ -554,6 +559,7 @@ error:
 fail_address_parse:
 	iput(inode);
 
+fail_address_parse2:
 	pr_info("Failed to parse address or file.\n");
 
 	return ret;
-- 
2.1.3

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

* Re: [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection
  2014-11-16 19:22                                         ` SF Markus Elfring
@ 2014-11-16 19:31                                           ` Steven Rostedt
  -1 siblings, 0 replies; 3633+ messages in thread
From: Steven Rostedt @ 2014-11-16 19:31 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Ingo Molnar, LKML, kernel-janitors, Coccinelle

On Sun, 16 Nov 2014 20:22:22 +0100
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 19:49:39 +0100
> 
> The iput() function was called in three cases by the create_trace_uprobe()
> function during error handling even if the passed variable contained still
> a null pointer. This implementation detail could be improved by the
> introduction of another jump label.

The first patch is fine, and the only reason is to save the few bytes
that the branch check might take. It's in a path that is unlikely to be
hit so it is not a performance issue at all.

This patch is useless. I rather not apply any patch than to create
another jump that skips over the freeing of iput() just because we know
inode is null. That's why we had the if (inode) in the first place.

So Nack on this patch and I'll contemplate applying the first one. I
probably will as it seems rather harmless.

Thanks,

-- Steve


> 
> Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/trace/trace_uprobe.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index ec002c0..a0288f2 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -434,19 +434,24 @@ static int create_trace_uprobe(int argc, char **argv)
>  	arg = strchr(argv[1], ':');
>  	if (!arg) {
>  		ret = -EINVAL;
> -		goto fail_address_parse;
> +		goto fail_address_parse2;
>  	}
>  
>  	*arg++ = '\0';
>  	filename = argv[1];
>  	ret = kern_path(filename, LOOKUP_FOLLOW, &path);
>  	if (ret)
> -		goto fail_address_parse;
> +		goto fail_address_parse2;
>  
>  	inode = igrab(path.dentry->d_inode);
>  	path_put(&path);
>  
> -	if (!inode || !S_ISREG(inode->i_mode)) {
> +	if (!inode) {
> +		ret = -EINVAL;
> +		goto fail_address_parse2;
> +	}
> +
> +	if (!S_ISREG(inode->i_mode)) {
>  		ret = -EINVAL;
>  		goto fail_address_parse;
>  	}
> @@ -554,6 +559,7 @@ error:
>  fail_address_parse:
>  	iput(inode);
>  
> +fail_address_parse2:
>  	pr_info("Failed to parse address or file.\n");
>  
>  	return ret;


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

* Re: [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detectio
@ 2014-11-16 19:31                                           ` Steven Rostedt
  0 siblings, 0 replies; 3633+ messages in thread
From: Steven Rostedt @ 2014-11-16 19:31 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Ingo Molnar, LKML, kernel-janitors, Coccinelle

On Sun, 16 Nov 2014 20:22:22 +0100
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 19:49:39 +0100
> 
> The iput() function was called in three cases by the create_trace_uprobe()
> function during error handling even if the passed variable contained still
> a null pointer. This implementation detail could be improved by the
> introduction of another jump label.

The first patch is fine, and the only reason is to save the few bytes
that the branch check might take. It's in a path that is unlikely to be
hit so it is not a performance issue at all.

This patch is useless. I rather not apply any patch than to create
another jump that skips over the freeing of iput() just because we know
inode is null. That's why we had the if (inode) in the first place.

So Nack on this patch and I'll contemplate applying the first one. I
probably will as it seems rather harmless.

Thanks,

-- Steve


> 
> Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/trace/trace_uprobe.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index ec002c0..a0288f2 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -434,19 +434,24 @@ static int create_trace_uprobe(int argc, char **argv)
>  	arg = strchr(argv[1], ':');
>  	if (!arg) {
>  		ret = -EINVAL;
> -		goto fail_address_parse;
> +		goto fail_address_parse2;
>  	}
>  
>  	*arg++ = '\0';
>  	filename = argv[1];
>  	ret = kern_path(filename, LOOKUP_FOLLOW, &path);
>  	if (ret)
> -		goto fail_address_parse;
> +		goto fail_address_parse2;
>  
>  	inode = igrab(path.dentry->d_inode);
>  	path_put(&path);
>  
> -	if (!inode || !S_ISREG(inode->i_mode)) {
> +	if (!inode) {
> +		ret = -EINVAL;
> +		goto fail_address_parse2;
> +	}
> +
> +	if (!S_ISREG(inode->i_mode)) {
>  		ret = -EINVAL;
>  		goto fail_address_parse;
>  	}
> @@ -554,6 +559,7 @@ error:
>  fail_address_parse:
>  	iput(inode);
>  
> +fail_address_parse2:
>  	pr_info("Failed to parse address or file.\n");
>  
>  	return ret;


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

* Re: [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection
  2014-11-16 19:31                                           ` [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detectio Steven Rostedt
  (?)
@ 2014-11-16 19:34                                             ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 19:34 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: SF Markus Elfring, Ingo Molnar, LKML, kernel-janitors, Coccinelle

On Sun, 16 Nov 2014, Steven Rostedt wrote:

> On Sun, 16 Nov 2014 20:22:22 +0100
> SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 16 Nov 2014 19:49:39 +0100
> >
> > The iput() function was called in three cases by the create_trace_uprobe()
> > function during error handling even if the passed variable contained still
> > a null pointer. This implementation detail could be improved by the
> > introduction of another jump label.
>
> The first patch is fine, and the only reason is to save the few bytes
> that the branch check might take. It's in a path that is unlikely to be
> hit so it is not a performance issue at all.
>
> This patch is useless. I rather not apply any patch than to create
> another jump that skips over the freeing of iput() just because we know
> inode is null. That's why we had the if (inode) in the first place.
>
> So Nack on this patch and I'll contemplate applying the first one. I
> probably will as it seems rather harmless.

I wuold have thought that one could have just returned, like in the cases
above...  But maybe the printed message is useful.

julia

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

* Re: [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detectio
@ 2014-11-16 19:34                                             ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 19:34 UTC (permalink / raw)
  To: cocci

On Sun, 16 Nov 2014, Steven Rostedt wrote:

> On Sun, 16 Nov 2014 20:22:22 +0100
> SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 16 Nov 2014 19:49:39 +0100
> >
> > The iput() function was called in three cases by the create_trace_uprobe()
> > function during error handling even if the passed variable contained still
> > a null pointer. This implementation detail could be improved by the
> > introduction of another jump label.
>
> The first patch is fine, and the only reason is to save the few bytes
> that the branch check might take. It's in a path that is unlikely to be
> hit so it is not a performance issue at all.
>
> This patch is useless. I rather not apply any patch than to create
> another jump that skips over the freeing of iput() just because we know
> inode is null. That's why we had the if (inode) in the first place.
>
> So Nack on this patch and I'll contemplate applying the first one. I
> probably will as it seems rather harmless.

I wuold have thought that one could have just returned, like in the cases
above...  But maybe the printed message is useful.

julia

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

* [Cocci] [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection
@ 2014-11-16 19:34                                             ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-16 19:34 UTC (permalink / raw)
  To: cocci

On Sun, 16 Nov 2014, Steven Rostedt wrote:

> On Sun, 16 Nov 2014 20:22:22 +0100
> SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 16 Nov 2014 19:49:39 +0100
> >
> > The iput() function was called in three cases by the create_trace_uprobe()
> > function during error handling even if the passed variable contained still
> > a null pointer. This implementation detail could be improved by the
> > introduction of another jump label.
>
> The first patch is fine, and the only reason is to save the few bytes
> that the branch check might take. It's in a path that is unlikely to be
> hit so it is not a performance issue at all.
>
> This patch is useless. I rather not apply any patch than to create
> another jump that skips over the freeing of iput() just because we know
> inode is null. That's why we had the if (inode) in the first place.
>
> So Nack on this patch and I'll contemplate applying the first one. I
> probably will as it seems rather harmless.

I wuold have thought that one could have just returned, like in the cases
above...  But maybe the printed message is useful.

julia

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

* Re: [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection
  2014-11-16 19:34                                             ` [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detectio Julia Lawall
@ 2014-11-16 21:49                                               ` Steven Rostedt
  -1 siblings, 0 replies; 3633+ messages in thread
From: Steven Rostedt @ 2014-11-16 21:49 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Ingo Molnar, LKML, kernel-janitors, Coccinelle

On Sun, 16 Nov 2014 20:34:59 +0100 (CET)
Julia Lawall <julia.lawall@lip6.fr> wrote:

> I wuold have thought that one could have just returned, like in the cases
> above...  But maybe the printed message is useful.

Yes, it lets us know that the format string failed to parse.

-- Steve


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

* Re: [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detectio
@ 2014-11-16 21:49                                               ` Steven Rostedt
  0 siblings, 0 replies; 3633+ messages in thread
From: Steven Rostedt @ 2014-11-16 21:49 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Ingo Molnar, LKML, kernel-janitors, Coccinelle

On Sun, 16 Nov 2014 20:34:59 +0100 (CET)
Julia Lawall <julia.lawall@lip6.fr> wrote:

> I wuold have thought that one could have just returned, like in the cases
> above...  But maybe the printed message is useful.

Yes, it lets us know that the format string failed to parse.

-- Steve


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

* [PATCH 1/1] fs-jbd: Deletion of an unnecessary check before the function call "iput"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-16 22:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 22:40 UTC (permalink / raw)
  To: Andrew Morton, Jan Kara, linux-ext4; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 23:23:19 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/jbd/journal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 06fe11e..32fe03e 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -1373,8 +1373,7 @@ int journal_destroy(journal_t *journal)
 	}
 	mutex_unlock(&journal->j_checkpoint_mutex);
 
-	if (journal->j_inode)
-		iput(journal->j_inode);
+	iput(journal->j_inode);
 	if (journal->j_revoke)
 		journal_destroy_revoke(journal);
 	kfree(journal->j_wbuf);
-- 
2.1.3



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

* [PATCH 1/1] fs-jbd: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-16 22:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 22:40 UTC (permalink / raw)
  To: Andrew Morton, Jan Kara, linux-ext4; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 23:23:19 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/jbd/journal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 06fe11e..32fe03e 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -1373,8 +1373,7 @@ int journal_destroy(journal_t *journal)
 	}
 	mutex_unlock(&journal->j_checkpoint_mutex);
 
-	if (journal->j_inode)
-		iput(journal->j_inode);
+	iput(journal->j_inode);
 	if (journal->j_revoke)
 		journal_destroy_revoke(journal);
 	kfree(journal->j_wbuf);
-- 
2.1.3

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

* [PATCH 1/1] fs-jbd: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-16 22:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 22:40 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 23:23:19 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/jbd/journal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 06fe11e..32fe03e 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -1373,8 +1373,7 @@ int journal_destroy(journal_t *journal)
 	}
 	mutex_unlock(&journal->j_checkpoint_mutex);
 
-	if (journal->j_inode)
-		iput(journal->j_inode);
+	iput(journal->j_inode);
 	if (journal->j_revoke)
 		journal_destroy_revoke(journal);
 	kfree(journal->j_wbuf);
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] fs-jbd: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-16 22:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-16 22:40 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Nov 2014 23:23:19 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/jbd/journal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 06fe11e..32fe03e 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -1373,8 +1373,7 @@ int journal_destroy(journal_t *journal)
 	}
 	mutex_unlock(&journal->j_checkpoint_mutex);
 
-	if (journal->j_inode)
-		iput(journal->j_inode);
+	iput(journal->j_inode);
 	if (journal->j_revoke)
 		journal_destroy_revoke(journal);
 	kfree(journal->j_wbuf);
-- 
2.1.3

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-16 11:48                                         ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e SF Markus Elfring
  (?)
@ 2014-11-17  7:34                                           ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-17  7:34 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Eric Paris, linux-kernel, kernel-janitors, trivial, Coccinelle

On Sun, Nov 16, 2014 at 12:48:37PM +0100, SF Markus Elfring wrote:
> > An example of a bug introduced is here:
> > 
> > https://lkml.org/lkml/2014/11/3/505
> 
> It seems that we try to clarify a different interpretation of "bugs", don't we?
> 

You removed the statement from "if (foo) kfree_fsm(foo);" so now it
prints a warning.

drivers/s390/net/fsm.c
    71  void
    72  kfree_fsm(fsm_instance *this)
    73  {
    74          if (this) {
    75                  if (this->f) {
    76                          kfree(this->f->jumpmatrix);
    77                          kfree(this->f);
    78                  }
    79                  kfree(this);
    80          } else
    81                  printk(KERN_WARNING
    82                          "fsm: kfree_fsm called with NULL argument\n");
    83  }

> It is an usual software development challenge to decide on the best source code places
> where to put input parameter validation (and when it can be omitted), isn't it?

No, it's not.  You should just try to write the most readable software
you can instead of removing if statements because you can.

But that's not my point.  My point is that these patches are not always
welcome so we should not merge them through the trivial tree.

regards,
dan carpenter

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e
@ 2014-11-17  7:34                                           ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-17  7:34 UTC (permalink / raw)
  To: cocci

On Sun, Nov 16, 2014 at 12:48:37PM +0100, SF Markus Elfring wrote:
> > An example of a bug introduced is here:
> > 
> > https://lkml.org/lkml/2014/11/3/505
> 
> It seems that we try to clarify a different interpretation of "bugs", don't we?
> 

You removed the statement from "if (foo) kfree_fsm(foo);" so now it
prints a warning.

drivers/s390/net/fsm.c
    71  void
    72  kfree_fsm(fsm_instance *this)
    73  {
    74          if (this) {
    75                  if (this->f) {
    76                          kfree(this->f->jumpmatrix);
    77                          kfree(this->f);
    78                  }
    79                  kfree(this);
    80          } else
    81                  printk(KERN_WARNING
    82                          "fsm: kfree_fsm called with NULL argument\n");
    83  }

> It is an usual software development challenge to decide on the best source code places
> where to put input parameter validation (and when it can be omitted), isn't it?

No, it's not.  You should just try to write the most readable software
you can instead of removing if statements because you can.

But that's not my point.  My point is that these patches are not always
welcome so we should not merge them through the trivial tree.

regards,
dan carpenter

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

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-17  7:34                                           ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-17  7:34 UTC (permalink / raw)
  To: cocci

On Sun, Nov 16, 2014 at 12:48:37PM +0100, SF Markus Elfring wrote:
> > An example of a bug introduced is here:
> > 
> > https://lkml.org/lkml/2014/11/3/505
> 
> It seems that we try to clarify a different interpretation of "bugs", don't we?
> 

You removed the statement from "if (foo) kfree_fsm(foo);" so now it
prints a warning.

drivers/s390/net/fsm.c
    71  void
    72  kfree_fsm(fsm_instance *this)
    73  {
    74          if (this) {
    75                  if (this->f) {
    76                          kfree(this->f->jumpmatrix);
    77                          kfree(this->f);
    78                  }
    79                  kfree(this);
    80          } else
    81                  printk(KERN_WARNING
    82                          "fsm: kfree_fsm called with NULL argument\n");
    83  }

> It is an usual software development challenge to decide on the best source code places
> where to put input parameter validation (and when it can be omitted), isn't it?

No, it's not.  You should just try to write the most readable software
you can instead of removing if statements because you can.

But that's not my point.  My point is that these patches are not always
welcome so we should not merge them through the trivial tree.

regards,
dan carpenter

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

* Re: [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
  2014-11-16 12:34                                   ` SF Markus Elfring
@ 2014-11-17  8:23                                     ` Masami Hiramatsu
  -1 siblings, 0 replies; 3633+ messages in thread
From: Masami Hiramatsu @ 2014-11-17  8:23 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, linux-kernel, kernel-janitors, Coccinelle

(2014/11/16 21:34), SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 12:20:31 +0100
> 
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/kprobes.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 3995f54..f1e7d45 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>  out:
>  	mutex_unlock(&kprobe_mutex);
>  
> -	if (probed_mod)
> -		module_put(probed_mod);
> +	module_put(probed_mod);

This is OK, but I you request a comment line over there so that
code reader can understand it is safe to pass a NULL pointer to
module_put().

# and of course don't touch jump label around that :)

Thank you,

>  
>  	return ret;
>  }
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* Re: [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-17  8:23                                     ` Masami Hiramatsu
  0 siblings, 0 replies; 3633+ messages in thread
From: Masami Hiramatsu @ 2014-11-17  8:23 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, linux-kernel, kernel-janitors, Coccinelle

(2014/11/16 21:34), SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 12:20:31 +0100
> 
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  kernel/kprobes.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 3995f54..f1e7d45 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>  out:
>  	mutex_unlock(&kprobe_mutex);
>  
> -	if (probed_mod)
> -		module_put(probed_mod);
> +	module_put(probed_mod);

This is OK, but I you request a comment line over there so that
code reader can understand it is safe to pass a NULL pointer to
module_put().

# and of course don't touch jump label around that :)

Thank you,

>  
>  	return ret;
>  }
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-17  7:34                                           ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
  (?)
@ 2014-11-17  8:56                                             ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17  8:56 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Eric Paris, linux-kernel, kernel-janitors, trivial, Coccinelle

> You removed the statement from "if (foo) kfree_fsm(foo);" so now it
> prints a warning.
> 
> drivers/s390/net/fsm.c

Would it be better to continue the clarification of affected implementation details
under the discussion topic "s390/net: Deletion of unnecessary checks before two function calls"?


>> It is an usual software development challenge to decide on the best source code places
>> where to put input parameter validation (and when it can be omitted), isn't it?
> 
> No, it's not.  You should just try to write the most readable software
> you can instead of removing if statements because you can.

Additional safety checks have also got an effect on source code readability, haven't they?

Regards,
Markus

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e
@ 2014-11-17  8:56                                             ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17  8:56 UTC (permalink / raw)
  To: cocci

> You removed the statement from "if (foo) kfree_fsm(foo);" so now it
> prints a warning.
> 
> drivers/s390/net/fsm.c

Would it be better to continue the clarification of affected implementation details
under the discussion topic "s390/net: Deletion of unnecessary checks before two function calls"?


>> It is an usual software development challenge to decide on the best source code places
>> where to put input parameter validation (and when it can be omitted), isn't it?
> 
> No, it's not.  You should just try to write the most readable software
> you can instead of removing if statements because you can.

Additional safety checks have also got an effect on source code readability, haven't they?

Regards,
Markus

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

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-17  8:56                                             ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17  8:56 UTC (permalink / raw)
  To: cocci

> You removed the statement from "if (foo) kfree_fsm(foo);" so now it
> prints a warning.
> 
> drivers/s390/net/fsm.c

Would it be better to continue the clarification of affected implementation details
under the discussion topic "s390/net: Deletion of unnecessary checks before two function calls"?


>> It is an usual software development challenge to decide on the best source code places
>> where to put input parameter validation (and when it can be omitted), isn't it?
> 
> No, it's not.  You should just try to write the most readable software
> you can instead of removing if statements because you can.

Additional safety checks have also got an effect on source code readability, haven't they?

Regards,
Markus

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

* [PATCH 1/1] ALSA: hda: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-17 10:07                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 10:07 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 10:44:33 +0100

The functions kfree() and release_firmware() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/hda/hda_codec.c | 3 +--
 sound/pci/hda/hda_intel.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index ec6a7d0..3fe8859 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -827,8 +827,7 @@ static void snd_hda_bus_free(struct hda_bus *bus)
 	WARN_ON(!list_empty(&bus->codec_list));
 	if (bus->workq)
 		flush_workqueue(bus->workq);
-	if (bus->unsol)
-		kfree(bus->unsol);
+	kfree(bus->unsol);
 	if (bus->ops.private_free)
 		bus->ops.private_free(bus);
 	if (bus->workq)
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 0a7f848..b4ec4e1 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1129,8 +1129,7 @@ static int azx_free(struct azx *chip)
 	pci_disable_device(chip->pci);
 	kfree(chip->azx_dev);
 #ifdef CONFIG_SND_HDA_PATCH_LOADER
-	if (chip->fw)
-		release_firmware(chip->fw);
+	release_firmware(chip->fw);
 #endif
 	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
 		hda_display_power(false);
-- 
2.1.3



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

* [PATCH 1/1] ALSA: hda: Deletion of unnecessary checks before two function calls
@ 2014-11-17 10:07                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 10:07 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 10:44:33 +0100

The functions kfree() and release_firmware() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/hda/hda_codec.c | 3 +--
 sound/pci/hda/hda_intel.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index ec6a7d0..3fe8859 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -827,8 +827,7 @@ static void snd_hda_bus_free(struct hda_bus *bus)
 	WARN_ON(!list_empty(&bus->codec_list));
 	if (bus->workq)
 		flush_workqueue(bus->workq);
-	if (bus->unsol)
-		kfree(bus->unsol);
+	kfree(bus->unsol);
 	if (bus->ops.private_free)
 		bus->ops.private_free(bus);
 	if (bus->workq)
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 0a7f848..b4ec4e1 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1129,8 +1129,7 @@ static int azx_free(struct azx *chip)
 	pci_disable_device(chip->pci);
 	kfree(chip->azx_dev);
 #ifdef CONFIG_SND_HDA_PATCH_LOADER
-	if (chip->fw)
-		release_firmware(chip->fw);
+	release_firmware(chip->fw);
 #endif
 	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
 		hda_display_power(false);
-- 
2.1.3



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

* [PATCH 1/1] ALSA: hda: Deletion of unnecessary checks before two function calls
@ 2014-11-17 10:07                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 10:07 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 10:44:33 +0100

The functions kfree() and release_firmware() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/hda/hda_codec.c | 3 +--
 sound/pci/hda/hda_intel.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index ec6a7d0..3fe8859 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -827,8 +827,7 @@ static void snd_hda_bus_free(struct hda_bus *bus)
 	WARN_ON(!list_empty(&bus->codec_list));
 	if (bus->workq)
 		flush_workqueue(bus->workq);
-	if (bus->unsol)
-		kfree(bus->unsol);
+	kfree(bus->unsol);
 	if (bus->ops.private_free)
 		bus->ops.private_free(bus);
 	if (bus->workq)
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 0a7f848..b4ec4e1 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1129,8 +1129,7 @@ static int azx_free(struct azx *chip)
 	pci_disable_device(chip->pci);
 	kfree(chip->azx_dev);
 #ifdef CONFIG_SND_HDA_PATCH_LOADER
-	if (chip->fw)
-		release_firmware(chip->fw);
+	release_firmware(chip->fw);
 #endif
 	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
 		hda_display_power(false);
-- 
2.1.3

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

* [Cocci] [PATCH 1/1] ALSA: hda: Deletion of unnecessary checks before two function calls
@ 2014-11-17 10:07                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 10:07 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 10:44:33 +0100

The functions kfree() and release_firmware() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/hda/hda_codec.c | 3 +--
 sound/pci/hda/hda_intel.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index ec6a7d0..3fe8859 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -827,8 +827,7 @@ static void snd_hda_bus_free(struct hda_bus *bus)
 	WARN_ON(!list_empty(&bus->codec_list));
 	if (bus->workq)
 		flush_workqueue(bus->workq);
-	if (bus->unsol)
-		kfree(bus->unsol);
+	kfree(bus->unsol);
 	if (bus->ops.private_free)
 		bus->ops.private_free(bus);
 	if (bus->workq)
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 0a7f848..b4ec4e1 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1129,8 +1129,7 @@ static int azx_free(struct azx *chip)
 	pci_disable_device(chip->pci);
 	kfree(chip->azx_dev);
 #ifdef CONFIG_SND_HDA_PATCH_LOADER
-	if (chip->fw)
-		release_firmware(chip->fw);
+	release_firmware(chip->fw);
 #endif
 	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
 		hda_display_power(false);
-- 
2.1.3

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

* [PATCH 1/1] ALSA: ice17xx: Deletion of unnecessary checks before the function call "snd_ac97_resume"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-17 10:34                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 10:34 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 11:28:02 +0100

The snd_ac97_resume() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/ice1712/ice1712.c | 3 +--
 sound/pci/ice1712/ice1724.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 87f7fc4..e1e18b5 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2905,8 +2905,7 @@ static int snd_ice1712_resume(struct device *dev)
 	outw(ice->pm_saved_spdif_ctrl, ICEMT(ice, ROUTE_SPDOUT));
 	outw(ice->pm_saved_route, ICEMT(ice, ROUTE_PSDOUT03));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 08cb08a..0e56835 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2884,8 +2884,7 @@ static int snd_vt1724_resume(struct device *dev)
 	outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG));
 	outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
-- 
2.1.3



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

* [PATCH 1/1] ALSA: ice17xx: Deletion of unnecessary checks before the function call "snd_ac97_resume"
@ 2014-11-17 10:34                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 10:34 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 11:28:02 +0100

The snd_ac97_resume() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/ice1712/ice1712.c | 3 +--
 sound/pci/ice1712/ice1724.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 87f7fc4..e1e18b5 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2905,8 +2905,7 @@ static int snd_ice1712_resume(struct device *dev)
 	outw(ice->pm_saved_spdif_ctrl, ICEMT(ice, ROUTE_SPDOUT));
 	outw(ice->pm_saved_route, ICEMT(ice, ROUTE_PSDOUT03));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 08cb08a..0e56835 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2884,8 +2884,7 @@ static int snd_vt1724_resume(struct device *dev)
 	outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG));
 	outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
-- 
2.1.3



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

* [PATCH 1/1] ALSA: ice17xx: Deletion of unnecessary checks before the function call "snd_ac97_resume"
@ 2014-11-17 10:34                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 10:34 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 11:28:02 +0100

The snd_ac97_resume() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/ice1712/ice1712.c | 3 +--
 sound/pci/ice1712/ice1724.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 87f7fc4..e1e18b5 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2905,8 +2905,7 @@ static int snd_ice1712_resume(struct device *dev)
 	outw(ice->pm_saved_spdif_ctrl, ICEMT(ice, ROUTE_SPDOUT));
 	outw(ice->pm_saved_route, ICEMT(ice, ROUTE_PSDOUT03));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 08cb08a..0e56835 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2884,8 +2884,7 @@ static int snd_vt1724_resume(struct device *dev)
 	outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG));
 	outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
-- 
2.1.3

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

* [Cocci] [PATCH 1/1] ALSA: ice17xx: Deletion of unnecessary checks before the function call "snd_ac97_resume"
@ 2014-11-17 10:34                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 10:34 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 11:28:02 +0100

The snd_ac97_resume() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/ice1712/ice1712.c | 3 +--
 sound/pci/ice1712/ice1724.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 87f7fc4..e1e18b5 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2905,8 +2905,7 @@ static int snd_ice1712_resume(struct device *dev)
 	outw(ice->pm_saved_spdif_ctrl, ICEMT(ice, ROUTE_SPDOUT));
 	outw(ice->pm_saved_route, ICEMT(ice, ROUTE_PSDOUT03));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 08cb08a..0e56835 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2884,8 +2884,7 @@ static int snd_vt1724_resume(struct device *dev)
 	outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG));
 	outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
-- 
2.1.3

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

* [PATCH 1/1] ALSA: lola: Deletion of an unnecessary check before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-17 11:48                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 11:48 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 12:42:16 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/lola/lola_mixer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/lola/lola_mixer.c b/sound/pci/lola/lola_mixer.c
index 782f4d8..e7fe15d 100644
--- a/sound/pci/lola/lola_mixer.c
+++ b/sound/pci/lola/lola_mixer.c
@@ -108,8 +108,7 @@ int lola_init_pins(struct lola *chip, int dir, int *nidp)
 
 void lola_free_mixer(struct lola *chip)
 {
-	if (chip->mixer.array_saved)
-		vfree(chip->mixer.array_saved);
+	vfree(chip->mixer.array_saved);
 }
 
 int lola_init_mixer_widget(struct lola *chip, int nid)
-- 
2.1.3



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

* [PATCH 1/1] ALSA: lola: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-17 11:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 11:48 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 12:42:16 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/lola/lola_mixer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/lola/lola_mixer.c b/sound/pci/lola/lola_mixer.c
index 782f4d8..e7fe15d 100644
--- a/sound/pci/lola/lola_mixer.c
+++ b/sound/pci/lola/lola_mixer.c
@@ -108,8 +108,7 @@ int lola_init_pins(struct lola *chip, int dir, int *nidp)
 
 void lola_free_mixer(struct lola *chip)
 {
-	if (chip->mixer.array_saved)
-		vfree(chip->mixer.array_saved);
+	vfree(chip->mixer.array_saved);
 }
 
 int lola_init_mixer_widget(struct lola *chip, int nid)
-- 
2.1.3



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

* [PATCH 1/1] ALSA: lola: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-17 11:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 11:48 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 12:42:16 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/lola/lola_mixer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/lola/lola_mixer.c b/sound/pci/lola/lola_mixer.c
index 782f4d8..e7fe15d 100644
--- a/sound/pci/lola/lola_mixer.c
+++ b/sound/pci/lola/lola_mixer.c
@@ -108,8 +108,7 @@ int lola_init_pins(struct lola *chip, int dir, int *nidp)
 
 void lola_free_mixer(struct lola *chip)
 {
-	if (chip->mixer.array_saved)
-		vfree(chip->mixer.array_saved);
+	vfree(chip->mixer.array_saved);
 }
 
 int lola_init_mixer_widget(struct lola *chip, int nid)
-- 
2.1.3

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

* [Cocci] [PATCH 1/1] ALSA: lola: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-17 11:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 11:48 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 12:42:16 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/lola/lola_mixer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/lola/lola_mixer.c b/sound/pci/lola/lola_mixer.c
index 782f4d8..e7fe15d 100644
--- a/sound/pci/lola/lola_mixer.c
+++ b/sound/pci/lola/lola_mixer.c
@@ -108,8 +108,7 @@ int lola_init_pins(struct lola *chip, int dir, int *nidp)
 
 void lola_free_mixer(struct lola *chip)
 {
-	if (chip->mixer.array_saved)
-		vfree(chip->mixer.array_saved);
+	vfree(chip->mixer.array_saved);
 }
 
 int lola_init_mixer_widget(struct lola *chip, int nid)
-- 
2.1.3

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

* [PATCH 1/1] ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmware"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-17 12:12                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 12:12 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 13:04:14 +0100

The release_firmware() function tests whether its argument is NULL and then
return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/rme9652/hdsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 7646ba1..0ae568d 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -5368,8 +5368,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
 
 	snd_hdsp_free_buffers(hdsp);
 
-	if (hdsp->firmware)
-		release_firmware(hdsp->firmware);
+	release_firmware(hdsp->firmware);
 	vfree(hdsp->fw_uploaded);
 
 	if (hdsp->iobase)
-- 
2.1.3



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

* [PATCH 1/1] ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmware"
@ 2014-11-17 12:12                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 12:12 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 13:04:14 +0100

The release_firmware() function tests whether its argument is NULL and then
return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/rme9652/hdsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 7646ba1..0ae568d 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -5368,8 +5368,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
 
 	snd_hdsp_free_buffers(hdsp);
 
-	if (hdsp->firmware)
-		release_firmware(hdsp->firmware);
+	release_firmware(hdsp->firmware);
 	vfree(hdsp->fw_uploaded);
 
 	if (hdsp->iobase)
-- 
2.1.3



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

* [PATCH 1/1] ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmware"
@ 2014-11-17 12:12                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 12:12 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 13:04:14 +0100

The release_firmware() function tests whether its argument is NULL and then
return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/rme9652/hdsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 7646ba1..0ae568d 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -5368,8 +5368,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
 
 	snd_hdsp_free_buffers(hdsp);
 
-	if (hdsp->firmware)
-		release_firmware(hdsp->firmware);
+	release_firmware(hdsp->firmware);
 	vfree(hdsp->fw_uploaded);
 
 	if (hdsp->iobase)
-- 
2.1.3



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

* [Cocci] [PATCH 1/1] ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmware"
@ 2014-11-17 12:12                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 12:12 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 13:04:14 +0100

The release_firmware() function tests whether its argument is NULL and then
return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/rme9652/hdsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 7646ba1..0ae568d 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -5368,8 +5368,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
 
 	snd_hdsp_free_buffers(hdsp);
 
-	if (hdsp->firmware)
-		release_firmware(hdsp->firmware);
+	release_firmware(hdsp->firmware);
 	vfree(hdsp->fw_uploaded);
 
 	if (hdsp->iobase)
-- 
2.1.3

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

* [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-17 12:41                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 12:41 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 13:35:54 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/ppc/pmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 8a431bc..5a13b22 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -887,8 +887,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
 		}
 	}
 
-	if (chip->pdev)
-		pci_dev_put(chip->pdev);
+	pci_dev_put(chip->pdev);
 	of_node_put(chip->node);
 	kfree(chip);
 	return 0;
-- 
2.1.3



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

* [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-17 12:41                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 12:41 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 13:35:54 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/ppc/pmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 8a431bc..5a13b22 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -887,8 +887,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
 		}
 	}
 
-	if (chip->pdev)
-		pci_dev_put(chip->pdev);
+	pci_dev_put(chip->pdev);
 	of_node_put(chip->node);
 	kfree(chip);
 	return 0;
-- 
2.1.3



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

* [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-17 12:41                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 12:41 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 13:35:54 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/ppc/pmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 8a431bc..5a13b22 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -887,8 +887,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
 		}
 	}
 
-	if (chip->pdev)
-		pci_dev_put(chip->pdev);
+	pci_dev_put(chip->pdev);
 	of_node_put(chip->node);
 	kfree(chip);
 	return 0;
-- 
2.1.3

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

* [Cocci] [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-17 12:41                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 12:41 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 13:35:54 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/ppc/pmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 8a431bc..5a13b22 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -887,8 +887,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
 		}
 	}
 
-	if (chip->pdev)
-		pci_dev_put(chip->pdev);
+	pci_dev_put(chip->pdev);
 	of_node_put(chip->node);
 	kfree(chip);
 	return 0;
-- 
2.1.3

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

* Re: [PATCH 1/1] ALSA: hda: Deletion of unnecessary checks before two function calls
  2014-11-17 10:07                                   ` SF Markus Elfring
@ 2014-11-17 12:45                                     ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Coccinelle

At Mon, 17 Nov 2014 11:07:04 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 10:44:33 +0100
> 
> The functions kfree() and release_firmware() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/pci/hda/hda_codec.c | 3 +--
>  sound/pci/hda/hda_intel.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
> index ec6a7d0..3fe8859 100644
> --- a/sound/pci/hda/hda_codec.c
> +++ b/sound/pci/hda/hda_codec.c
> @@ -827,8 +827,7 @@ static void snd_hda_bus_free(struct hda_bus *bus)
>  	WARN_ON(!list_empty(&bus->codec_list));
>  	if (bus->workq)
>  		flush_workqueue(bus->workq);
> -	if (bus->unsol)
> -		kfree(bus->unsol);
> +	kfree(bus->unsol);
>  	if (bus->ops.private_free)
>  		bus->ops.private_free(bus);
>  	if (bus->workq)
> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> index 0a7f848..b4ec4e1 100644
> --- a/sound/pci/hda/hda_intel.c
> +++ b/sound/pci/hda/hda_intel.c
> @@ -1129,8 +1129,7 @@ static int azx_free(struct azx *chip)
>  	pci_disable_device(chip->pci);
>  	kfree(chip->azx_dev);
>  #ifdef CONFIG_SND_HDA_PATCH_LOADER
> -	if (chip->fw)
> -		release_firmware(chip->fw);
> +	release_firmware(chip->fw);
>  #endif
>  	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
>  		hda_display_power(false);
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: hda: Deletion of unnecessary checks before two function calls
@ 2014-11-17 12:45                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Coccinelle

At Mon, 17 Nov 2014 11:07:04 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 10:44:33 +0100
> 
> The functions kfree() and release_firmware() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/pci/hda/hda_codec.c | 3 +--
>  sound/pci/hda/hda_intel.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
> index ec6a7d0..3fe8859 100644
> --- a/sound/pci/hda/hda_codec.c
> +++ b/sound/pci/hda/hda_codec.c
> @@ -827,8 +827,7 @@ static void snd_hda_bus_free(struct hda_bus *bus)
>  	WARN_ON(!list_empty(&bus->codec_list));
>  	if (bus->workq)
>  		flush_workqueue(bus->workq);
> -	if (bus->unsol)
> -		kfree(bus->unsol);
> +	kfree(bus->unsol);
>  	if (bus->ops.private_free)
>  		bus->ops.private_free(bus);
>  	if (bus->workq)
> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> index 0a7f848..b4ec4e1 100644
> --- a/sound/pci/hda/hda_intel.c
> +++ b/sound/pci/hda/hda_intel.c
> @@ -1129,8 +1129,7 @@ static int azx_free(struct azx *chip)
>  	pci_disable_device(chip->pci);
>  	kfree(chip->azx_dev);
>  #ifdef CONFIG_SND_HDA_PATCH_LOADER
> -	if (chip->fw)
> -		release_firmware(chip->fw);
> +	release_firmware(chip->fw);
>  #endif
>  	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
>  		hda_display_power(false);
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: ice17xx: Deletion of unnecessary checks before the function call "snd_ac97_resume"
  2014-11-17 10:34                                   ` SF Markus Elfring
@ 2014-11-17 12:46                                     ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:46 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Coccinelle

At Mon, 17 Nov 2014 11:34:22 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 11:28:02 +0100
> 
> The snd_ac97_resume() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/pci/ice1712/ice1712.c | 3 +--
>  sound/pci/ice1712/ice1724.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
> index 87f7fc4..e1e18b5 100644
> --- a/sound/pci/ice1712/ice1712.c
> +++ b/sound/pci/ice1712/ice1712.c
> @@ -2905,8 +2905,7 @@ static int snd_ice1712_resume(struct device *dev)
>  	outw(ice->pm_saved_spdif_ctrl, ICEMT(ice, ROUTE_SPDOUT));
>  	outw(ice->pm_saved_route, ICEMT(ice, ROUTE_PSDOUT03));
>  
> -	if (ice->ac97)
> -		snd_ac97_resume(ice->ac97);
> +	snd_ac97_resume(ice->ac97);
>  
>  	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
>  	return 0;
> diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
> index 08cb08a..0e56835 100644
> --- a/sound/pci/ice1712/ice1724.c
> +++ b/sound/pci/ice1712/ice1724.c
> @@ -2884,8 +2884,7 @@ static int snd_vt1724_resume(struct device *dev)
>  	outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG));
>  	outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK));
>  
> -	if (ice->ac97)
> -		snd_ac97_resume(ice->ac97);
> +	snd_ac97_resume(ice->ac97);
>  
>  	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
>  	return 0;
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: ice17xx: Deletion of unnecessary checks before the function call "snd_ac97_res
@ 2014-11-17 12:46                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:46 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Coccinelle

At Mon, 17 Nov 2014 11:34:22 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 11:28:02 +0100
> 
> The snd_ac97_resume() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/pci/ice1712/ice1712.c | 3 +--
>  sound/pci/ice1712/ice1724.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
> index 87f7fc4..e1e18b5 100644
> --- a/sound/pci/ice1712/ice1712.c
> +++ b/sound/pci/ice1712/ice1712.c
> @@ -2905,8 +2905,7 @@ static int snd_ice1712_resume(struct device *dev)
>  	outw(ice->pm_saved_spdif_ctrl, ICEMT(ice, ROUTE_SPDOUT));
>  	outw(ice->pm_saved_route, ICEMT(ice, ROUTE_PSDOUT03));
>  
> -	if (ice->ac97)
> -		snd_ac97_resume(ice->ac97);
> +	snd_ac97_resume(ice->ac97);
>  
>  	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
>  	return 0;
> diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
> index 08cb08a..0e56835 100644
> --- a/sound/pci/ice1712/ice1724.c
> +++ b/sound/pci/ice1712/ice1724.c
> @@ -2884,8 +2884,7 @@ static int snd_vt1724_resume(struct device *dev)
>  	outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG));
>  	outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK));
>  
> -	if (ice->ac97)
> -		snd_ac97_resume(ice->ac97);
> +	snd_ac97_resume(ice->ac97);
>  
>  	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
>  	return 0;
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: lola: Deletion of an unnecessary check before the function call "vfree"
  2014-11-17 11:48                                   ` SF Markus Elfring
@ 2014-11-17 12:46                                     ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:46 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Coccinelle

At Mon, 17 Nov 2014 12:48:44 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 12:42:16 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/pci/lola/lola_mixer.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/pci/lola/lola_mixer.c b/sound/pci/lola/lola_mixer.c
> index 782f4d8..e7fe15d 100644
> --- a/sound/pci/lola/lola_mixer.c
> +++ b/sound/pci/lola/lola_mixer.c
> @@ -108,8 +108,7 @@ int lola_init_pins(struct lola *chip, int dir, int *nidp)
>  
>  void lola_free_mixer(struct lola *chip)
>  {
> -	if (chip->mixer.array_saved)
> -		vfree(chip->mixer.array_saved);
> +	vfree(chip->mixer.array_saved);
>  }
>  
>  int lola_init_mixer_widget(struct lola *chip, int nid)
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: lola: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-17 12:46                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:46 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Coccinelle

At Mon, 17 Nov 2014 12:48:44 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 12:42:16 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/pci/lola/lola_mixer.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/pci/lola/lola_mixer.c b/sound/pci/lola/lola_mixer.c
> index 782f4d8..e7fe15d 100644
> --- a/sound/pci/lola/lola_mixer.c
> +++ b/sound/pci/lola/lola_mixer.c
> @@ -108,8 +108,7 @@ int lola_init_pins(struct lola *chip, int dir, int *nidp)
>  
>  void lola_free_mixer(struct lola *chip)
>  {
> -	if (chip->mixer.array_saved)
> -		vfree(chip->mixer.array_saved);
> +	vfree(chip->mixer.array_saved);
>  }
>  
>  int lola_init_mixer_widget(struct lola *chip, int nid)
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmware"
  2014-11-17 12:12                                   ` SF Markus Elfring
@ 2014-11-17 12:47                                     ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Coccinelle

At Mon, 17 Nov 2014 13:12:15 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 13:04:14 +0100
> 
> The release_firmware() function tests whether its argument is NULL and then
> return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/pci/rme9652/hdsp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
> index 7646ba1..0ae568d 100644
> --- a/sound/pci/rme9652/hdsp.c
> +++ b/sound/pci/rme9652/hdsp.c
> @@ -5368,8 +5368,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
>  
>  	snd_hdsp_free_buffers(hdsp);
>  
> -	if (hdsp->firmware)
> -		release_firmware(hdsp->firmware);
> +	release_firmware(hdsp->firmware);
>  	vfree(hdsp->fw_uploaded);
>  
>  	if (hdsp->iobase)
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmw
@ 2014-11-17 12:47                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Coccinelle

At Mon, 17 Nov 2014 13:12:15 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 13:04:14 +0100
> 
> The release_firmware() function tests whether its argument is NULL and then
> return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/pci/rme9652/hdsp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
> index 7646ba1..0ae568d 100644
> --- a/sound/pci/rme9652/hdsp.c
> +++ b/sound/pci/rme9652/hdsp.c
> @@ -5368,8 +5368,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
>  
>  	snd_hdsp_free_buffers(hdsp);
>  
> -	if (hdsp->firmware)
> -		release_firmware(hdsp->firmware);
> +	release_firmware(hdsp->firmware);
>  	vfree(hdsp->fw_uploaded);
>  
>  	if (hdsp->iobase)
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_put"
  2014-11-17 12:41                                   ` SF Markus Elfring
  (?)
@ 2014-11-17 12:53                                     ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:53 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Coccinelle

At Mon, 17 Nov 2014 13:41:19 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 13:35:54 +0100
> 
> The pci_dev_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/ppc/pmac.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
> index 8a431bc..5a13b22 100644
> --- a/sound/ppc/pmac.c
> +++ b/sound/ppc/pmac.c
> @@ -887,8 +887,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
>  		}
>  	}
>  
> -	if (chip->pdev)
> -		pci_dev_put(chip->pdev);
> +	pci_dev_put(chip->pdev);
>  	of_node_put(chip->node);
>  	kfree(chip);
>  	return 0;
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_p
@ 2014-11-17 12:53                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:53 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Coccinelle, alsa-devel, kernel-janitors, LKML

At Mon, 17 Nov 2014 13:41:19 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 13:35:54 +0100
> 
> The pci_dev_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/ppc/pmac.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
> index 8a431bc..5a13b22 100644
> --- a/sound/ppc/pmac.c
> +++ b/sound/ppc/pmac.c
> @@ -887,8 +887,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
>  		}
>  	}
>  
> -	if (chip->pdev)
> -		pci_dev_put(chip->pdev);
> +	pci_dev_put(chip->pdev);
>  	of_node_put(chip->node);
>  	kfree(chip);
>  	return 0;
> -- 
> 2.1.3
> 
> 

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

* Re: [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-17 12:53                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-17 12:53 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Coccinelle, alsa-devel, kernel-janitors, LKML

At Mon, 17 Nov 2014 13:41:19 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 13:35:54 +0100
> 
> The pci_dev_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/ppc/pmac.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
> index 8a431bc..5a13b22 100644
> --- a/sound/ppc/pmac.c
> +++ b/sound/ppc/pmac.c
> @@ -887,8 +887,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
>  		}
>  	}
>  
> -	if (chip->pdev)
> -		pci_dev_put(chip->pdev);
> +	pci_dev_put(chip->pdev);
>  	of_node_put(chip->node);
>  	kfree(chip);
>  	return 0;
> -- 
> 2.1.3
> 
> 

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

* ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-17 13:15                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 13:15 UTC (permalink / raw)
  To: Jarkko Nikula, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Peter Ujfalusi, Takashi Iwai, linux-omap, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 14:05:27 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/soc/omap/mcbsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index 86c7538..68a1252 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -621,8 +621,7 @@ void omap_mcbsp_free(struct omap_mcbsp *mcbsp)
 	mcbsp->reg_cache = NULL;
 	spin_unlock(&mcbsp->lock);
 
-	if (reg_cache)
-		kfree(reg_cache);
+	kfree(reg_cache);
 }
 
 /*
-- 
2.1.3


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

* ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-17 13:15                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 13:15 UTC (permalink / raw)
  To: Jarkko Nikula, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Peter Ujfalusi, Takashi Iwai, linux-omap, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 14:05:27 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/soc/omap/mcbsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index 86c7538..68a1252 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -621,8 +621,7 @@ void omap_mcbsp_free(struct omap_mcbsp *mcbsp)
 	mcbsp->reg_cache = NULL;
 	spin_unlock(&mcbsp->lock);
 
-	if (reg_cache)
-		kfree(reg_cache);
+	kfree(reg_cache);
 }
 
 /*
-- 
2.1.3


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

* ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-17 13:15                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 13:15 UTC (permalink / raw)
  To: Jarkko Nikula, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Peter Ujfalusi, Takashi Iwai, linux-omap, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 14:05:27 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/soc/omap/mcbsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index 86c7538..68a1252 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -621,8 +621,7 @@ void omap_mcbsp_free(struct omap_mcbsp *mcbsp)
 	mcbsp->reg_cache = NULL;
 	spin_unlock(&mcbsp->lock);
 
-	if (reg_cache)
-		kfree(reg_cache);
+	kfree(reg_cache);
 }
 
 /*
-- 
2.1.3

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

* [PATCH 1/1] tools lib traceevent: Deletion of an unnecessary check before the function call "free_arg"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-17 13:42                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 13:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 14:38:14 +0100

The free_arg() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 tools/lib/traceevent/parse-filter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index b502344..78debaf 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1237,8 +1237,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
 	if (filter_type == NULL)
 		return PEVENT_ERRNO__MEM_ALLOC_FAILED;
 
-	if (filter_type->filter)
-		free_arg(filter_type->filter);
+	free_arg(filter_type->filter);
 	filter_type->filter = arg;
 
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] tools lib traceevent: Deletion of an unnecessary check before the function call "free_ar
@ 2014-11-17 13:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 13:42 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 14:38:14 +0100

The free_arg() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 tools/lib/traceevent/parse-filter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index b502344..78debaf 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1237,8 +1237,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
 	if (filter_type = NULL)
 		return PEVENT_ERRNO__MEM_ALLOC_FAILED;
 
-	if (filter_type->filter)
-		free_arg(filter_type->filter);
+	free_arg(filter_type->filter);
 	filter_type->filter = arg;
 
 	return 0;
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] tools lib traceevent: Deletion of an unnecessary check before the function call "free_arg"
@ 2014-11-17 13:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 13:42 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 14:38:14 +0100

The free_arg() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 tools/lib/traceevent/parse-filter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index b502344..78debaf 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1237,8 +1237,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
 	if (filter_type == NULL)
 		return PEVENT_ERRNO__MEM_ALLOC_FAILED;
 
-	if (filter_type->filter)
-		free_arg(filter_type->filter);
+	free_arg(filter_type->filter);
 	filter_type->filter = arg;
 
 	return 0;
-- 
2.1.3

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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-17  8:56                                             ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e SF Markus Elfring
  (?)
@ 2014-11-17 13:45                                               ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-17 13:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Eric Paris, linux-kernel, kernel-janitors, trivial, Coccinelle

On Mon, Nov 17, 2014 at 09:56:22AM +0100, SF Markus Elfring wrote:
> > You removed the statement from "if (foo) kfree_fsm(foo);" so now it
> > prints a warning.
> > 
> > drivers/s390/net/fsm.c
> 
> Would it be better to continue the clarification of affected implementation details
> under the discussion topic "s390/net: Deletion of unnecessary checks before two function calls"?
> 

What do you want me to clarify?  Do you still not see the bug?

regards,
dan carpenter


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

* Re: [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e
@ 2014-11-17 13:45                                               ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-17 13:45 UTC (permalink / raw)
  To: cocci

On Mon, Nov 17, 2014 at 09:56:22AM +0100, SF Markus Elfring wrote:
> > You removed the statement from "if (foo) kfree_fsm(foo);" so now it
> > prints a warning.
> > 
> > drivers/s390/net/fsm.c
> 
> Would it be better to continue the clarification of affected implementation details
> under the discussion topic "s390/net: Deletion of unnecessary checks before two function calls"?
> 

What do you want me to clarify?  Do you still not see the bug?

regards,
dan carpenter


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

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-17 13:45                                               ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-17 13:45 UTC (permalink / raw)
  To: cocci

On Mon, Nov 17, 2014 at 09:56:22AM +0100, SF Markus Elfring wrote:
> > You removed the statement from "if (foo) kfree_fsm(foo);" so now it
> > prints a warning.
> > 
> > drivers/s390/net/fsm.c
> 
> Would it be better to continue the clarification of affected implementation details
> under the discussion topic "s390/net: Deletion of unnecessary checks before two function calls"?
> 

What do you want me to clarify?  Do you still not see the bug?

regards,
dan carpenter

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

* Re: s390/net: Deletion of unnecessary checks before two function calls
  2014-11-17 13:45                                               ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
@ 2014-11-17 14:30                                                 ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 14:30 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: linux-kernel, kernel-janitors, Coccinelle, Eric Paris,
	Frank Blaschka, Heiko Carstens, Martin Schwidefsky, Ursula Braun,
	linux390, linux-s390

> What do you want me to clarify?  Do you still not see the bug?

Would you like to point out that you notice the warning message
"fsm: kfree_fsm called with NULL argument" after my update suggestion?

How do you think about to share a bit more information about the
corresponding function call graph from your test system?

Regards,
Markus


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

* Re: s390/net: Deletion of unnecessary checks before two function calls
@ 2014-11-17 14:30                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 14:30 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: linux-kernel, kernel-janitors, Coccinelle, Eric Paris,
	Frank Blaschka, Heiko Carstens, Martin Schwidefsky, Ursula Braun,
	linux390, linux-s390

> What do you want me to clarify?  Do you still not see the bug?

Would you like to point out that you notice the warning message
"fsm: kfree_fsm called with NULL argument" after my update suggestion?

How do you think about to share a bit more information about the
corresponding function call graph from your test system?

Regards,
Markus


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

* [PATCH 1/1] perf tools: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-17 17:11                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 17:11 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ingo Molnar, Paul Mackerras, Peter Zijlstra
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 18:05:57 +0100

The functions free_event_desc() and strfilter__delete() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 tools/perf/builtin-probe.c | 6 ++----
 tools/perf/util/header.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index c63fa29..1b72bf2 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -254,8 +254,7 @@ static int opt_set_filter(const struct option *opt __maybe_unused,
 
 	if (str) {
 		pr_debug2("Set filter: %s\n", str);
-		if (params.filter)
-			strfilter__delete(params.filter);
+		strfilter__delete(params.filter);
 		params.filter = strfilter__new(str, &err);
 		if (!params.filter) {
 			pr_err("Filter parse error at %td.\n", err - str + 1);
@@ -283,8 +282,7 @@ static void cleanup_params(void)
 		strlist__delete(params.dellist);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 158c787..a62fbc6 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1367,8 +1367,7 @@ out:
 	free(buf);
 	return events;
 error:
-	if (events)
-		free_event_desc(events);
+	free_event_desc(events);
 	events = NULL;
 	goto out;
 }
-- 
2.1.3


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

* [PATCH 1/1] perf tools: Deletion of unnecessary checks before two function calls
@ 2014-11-17 17:11                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 17:11 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 18:05:57 +0100

The functions free_event_desc() and strfilter__delete() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 tools/perf/builtin-probe.c | 6 ++----
 tools/perf/util/header.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index c63fa29..1b72bf2 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -254,8 +254,7 @@ static int opt_set_filter(const struct option *opt __maybe_unused,
 
 	if (str) {
 		pr_debug2("Set filter: %s\n", str);
-		if (params.filter)
-			strfilter__delete(params.filter);
+		strfilter__delete(params.filter);
 		params.filter = strfilter__new(str, &err);
 		if (!params.filter) {
 			pr_err("Filter parse error at %td.\n", err - str + 1);
@@ -283,8 +282,7 @@ static void cleanup_params(void)
 		strlist__delete(params.dellist);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 158c787..a62fbc6 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1367,8 +1367,7 @@ out:
 	free(buf);
 	return events;
 error:
-	if (events)
-		free_event_desc(events);
+	free_event_desc(events);
 	events = NULL;
 	goto out;
 }
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] perf tools: Deletion of unnecessary checks before two function calls
@ 2014-11-17 17:11                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 17:11 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 18:05:57 +0100

The functions free_event_desc() and strfilter__delete() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 tools/perf/builtin-probe.c | 6 ++----
 tools/perf/util/header.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index c63fa29..1b72bf2 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -254,8 +254,7 @@ static int opt_set_filter(const struct option *opt __maybe_unused,
 
 	if (str) {
 		pr_debug2("Set filter: %s\n", str);
-		if (params.filter)
-			strfilter__delete(params.filter);
+		strfilter__delete(params.filter);
 		params.filter = strfilter__new(str, &err);
 		if (!params.filter) {
 			pr_err("Filter parse error at %td.\n", err - str + 1);
@@ -283,8 +282,7 @@ static void cleanup_params(void)
 		strlist__delete(params.dellist);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 158c787..a62fbc6 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1367,8 +1367,7 @@ out:
 	free(buf);
 	return events;
 error:
-	if (events)
-		free_event_desc(events);
+	free_event_desc(events);
 	events = NULL;
 	goto out;
 }
-- 
2.1.3

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

* [PATCH 1/1] mm/zswap: Deletion of an unnecessary check before the function call "free_percpu"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-17 17:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 17:40 UTC (permalink / raw)
  To: Seth Jennings, linux-mm; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 18:33:33 +0100

The free_percpu() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 mm/zswap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index ea064c1..35629f0 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -152,8 +152,7 @@ static int __init zswap_comp_init(void)
 static void zswap_comp_exit(void)
 {
 	/* free percpu transforms */
-	if (zswap_comp_pcpu_tfms)
-		free_percpu(zswap_comp_pcpu_tfms);
+	free_percpu(zswap_comp_pcpu_tfms);
 }
 
 /*********************************
-- 
2.1.3


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

* [PATCH 1/1] mm/zswap: Deletion of an unnecessary check before the function call "free_percpu"
@ 2014-11-17 17:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 17:40 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 18:33:33 +0100

The free_percpu() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 mm/zswap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index ea064c1..35629f0 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -152,8 +152,7 @@ static int __init zswap_comp_init(void)
 static void zswap_comp_exit(void)
 {
 	/* free percpu transforms */
-	if (zswap_comp_pcpu_tfms)
-		free_percpu(zswap_comp_pcpu_tfms);
+	free_percpu(zswap_comp_pcpu_tfms);
 }
 
 /*********************************
-- 
2.1.3


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

* [PATCH 1/1] mm/zswap: Deletion of an unnecessary check before the function call "free_percpu"
@ 2014-11-17 17:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 17:40 UTC (permalink / raw)
  To: Seth Jennings, linux-mm; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 18:33:33 +0100

The free_percpu() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 mm/zswap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index ea064c1..35629f0 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -152,8 +152,7 @@ static int __init zswap_comp_init(void)
 static void zswap_comp_exit(void)
 {
 	/* free percpu transforms */
-	if (zswap_comp_pcpu_tfms)
-		free_percpu(zswap_comp_pcpu_tfms);
+	free_percpu(zswap_comp_pcpu_tfms);
 }
 
 /*********************************
-- 
2.1.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [Cocci] [PATCH 1/1] mm/zswap: Deletion of an unnecessary check before the function call "free_percpu"
@ 2014-11-17 17:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 17:40 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 18:33:33 +0100

The free_percpu() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 mm/zswap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index ea064c1..35629f0 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -152,8 +152,7 @@ static int __init zswap_comp_init(void)
 static void zswap_comp_exit(void)
 {
 	/* free percpu transforms */
-	if (zswap_comp_pcpu_tfms)
-		free_percpu(zswap_comp_pcpu_tfms);
+	free_percpu(zswap_comp_pcpu_tfms);
 }
 
 /*********************************
-- 
2.1.3

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

* [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-17 18:19                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 18:19 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 19:13:56 +0100

The hfs_bnode_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/hfs/bfind.c     | 3 +--
 fs/hfs/brec.c      | 3 +--
 fs/hfsplus/bfind.c | 3 +--
 fs/hfsplus/brec.c  | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index de69d8a..0e26523 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
index 9f4ee7f..3a52b2c 100644
--- a/fs/hfs/brec.c
+++ b/fs/hfs/brec.c
@@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index c1422d9..7be88e3 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 6e560d5..59bab47 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
-- 
2.1.3


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

* [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"
@ 2014-11-17 18:19                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 18:19 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 19:13:56 +0100

The hfs_bnode_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/hfs/bfind.c     | 3 +--
 fs/hfs/brec.c      | 3 +--
 fs/hfsplus/bfind.c | 3 +--
 fs/hfsplus/brec.c  | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index de69d8a..0e26523 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
index 9f4ee7f..3a52b2c 100644
--- a/fs/hfs/brec.c
+++ b/fs/hfs/brec.c
@@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index c1422d9..7be88e3 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 6e560d5..59bab47 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
-- 
2.1.3

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

* [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"
@ 2014-11-17 18:19                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 18:19 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 19:13:56 +0100

The hfs_bnode_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/hfs/bfind.c     | 3 +--
 fs/hfs/brec.c      | 3 +--
 fs/hfsplus/bfind.c | 3 +--
 fs/hfsplus/brec.c  | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index de69d8a..0e26523 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
index 9f4ee7f..3a52b2c 100644
--- a/fs/hfs/brec.c
+++ b/fs/hfs/brec.c
@@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index c1422d9..7be88e3 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 6e560d5..59bab47 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"
@ 2014-11-17 18:19                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 18:19 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 19:13:56 +0100

The hfs_bnode_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/hfs/bfind.c     | 3 +--
 fs/hfs/brec.c      | 3 +--
 fs/hfsplus/bfind.c | 3 +--
 fs/hfsplus/brec.c  | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index de69d8a..0e26523 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
index 9f4ee7f..3a52b2c 100644
--- a/fs/hfs/brec.c
+++ b/fs/hfs/brec.c
@@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index c1422d9..7be88e3 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 6e560d5..59bab47 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
-- 
2.1.3

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

* [PATCH 1/1] configfs: Deletion of unnecessary checks before the function call "config_item_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-17 18:42                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 18:42 UTC (permalink / raw)
  To: Joel Becker; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 19:37:03 +0100

The config_item_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/configfs/file.c | 3 +--
 fs/configfs/item.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index 1d1c41f..48f36e7 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -291,8 +291,7 @@ static int configfs_release(struct inode * inode, struct file * filp)
 	struct module * owner = attr->ca_owner;
 	struct configfs_buffer * buffer = filp->private_data;
 
-	if (item)
-		config_item_put(item);
+	config_item_put(item);
 	/* After this point, attr should not be accessed. */
 	module_put(owner);
 
diff --git a/fs/configfs/item.c b/fs/configfs/item.c
index e65f9ff..891b20e 100644
--- a/fs/configfs/item.c
+++ b/fs/configfs/item.c
@@ -153,8 +153,7 @@ static void config_item_cleanup(struct config_item *item)
 		t->ct_item_ops->release(item);
 	if (s)
 		config_group_put(s);
-	if (parent)
-		config_item_put(parent);
+	config_item_put(parent);
 }
 
 static void config_item_release(struct kref *kref)
-- 
2.1.3


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

* [PATCH 1/1] configfs: Deletion of unnecessary checks before the function call "config_item_put"
@ 2014-11-17 18:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 18:42 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 19:37:03 +0100

The config_item_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/configfs/file.c | 3 +--
 fs/configfs/item.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index 1d1c41f..48f36e7 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -291,8 +291,7 @@ static int configfs_release(struct inode * inode, struct file * filp)
 	struct module * owner = attr->ca_owner;
 	struct configfs_buffer * buffer = filp->private_data;
 
-	if (item)
-		config_item_put(item);
+	config_item_put(item);
 	/* After this point, attr should not be accessed. */
 	module_put(owner);
 
diff --git a/fs/configfs/item.c b/fs/configfs/item.c
index e65f9ff..891b20e 100644
--- a/fs/configfs/item.c
+++ b/fs/configfs/item.c
@@ -153,8 +153,7 @@ static void config_item_cleanup(struct config_item *item)
 		t->ct_item_ops->release(item);
 	if (s)
 		config_group_put(s);
-	if (parent)
-		config_item_put(parent);
+	config_item_put(parent);
 }
 
 static void config_item_release(struct kref *kref)
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] configfs: Deletion of unnecessary checks before the function call "config_item_put"
@ 2014-11-17 18:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-17 18:42 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 17 Nov 2014 19:37:03 +0100

The config_item_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/configfs/file.c | 3 +--
 fs/configfs/item.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index 1d1c41f..48f36e7 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -291,8 +291,7 @@ static int configfs_release(struct inode * inode, struct file * filp)
 	struct module * owner = attr->ca_owner;
 	struct configfs_buffer * buffer = filp->private_data;
 
-	if (item)
-		config_item_put(item);
+	config_item_put(item);
 	/* After this point, attr should not be accessed. */
 	module_put(owner);
 
diff --git a/fs/configfs/item.c b/fs/configfs/item.c
index e65f9ff..891b20e 100644
--- a/fs/configfs/item.c
+++ b/fs/configfs/item.c
@@ -153,8 +153,7 @@ static void config_item_cleanup(struct config_item *item)
 		t->ct_item_ops->release(item);
 	if (s)
 		config_group_put(s);
-	if (parent)
-		config_item_put(parent);
+	config_item_put(parent);
 }
 
 static void config_item_release(struct kref *kref)
-- 
2.1.3

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

* Re: ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"
  2014-11-17 13:15                                   ` SF Markus Elfring
  (?)
@ 2014-11-17 19:11                                     ` Jarkko Nikula
  -1 siblings, 0 replies; 3633+ messages in thread
From: Jarkko Nikula @ 2014-11-17 19:11 UTC (permalink / raw)
  To: SF Markus Elfring, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Peter Ujfalusi, Takashi Iwai, linux-omap, alsa-devel
  Cc: LKML, kernel-janitors, Coccinelle

On 11/17/2014 03:15 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 14:05:27 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  sound/soc/omap/mcbsp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com>


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

* Re: ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-17 19:11                                     ` Jarkko Nikula
  0 siblings, 0 replies; 3633+ messages in thread
From: Jarkko Nikula @ 2014-11-17 19:11 UTC (permalink / raw)
  To: SF Markus Elfring, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Peter Ujfalusi, Takashi Iwai, linux-omap, alsa-devel
  Cc: kernel-janitors, LKML, Coccinelle

On 11/17/2014 03:15 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 14:05:27 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  sound/soc/omap/mcbsp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com>


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

* Re: ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-17 19:11                                     ` Jarkko Nikula
  0 siblings, 0 replies; 3633+ messages in thread
From: Jarkko Nikula @ 2014-11-17 19:11 UTC (permalink / raw)
  To: SF Markus Elfring, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Peter Ujfalusi, Takashi Iwai, linux-omap, alsa-devel
  Cc: kernel-janitors, LKML, Coccinelle

On 11/17/2014 03:15 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 14:05:27 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  sound/soc/omap/mcbsp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com>

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

* Re: [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"
  2014-11-17 18:19                                   ` SF Markus Elfring
@ 2014-11-17 19:18                                     ` Vyacheslav Dubeyko
  -1 siblings, 0 replies; 3633+ messages in thread
From: Vyacheslav Dubeyko @ 2014-11-17 19:18 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-fsdevel, LKML, kernel-janitors, Coccinelle

On Mon, 2014-11-17 at 19:19 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 19:13:56 +0100
> 
> The hfs_bnode_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 

Thank you. It's the reasonable correction. Looks good for me.

Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>

Thanks,
Vyacheslav Dubeyko.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/hfs/bfind.c     | 3 +--
>  fs/hfs/brec.c      | 3 +--
>  fs/hfsplus/bfind.c | 3 +--
>  fs/hfsplus/brec.c  | 3 +--
>  4 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
> index de69d8a..0e26523 100644
> --- a/fs/hfs/bfind.c
> +++ b/fs/hfs/bfind.c
> @@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
>  	int height, res;
>  
>  	tree = fd->tree;
> -	if (fd->bnode)
> -		hfs_bnode_put(fd->bnode);
> +	hfs_bnode_put(fd->bnode);
>  	fd->bnode = NULL;
>  	nidx = tree->root;
>  	if (!nidx)
> diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
> index 9f4ee7f..3a52b2c 100644
> --- a/fs/hfs/brec.c
> +++ b/fs/hfs/brec.c
> @@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
>  		/* panic? */
>  		hfs_bnode_put(node);
>  		hfs_bnode_put(new_node);
> -		if (next_node)
> -			hfs_bnode_put(next_node);
> +		hfs_bnode_put(next_node);
>  		return ERR_PTR(-ENOSPC);
>  	}
>  
> diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
> index c1422d9..7be88e3 100644
> --- a/fs/hfsplus/bfind.c
> +++ b/fs/hfsplus/bfind.c
> @@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
>  	int height, res;
>  
>  	tree = fd->tree;
> -	if (fd->bnode)
> -		hfs_bnode_put(fd->bnode);
> +	hfs_bnode_put(fd->bnode);
>  	fd->bnode = NULL;
>  	nidx = tree->root;
>  	if (!nidx)
> diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
> index 6e560d5..59bab47 100644
> --- a/fs/hfsplus/brec.c
> +++ b/fs/hfsplus/brec.c
> @@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
>  		/* panic? */
>  		hfs_bnode_put(node);
>  		hfs_bnode_put(new_node);
> -		if (next_node)
> -			hfs_bnode_put(next_node);
> +		hfs_bnode_put(next_node);
>  		return ERR_PTR(-ENOSPC);
>  	}
>  



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

* Re: [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"
@ 2014-11-17 19:18                                     ` Vyacheslav Dubeyko
  0 siblings, 0 replies; 3633+ messages in thread
From: Vyacheslav Dubeyko @ 2014-11-17 19:18 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-fsdevel, LKML, kernel-janitors, Coccinelle

On Mon, 2014-11-17 at 19:19 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 19:13:56 +0100
> 
> The hfs_bnode_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 

Thank you. It's the reasonable correction. Looks good for me.

Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>

Thanks,
Vyacheslav Dubeyko.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/hfs/bfind.c     | 3 +--
>  fs/hfs/brec.c      | 3 +--
>  fs/hfsplus/bfind.c | 3 +--
>  fs/hfsplus/brec.c  | 3 +--
>  4 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
> index de69d8a..0e26523 100644
> --- a/fs/hfs/bfind.c
> +++ b/fs/hfs/bfind.c
> @@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
>  	int height, res;
>  
>  	tree = fd->tree;
> -	if (fd->bnode)
> -		hfs_bnode_put(fd->bnode);
> +	hfs_bnode_put(fd->bnode);
>  	fd->bnode = NULL;
>  	nidx = tree->root;
>  	if (!nidx)
> diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
> index 9f4ee7f..3a52b2c 100644
> --- a/fs/hfs/brec.c
> +++ b/fs/hfs/brec.c
> @@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
>  		/* panic? */
>  		hfs_bnode_put(node);
>  		hfs_bnode_put(new_node);
> -		if (next_node)
> -			hfs_bnode_put(next_node);
> +		hfs_bnode_put(next_node);
>  		return ERR_PTR(-ENOSPC);
>  	}
>  
> diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
> index c1422d9..7be88e3 100644
> --- a/fs/hfsplus/bfind.c
> +++ b/fs/hfsplus/bfind.c
> @@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
>  	int height, res;
>  
>  	tree = fd->tree;
> -	if (fd->bnode)
> -		hfs_bnode_put(fd->bnode);
> +	hfs_bnode_put(fd->bnode);
>  	fd->bnode = NULL;
>  	nidx = tree->root;
>  	if (!nidx)
> diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
> index 6e560d5..59bab47 100644
> --- a/fs/hfsplus/brec.c
> +++ b/fs/hfsplus/brec.c
> @@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
>  		/* panic? */
>  		hfs_bnode_put(node);
>  		hfs_bnode_put(new_node);
> -		if (next_node)
> -			hfs_bnode_put(next_node);
> +		hfs_bnode_put(next_node);
>  		return ERR_PTR(-ENOSPC);
>  	}
>  



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

* [PATCH 1/1] fs-eventpoll: Deletion of unnecessary checks before the function call "__pm_stay_awake"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-18  8:35                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18  8:35 UTC (permalink / raw)
  To: Alexander Viro, linux-fsdevel; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 09:27:16 +0100

The __pm_stay_awake() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/eventpoll.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 7bcfff9..eec2e85 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -555,8 +555,7 @@ static inline void ep_pm_stay_awake(struct epitem *epi)
 {
 	struct wakeup_source *ws = ep_wakeup_source(epi);
 
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 }
 
 static inline bool ep_has_wakeup_source(struct epitem *epi)
@@ -571,8 +570,7 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi)
 
 	rcu_read_lock();
 	ws = rcu_dereference(epi->ws);
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 	rcu_read_unlock();
 }
 
-- 
2.1.3


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

* [PATCH 1/1] fs-eventpoll: Deletion of unnecessary checks before the function call "__pm_stay_awake"
@ 2014-11-18  8:35                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18  8:35 UTC (permalink / raw)
  To: Alexander Viro, linux-fsdevel; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 09:27:16 +0100

The __pm_stay_awake() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/eventpoll.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 7bcfff9..eec2e85 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -555,8 +555,7 @@ static inline void ep_pm_stay_awake(struct epitem *epi)
 {
 	struct wakeup_source *ws = ep_wakeup_source(epi);
 
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 }
 
 static inline bool ep_has_wakeup_source(struct epitem *epi)
@@ -571,8 +570,7 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi)
 
 	rcu_read_lock();
 	ws = rcu_dereference(epi->ws);
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 	rcu_read_unlock();
 }
 
-- 
2.1.3

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

* [PATCH 1/1] fs-eventpoll: Deletion of unnecessary checks before the function call "__pm_stay_awake"
@ 2014-11-18  8:35                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18  8:35 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 09:27:16 +0100

The __pm_stay_awake() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/eventpoll.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 7bcfff9..eec2e85 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -555,8 +555,7 @@ static inline void ep_pm_stay_awake(struct epitem *epi)
 {
 	struct wakeup_source *ws = ep_wakeup_source(epi);
 
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 }
 
 static inline bool ep_has_wakeup_source(struct epitem *epi)
@@ -571,8 +570,7 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi)
 
 	rcu_read_lock();
 	ws = rcu_dereference(epi->ws);
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 	rcu_read_unlock();
 }
 
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] fs-eventpoll: Deletion of unnecessary checks before the function call "__pm_stay_awake"
@ 2014-11-18  8:35                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18  8:35 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 09:27:16 +0100

The __pm_stay_awake() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/eventpoll.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 7bcfff9..eec2e85 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -555,8 +555,7 @@ static inline void ep_pm_stay_awake(struct epitem *epi)
 {
 	struct wakeup_source *ws = ep_wakeup_source(epi);
 
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 }
 
 static inline bool ep_has_wakeup_source(struct epitem *epi)
@@ -571,8 +570,7 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi)
 
 	rcu_read_lock();
 	ws = rcu_dereference(epi->ws);
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 	rcu_read_unlock();
 }
 
-- 
2.1.3

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

* [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_io_state"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-18  9:10                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18  9:10 UTC (permalink / raw)
  To: Benny Halevy, Boaz Harrosh, osd-dev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 10:05:19 +0100

The ore_put_io_state() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/exofs/ore_raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c
index 84529b8..5dc7c4c 100644
--- a/fs/exofs/ore_raid.c
+++ b/fs/exofs/ore_raid.c
@@ -716,6 +716,5 @@ void _ore_free_raid_stuff(struct ore_io_state *ios)
 		if (ios->extra_part_alloc)
 			kfree(ios->per_dev[0].sglist);
 	}
-	if (ios->ios_read_4_write)
-		ore_put_io_state(ios->ios_read_4_write);
+	ore_put_io_state(ios->ios_read_4_write);
 }
-- 
2.1.3


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

* [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_io_state"
@ 2014-11-18  9:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18  9:10 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 10:05:19 +0100

The ore_put_io_state() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/exofs/ore_raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c
index 84529b8..5dc7c4c 100644
--- a/fs/exofs/ore_raid.c
+++ b/fs/exofs/ore_raid.c
@@ -716,6 +716,5 @@ void _ore_free_raid_stuff(struct ore_io_state *ios)
 		if (ios->extra_part_alloc)
 			kfree(ios->per_dev[0].sglist);
 	}
-	if (ios->ios_read_4_write)
-		ore_put_io_state(ios->ios_read_4_write);
+	ore_put_io_state(ios->ios_read_4_write);
 }
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_io_state"
@ 2014-11-18  9:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18  9:10 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 10:05:19 +0100

The ore_put_io_state() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/exofs/ore_raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c
index 84529b8..5dc7c4c 100644
--- a/fs/exofs/ore_raid.c
+++ b/fs/exofs/ore_raid.c
@@ -716,6 +716,5 @@ void _ore_free_raid_stuff(struct ore_io_state *ios)
 		if (ios->extra_part_alloc)
 			kfree(ios->per_dev[0].sglist);
 	}
-	if (ios->ios_read_4_write)
-		ore_put_io_state(ios->ios_read_4_write);
+	ore_put_io_state(ios->ios_read_4_write);
 }
-- 
2.1.3

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

* Re: [osd-dev] [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_io_state"
  2014-11-18  9:10                                   ` SF Markus Elfring
@ 2014-11-18  9:13                                     ` Boaz Harrosh
  -1 siblings, 0 replies; 3633+ messages in thread
From: Boaz Harrosh @ 2014-11-18  9:13 UTC (permalink / raw)
  To: SF Markus Elfring, Benny Halevy, Boaz Harrosh, osd-dev
  Cc: kernel-janitors, LKML, Coccinelle

On 11/18/2014 11:10 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 10:05:19 +0100
> 
> The ore_put_io_state() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/exofs/ore_raid.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c
> index 84529b8..5dc7c4c 100644
> --- a/fs/exofs/ore_raid.c
> +++ b/fs/exofs/ore_raid.c
> @@ -716,6 +716,5 @@ void _ore_free_raid_stuff(struct ore_io_state *ios)
>  		if (ios->extra_part_alloc)
>  			kfree(ios->per_dev[0].sglist);
>  	}
> -	if (ios->ios_read_4_write)
> -		ore_put_io_state(ios->ios_read_4_write);
> +	ore_put_io_state(ios->ios_read_4_write);
>  }
> 

Thanks will submit for next Kernel
Boaz

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

* Re: [osd-dev] [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_
@ 2014-11-18  9:13                                     ` Boaz Harrosh
  0 siblings, 0 replies; 3633+ messages in thread
From: Boaz Harrosh @ 2014-11-18  9:13 UTC (permalink / raw)
  To: SF Markus Elfring, Benny Halevy, Boaz Harrosh, osd-dev
  Cc: kernel-janitors, LKML, Coccinelle

On 11/18/2014 11:10 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 10:05:19 +0100
> 
> The ore_put_io_state() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/exofs/ore_raid.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c
> index 84529b8..5dc7c4c 100644
> --- a/fs/exofs/ore_raid.c
> +++ b/fs/exofs/ore_raid.c
> @@ -716,6 +716,5 @@ void _ore_free_raid_stuff(struct ore_io_state *ios)
>  		if (ios->extra_part_alloc)
>  			kfree(ios->per_dev[0].sglist);
>  	}
> -	if (ios->ios_read_4_write)
> -		ore_put_io_state(ios->ios_read_4_write);
> +	ore_put_io_state(ios->ios_read_4_write);
>  }
> 

Thanks will submit for next Kernel
Boaz

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

* Re: [PATCH 1/1] fs-jbd: Deletion of an unnecessary check before the function call "iput"
  2014-11-16 22:40                                   ` SF Markus Elfring
@ 2014-11-18  9:16                                     ` Jan Kara
  -1 siblings, 0 replies; 3633+ messages in thread
From: Jan Kara @ 2014-11-18  9:16 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Andrew Morton, Jan Kara, linux-ext4, LKML, kernel-janitors, Coccinelle

On Sun 16-11-14 23:40:18, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 23:23:19 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/jbd/journal.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
  Thanks. Merged into my tree.

								Honza

> 
> diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
> index 06fe11e..32fe03e 100644
> --- a/fs/jbd/journal.c
> +++ b/fs/jbd/journal.c
> @@ -1373,8 +1373,7 @@ int journal_destroy(journal_t *journal)
>  	}
>  	mutex_unlock(&journal->j_checkpoint_mutex);
>  
> -	if (journal->j_inode)
> -		iput(journal->j_inode);
> +	iput(journal->j_inode);
>  	if (journal->j_revoke)
>  		journal_destroy_revoke(journal);
>  	kfree(journal->j_wbuf);
> -- 
> 2.1.3
> 
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 1/1] fs-jbd: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-18  9:16                                     ` Jan Kara
  0 siblings, 0 replies; 3633+ messages in thread
From: Jan Kara @ 2014-11-18  9:16 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Andrew Morton, Jan Kara, linux-ext4, LKML, kernel-janitors, Coccinelle

On Sun 16-11-14 23:40:18, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 23:23:19 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/jbd/journal.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
  Thanks. Merged into my tree.

								Honza

> 
> diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
> index 06fe11e..32fe03e 100644
> --- a/fs/jbd/journal.c
> +++ b/fs/jbd/journal.c
> @@ -1373,8 +1373,7 @@ int journal_destroy(journal_t *journal)
>  	}
>  	mutex_unlock(&journal->j_checkpoint_mutex);
>  
> -	if (journal->j_inode)
> -		iput(journal->j_inode);
> +	iput(journal->j_inode);
>  	if (journal->j_revoke)
>  		journal_destroy_revoke(journal);
>  	kfree(journal->j_wbuf);
> -- 
> 2.1.3
> 
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"
  2014-11-17 13:15                                   ` SF Markus Elfring
                                                     ` (2 preceding siblings ...)
  (?)
@ 2014-11-18  9:40                                   ` Mark Brown
  -1 siblings, 0 replies; 3633+ messages in thread
From: Mark Brown @ 2014-11-18  9:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jarkko Nikula, Jaroslav Kysela, Liam Girdwood, Peter Ujfalusi,
	Takashi Iwai, linux-omap, alsa-devel, LKML, kernel-janitors,
	Coccinelle

[-- Attachment #1: Type: text/plain, Size: 326 bytes --]

On Mon, Nov 17, 2014 at 02:15:01PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 14:05:27 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-18 10:35                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 10:35 UTC (permalink / raw)
  To: Steven Whitehouse, cluster-devel; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 11:31:23 +0100

The functions iput() and put_pid() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/gfs2/glock.c      | 3 +--
 fs/gfs2/ops_fstype.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 7f513b1..f4aa085 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
 	gh->gh_flags = flags;
 	gh->gh_iflags = 0;
 	gh->gh_ip = (unsigned long)__builtin_return_address(0);
-	if (gh->gh_owner_pid)
-		put_pid(gh->gh_owner_pid);
+	put_pid(gh->gh_owner_pid);
 	gh->gh_owner_pid = get_pid(task_pid(current));
 }
 
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index d3eae24..272ff81 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -918,8 +918,7 @@ fail_qc_i:
 fail_ut_i:
 	iput(sdp->sd_sc_inode);
 fail:
-	if (pn)
-		iput(pn);
+	iput(pn);
 	return error;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls
@ 2014-11-18 10:35                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 10:35 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 11:31:23 +0100

The functions iput() and put_pid() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/gfs2/glock.c      | 3 +--
 fs/gfs2/ops_fstype.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 7f513b1..f4aa085 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
 	gh->gh_flags = flags;
 	gh->gh_iflags = 0;
 	gh->gh_ip = (unsigned long)__builtin_return_address(0);
-	if (gh->gh_owner_pid)
-		put_pid(gh->gh_owner_pid);
+	put_pid(gh->gh_owner_pid);
 	gh->gh_owner_pid = get_pid(task_pid(current));
 }
 
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index d3eae24..272ff81 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -918,8 +918,7 @@ fail_qc_i:
 fail_ut_i:
 	iput(sdp->sd_sc_inode);
 fail:
-	if (pn)
-		iput(pn);
+	iput(pn);
 	return error;
 }
 
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls
@ 2014-11-18 10:35                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 10:35 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 11:31:23 +0100

The functions iput() and put_pid() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/gfs2/glock.c      | 3 +--
 fs/gfs2/ops_fstype.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 7f513b1..f4aa085 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
 	gh->gh_flags = flags;
 	gh->gh_iflags = 0;
 	gh->gh_ip = (unsigned long)__builtin_return_address(0);
-	if (gh->gh_owner_pid)
-		put_pid(gh->gh_owner_pid);
+	put_pid(gh->gh_owner_pid);
 	gh->gh_owner_pid = get_pid(task_pid(current));
 }
 
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index d3eae24..272ff81 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -918,8 +918,7 @@ fail_qc_i:
 fail_ut_i:
 	iput(sdp->sd_sc_inode);
 fail:
-	if (pn)
-		iput(pn);
+	iput(pn);
 	return error;
 }
 
-- 
2.1.3

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

* [Cluster-devel] [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls
@ 2014-11-18 10:35                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 10:35 UTC (permalink / raw)
  To: cluster-devel.redhat.com

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 11:31:23 +0100

The functions iput() and put_pid() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/gfs2/glock.c      | 3 +--
 fs/gfs2/ops_fstype.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 7f513b1..f4aa085 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
 	gh->gh_flags = flags;
 	gh->gh_iflags = 0;
 	gh->gh_ip = (unsigned long)__builtin_return_address(0);
-	if (gh->gh_owner_pid)
-		put_pid(gh->gh_owner_pid);
+	put_pid(gh->gh_owner_pid);
 	gh->gh_owner_pid = get_pid(task_pid(current));
 }
 
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index d3eae24..272ff81 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -918,8 +918,7 @@ fail_qc_i:
 fail_ut_i:
 	iput(sdp->sd_sc_inode);
 fail:
-	if (pn)
-		iput(pn);
+	iput(pn);
 	return error;
 }
 
-- 
2.1.3



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

* Re: [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls
  2014-11-18 10:35                                   ` SF Markus Elfring
@ 2014-11-18 11:05                                     ` Steven Whitehouse
  -1 siblings, 0 replies; 3633+ messages in thread
From: Steven Whitehouse @ 2014-11-18 11:05 UTC (permalink / raw)
  To: SF Markus Elfring, cluster-devel; +Cc: LKML, kernel-janitors, Coccinelle

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Steve.

On 18/11/14 10:35, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 11:31:23 +0100
>
> The functions iput() and put_pid() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   fs/gfs2/glock.c      | 3 +--
>   fs/gfs2/ops_fstype.c | 3 +--
>   2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
> index 7f513b1..f4aa085 100644
> --- a/fs/gfs2/glock.c
> +++ b/fs/gfs2/glock.c
> @@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
>   	gh->gh_flags = flags;
>   	gh->gh_iflags = 0;
>   	gh->gh_ip = (unsigned long)__builtin_return_address(0);
> -	if (gh->gh_owner_pid)
> -		put_pid(gh->gh_owner_pid);
> +	put_pid(gh->gh_owner_pid);
>   	gh->gh_owner_pid = get_pid(task_pid(current));
>   }
>   
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index d3eae24..272ff81 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -918,8 +918,7 @@ fail_qc_i:
>   fail_ut_i:
>   	iput(sdp->sd_sc_inode);
>   fail:
> -	if (pn)
> -		iput(pn);
> +	iput(pn);
>   	return error;
>   }
>   


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

* [Cluster-devel] [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls
@ 2014-11-18 11:05                                     ` Steven Whitehouse
  0 siblings, 0 replies; 3633+ messages in thread
From: Steven Whitehouse @ 2014-11-18 11:05 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Steve.

On 18/11/14 10:35, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 11:31:23 +0100
>
> The functions iput() and put_pid() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   fs/gfs2/glock.c      | 3 +--
>   fs/gfs2/ops_fstype.c | 3 +--
>   2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
> index 7f513b1..f4aa085 100644
> --- a/fs/gfs2/glock.c
> +++ b/fs/gfs2/glock.c
> @@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
>   	gh->gh_flags = flags;
>   	gh->gh_iflags = 0;
>   	gh->gh_ip = (unsigned long)__builtin_return_address(0);
> -	if (gh->gh_owner_pid)
> -		put_pid(gh->gh_owner_pid);
> +	put_pid(gh->gh_owner_pid);
>   	gh->gh_owner_pid = get_pid(task_pid(current));
>   }
>   
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index d3eae24..272ff81 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -918,8 +918,7 @@ fail_qc_i:
>   fail_ut_i:
>   	iput(sdp->sd_sc_inode);
>   fail:
> -	if (pn)
> -		iput(pn);
> +	iput(pn);
>   	return error;
>   }
>   



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

* [PATCH 1/1] fs-namespace: Deletion of unnecessary checks before the function call "mntput"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-18 11:20                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 11:20 UTC (permalink / raw)
  To: Alexander Viro, linux-fsdevel; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 12:10:43 +0100

The mntput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/namespace.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 550dbff..3b3710e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2615,10 +2615,8 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 	}
 	namespace_unlock();
 
-	if (rootmnt)
-		mntput(rootmnt);
-	if (pwdmnt)
-		mntput(pwdmnt);
+	mntput(rootmnt);
+	mntput(pwdmnt);
 
 	return new_ns;
 }
-- 
2.1.3


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

* [PATCH 1/1] fs-namespace: Deletion of unnecessary checks before the function call "mntput"
@ 2014-11-18 11:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 11:20 UTC (permalink / raw)
  To: Alexander Viro, linux-fsdevel; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 12:10:43 +0100

The mntput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/namespace.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 550dbff..3b3710e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2615,10 +2615,8 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 	}
 	namespace_unlock();
 
-	if (rootmnt)
-		mntput(rootmnt);
-	if (pwdmnt)
-		mntput(pwdmnt);
+	mntput(rootmnt);
+	mntput(pwdmnt);
 
 	return new_ns;
 }
-- 
2.1.3

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

* [PATCH 1/1] fs-namespace: Deletion of unnecessary checks before the function call "mntput"
@ 2014-11-18 11:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 11:20 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 12:10:43 +0100

The mntput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/namespace.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 550dbff..3b3710e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2615,10 +2615,8 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 	}
 	namespace_unlock();
 
-	if (rootmnt)
-		mntput(rootmnt);
-	if (pwdmnt)
-		mntput(pwdmnt);
+	mntput(rootmnt);
+	mntput(pwdmnt);
 
 	return new_ns;
 }
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] fs-namespace: Deletion of unnecessary checks before the function call "mntput"
@ 2014-11-18 11:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 11:20 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 12:10:43 +0100

The mntput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/namespace.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 550dbff..3b3710e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2615,10 +2615,8 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 	}
 	namespace_unlock();
 
-	if (rootmnt)
-		mntput(rootmnt);
-	if (pwdmnt)
-		mntput(pwdmnt);
+	mntput(rootmnt);
+	mntput(pwdmnt);
 
 	return new_ns;
 }
-- 
2.1.3

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

* [PATCH 1/1] NFS: Deletion of unnecessary checks before the function call "nfs_put_client"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-18 13:10                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 13:10 UTC (permalink / raw)
  To: Trond Myklebust, linux-nfs; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 13:23:43 +0100

The nfs_put_client() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/nfs/filelayout/filelayoutdev.c |  3 +--
 fs/nfs/nfs4client.c               | 15 +++++----------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/nfs/filelayout/filelayoutdev.c b/fs/nfs/filelayout/filelayoutdev.c
index 8540516..cc5e7d6 100644
--- a/fs/nfs/filelayout/filelayoutdev.c
+++ b/fs/nfs/filelayout/filelayoutdev.c
@@ -204,8 +204,7 @@ destroy_ds(struct nfs4_pnfs_ds *ds)
 	ifdebug(FACILITY)
 		print_ds(ds);
 
-	if (ds->ds_clp)
-		nfs_put_client(ds->ds_clp);
+	nfs_put_client(ds->ds_clp);
 
 	while (!list_empty(&ds->ds_addrs)) {
 		da = list_first_entry(&ds->ds_addrs,
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index ffdb28d..5f07a0e 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -498,8 +498,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 			atomic_inc(&pos->cl_count);
 			spin_unlock(&nn->nfs_client_lock);
 
-			if (prev)
-				nfs_put_client(prev);
+			nfs_put_client(prev);
 			prev = pos;
 
 			status = nfs_wait_client_init_complete(pos);
@@ -517,8 +516,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 		atomic_inc(&pos->cl_count);
 		spin_unlock(&nn->nfs_client_lock);
 
-		if (prev)
-			nfs_put_client(prev);
+		nfs_put_client(prev);
 		prev = pos;
 
 		status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
@@ -549,8 +547,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 
 	/* No match found. The server lost our clientid */
 out:
-	if (prev)
-		nfs_put_client(prev);
+	nfs_put_client(prev);
 	dprintk("NFS: <-- %s status = %d\n", __func__, status);
 	return status;
 }
@@ -641,8 +638,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
 			atomic_inc(&pos->cl_count);
 			spin_unlock(&nn->nfs_client_lock);
 
-			if (prev)
-				nfs_put_client(prev);
+			nfs_put_client(prev);
 			prev = pos;
 
 			status = nfs_wait_client_init_complete(pos);
@@ -675,8 +671,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
 	/* No matching nfs_client found. */
 	spin_unlock(&nn->nfs_client_lock);
 	dprintk("NFS: <-- %s status = %d\n", __func__, status);
-	if (prev)
-		nfs_put_client(prev);
+	nfs_put_client(prev);
 	return status;
 }
 #endif	/* CONFIG_NFS_V4_1 */
-- 
2.1.3


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

* [PATCH 1/1] NFS: Deletion of unnecessary checks before the function call "nfs_put_client"
@ 2014-11-18 13:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 13:10 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 13:23:43 +0100

The nfs_put_client() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/nfs/filelayout/filelayoutdev.c |  3 +--
 fs/nfs/nfs4client.c               | 15 +++++----------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/nfs/filelayout/filelayoutdev.c b/fs/nfs/filelayout/filelayoutdev.c
index 8540516..cc5e7d6 100644
--- a/fs/nfs/filelayout/filelayoutdev.c
+++ b/fs/nfs/filelayout/filelayoutdev.c
@@ -204,8 +204,7 @@ destroy_ds(struct nfs4_pnfs_ds *ds)
 	ifdebug(FACILITY)
 		print_ds(ds);
 
-	if (ds->ds_clp)
-		nfs_put_client(ds->ds_clp);
+	nfs_put_client(ds->ds_clp);
 
 	while (!list_empty(&ds->ds_addrs)) {
 		da = list_first_entry(&ds->ds_addrs,
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index ffdb28d..5f07a0e 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -498,8 +498,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 			atomic_inc(&pos->cl_count);
 			spin_unlock(&nn->nfs_client_lock);
 
-			if (prev)
-				nfs_put_client(prev);
+			nfs_put_client(prev);
 			prev = pos;
 
 			status = nfs_wait_client_init_complete(pos);
@@ -517,8 +516,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 		atomic_inc(&pos->cl_count);
 		spin_unlock(&nn->nfs_client_lock);
 
-		if (prev)
-			nfs_put_client(prev);
+		nfs_put_client(prev);
 		prev = pos;
 
 		status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
@@ -549,8 +547,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 
 	/* No match found. The server lost our clientid */
 out:
-	if (prev)
-		nfs_put_client(prev);
+	nfs_put_client(prev);
 	dprintk("NFS: <-- %s status = %d\n", __func__, status);
 	return status;
 }
@@ -641,8 +638,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
 			atomic_inc(&pos->cl_count);
 			spin_unlock(&nn->nfs_client_lock);
 
-			if (prev)
-				nfs_put_client(prev);
+			nfs_put_client(prev);
 			prev = pos;
 
 			status = nfs_wait_client_init_complete(pos);
@@ -675,8 +671,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
 	/* No matching nfs_client found. */
 	spin_unlock(&nn->nfs_client_lock);
 	dprintk("NFS: <-- %s status = %d\n", __func__, status);
-	if (prev)
-		nfs_put_client(prev);
+	nfs_put_client(prev);
 	return status;
 }
 #endif	/* CONFIG_NFS_V4_1 */
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] NFS: Deletion of unnecessary checks before the function call "nfs_put_client"
@ 2014-11-18 13:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 13:10 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 13:23:43 +0100

The nfs_put_client() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/nfs/filelayout/filelayoutdev.c |  3 +--
 fs/nfs/nfs4client.c               | 15 +++++----------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/nfs/filelayout/filelayoutdev.c b/fs/nfs/filelayout/filelayoutdev.c
index 8540516..cc5e7d6 100644
--- a/fs/nfs/filelayout/filelayoutdev.c
+++ b/fs/nfs/filelayout/filelayoutdev.c
@@ -204,8 +204,7 @@ destroy_ds(struct nfs4_pnfs_ds *ds)
 	ifdebug(FACILITY)
 		print_ds(ds);
 
-	if (ds->ds_clp)
-		nfs_put_client(ds->ds_clp);
+	nfs_put_client(ds->ds_clp);
 
 	while (!list_empty(&ds->ds_addrs)) {
 		da = list_first_entry(&ds->ds_addrs,
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index ffdb28d..5f07a0e 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -498,8 +498,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 			atomic_inc(&pos->cl_count);
 			spin_unlock(&nn->nfs_client_lock);
 
-			if (prev)
-				nfs_put_client(prev);
+			nfs_put_client(prev);
 			prev = pos;
 
 			status = nfs_wait_client_init_complete(pos);
@@ -517,8 +516,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 		atomic_inc(&pos->cl_count);
 		spin_unlock(&nn->nfs_client_lock);
 
-		if (prev)
-			nfs_put_client(prev);
+		nfs_put_client(prev);
 		prev = pos;
 
 		status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
@@ -549,8 +547,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 
 	/* No match found. The server lost our clientid */
 out:
-	if (prev)
-		nfs_put_client(prev);
+	nfs_put_client(prev);
 	dprintk("NFS: <-- %s status = %d\n", __func__, status);
 	return status;
 }
@@ -641,8 +638,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
 			atomic_inc(&pos->cl_count);
 			spin_unlock(&nn->nfs_client_lock);
 
-			if (prev)
-				nfs_put_client(prev);
+			nfs_put_client(prev);
 			prev = pos;
 
 			status = nfs_wait_client_init_complete(pos);
@@ -675,8 +671,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
 	/* No matching nfs_client found. */
 	spin_unlock(&nn->nfs_client_lock);
 	dprintk("NFS: <-- %s status = %d\n", __func__, status);
-	if (prev)
-		nfs_put_client(prev);
+	nfs_put_client(prev);
 	return status;
 }
 #endif	/* CONFIG_NFS_V4_1 */
-- 
2.1.3

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

* [PATCH 1/1] nilfs2: Deletion of an unnecessary check before the function call "iput"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-18 13:48                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 13:48 UTC (permalink / raw)
  To: Ryusuke Konishi, linux-nilfs; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 14:41:27 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/nilfs2/the_nilfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 9da25fe..69bd801 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -808,8 +808,7 @@ void nilfs_put_root(struct nilfs_root *root)
 		spin_lock(&nilfs->ns_cptree_lock);
 		rb_erase(&root->rb_node, &nilfs->ns_cptree);
 		spin_unlock(&nilfs->ns_cptree_lock);
-		if (root->ifile)
-			iput(root->ifile);
+		iput(root->ifile);
 
 		kfree(root);
 	}
-- 
2.1.3


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

* [PATCH 1/1] nilfs2: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-18 13:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 13:48 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 14:41:27 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/nilfs2/the_nilfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 9da25fe..69bd801 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -808,8 +808,7 @@ void nilfs_put_root(struct nilfs_root *root)
 		spin_lock(&nilfs->ns_cptree_lock);
 		rb_erase(&root->rb_node, &nilfs->ns_cptree);
 		spin_unlock(&nilfs->ns_cptree_lock);
-		if (root->ifile)
-			iput(root->ifile);
+		iput(root->ifile);
 
 		kfree(root);
 	}
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] nilfs2: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-18 13:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 13:48 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 14:41:27 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/nilfs2/the_nilfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 9da25fe..69bd801 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -808,8 +808,7 @@ void nilfs_put_root(struct nilfs_root *root)
 		spin_lock(&nilfs->ns_cptree_lock);
 		rb_erase(&root->rb_node, &nilfs->ns_cptree);
 		spin_unlock(&nilfs->ns_cptree_lock);
-		if (root->ifile)
-			iput(root->ifile);
+		iput(root->ifile);
 
 		kfree(root);
 	}
-- 
2.1.3

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

* [PATCH 1/1] nilfs2: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-18 13:48                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 13:48 UTC (permalink / raw)
  To: Ryusuke Konishi, linux-nilfs-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Coccinelle

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Tue, 18 Nov 2014 14:41:27 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 fs/nilfs2/the_nilfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 9da25fe..69bd801 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -808,8 +808,7 @@ void nilfs_put_root(struct nilfs_root *root)
 		spin_lock(&nilfs->ns_cptree_lock);
 		rb_erase(&root->rb_node, &nilfs->ns_cptree);
 		spin_unlock(&nilfs->ns_cptree_lock);
-		if (root->ifile)
-			iput(root->ifile);
+		iput(root->ifile);
 
 		kfree(root);
 	}
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/1] fs-proc: One function call less in proc_sys_lookup() after error detection
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-18 14:51                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 14:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 15:42:43 +0100

The sysctl_head_finish() function was called in an inefficient way by the
implementation of the proc_sys_lookup() function in case of a lookup failure.
The corresponding source code was improved by deletion of an unnecessary
null pointer check and a few adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/proc/proc_sysctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index f92d5dd..6606aaf 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -457,21 +457,21 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
 		ret = sysctl_follow_link(&h, &p, current->nsproxy);
 		err = ERR_PTR(ret);
 		if (ret)
-			goto out;
+			goto inode_failure;
 	}
 
 	err = ERR_PTR(-ENOMEM);
 	inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
 	if (!inode)
-		goto out;
+		goto inode_failure;
 
 	err = NULL;
 	d_set_d_op(dentry, &proc_sys_dentry_operations);
 	d_add(dentry, inode);
 
+inode_failure:
+	sysctl_head_finish(h);
 out:
-	if (h)
-		sysctl_head_finish(h);
 	sysctl_head_finish(head);
 	return err;
 }
-- 
2.1.3


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

* [PATCH 1/1] fs-proc: One function call less in proc_sys_lookup() after error detection
@ 2014-11-18 14:51                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 14:51 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 15:42:43 +0100

The sysctl_head_finish() function was called in an inefficient way by the
implementation of the proc_sys_lookup() function in case of a lookup failure.
The corresponding source code was improved by deletion of an unnecessary
null pointer check and a few adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/proc/proc_sysctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index f92d5dd..6606aaf 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -457,21 +457,21 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
 		ret = sysctl_follow_link(&h, &p, current->nsproxy);
 		err = ERR_PTR(ret);
 		if (ret)
-			goto out;
+			goto inode_failure;
 	}
 
 	err = ERR_PTR(-ENOMEM);
 	inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
 	if (!inode)
-		goto out;
+		goto inode_failure;
 
 	err = NULL;
 	d_set_d_op(dentry, &proc_sys_dentry_operations);
 	d_add(dentry, inode);
 
+inode_failure:
+	sysctl_head_finish(h);
 out:
-	if (h)
-		sysctl_head_finish(h);
 	sysctl_head_finish(head);
 	return err;
 }
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] fs-proc: One function call less in proc_sys_lookup() after error detection
@ 2014-11-18 14:51                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 14:51 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 15:42:43 +0100

The sysctl_head_finish() function was called in an inefficient way by the
implementation of the proc_sys_lookup() function in case of a lookup failure.
The corresponding source code was improved by deletion of an unnecessary
null pointer check and a few adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/proc/proc_sysctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index f92d5dd..6606aaf 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -457,21 +457,21 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
 		ret = sysctl_follow_link(&h, &p, current->nsproxy);
 		err = ERR_PTR(ret);
 		if (ret)
-			goto out;
+			goto inode_failure;
 	}
 
 	err = ERR_PTR(-ENOMEM);
 	inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
 	if (!inode)
-		goto out;
+		goto inode_failure;
 
 	err = NULL;
 	d_set_d_op(dentry, &proc_sys_dentry_operations);
 	d_add(dentry, inode);
 
+inode_failure:
+	sysctl_head_finish(h);
 out:
-	if (h)
-		sysctl_head_finish(h);
 	sysctl_head_finish(head);
 	return err;
 }
-- 
2.1.3

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

* [PATCH 0/2] fs-udf: Deletion of two unnecessary checks
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-18 17:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 17:55 UTC (permalink / raw)
  To: Jan Kara; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 18:33:08 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of unnecessary checks before the function call "iput"
  One function call less in udf_fill_super() after error detection

 fs/udf/super.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.1.3


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

* [PATCH 0/2] fs-udf: Deletion of two unnecessary checks
@ 2014-11-18 17:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 17:55 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 18:33:08 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of unnecessary checks before the function call "iput"
  One function call less in udf_fill_super() after error detection

 fs/udf/super.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.1.3


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

* [Cocci] [PATCH 0/2] fs-udf: Deletion of two unnecessary checks
@ 2014-11-18 17:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 17:55 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 18:33:08 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of unnecessary checks before the function call "iput"
  One function call less in udf_fill_super() after error detection

 fs/udf/super.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.1.3

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

* [PATCH 1/2] fs-udf: Deletion of unnecessary checks before the function call "iput"
  2014-11-18 17:55                                   ` SF Markus Elfring
  (?)
@ 2014-11-18 18:00                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 18:00 UTC (permalink / raw)
  To: Jan Kara; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 17:17:46 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/udf/super.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index e229315..f93c65d 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -2237,8 +2237,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	return 0;
 
 error_out:
-	if (sbi->s_vat_inode)
-		iput(sbi->s_vat_inode);
+	iput(sbi->s_vat_inode);
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
@@ -2291,8 +2290,7 @@ static void udf_put_super(struct super_block *sb)
 
 	sbi = UDF_SB(sb);
 
-	if (sbi->s_vat_inode)
-		iput(sbi->s_vat_inode);
+	iput(sbi->s_vat_inode);
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
-- 
2.1.3


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

* [PATCH 1/2] fs-udf: Deletion of unnecessary checks before the function call "iput"
@ 2014-11-18 18:00                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 18:00 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 17:17:46 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/udf/super.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index e229315..f93c65d 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -2237,8 +2237,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	return 0;
 
 error_out:
-	if (sbi->s_vat_inode)
-		iput(sbi->s_vat_inode);
+	iput(sbi->s_vat_inode);
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
@@ -2291,8 +2290,7 @@ static void udf_put_super(struct super_block *sb)
 
 	sbi = UDF_SB(sb);
 
-	if (sbi->s_vat_inode)
-		iput(sbi->s_vat_inode);
+	iput(sbi->s_vat_inode);
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
-- 
2.1.3


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

* [Cocci] [PATCH 1/2] fs-udf: Deletion of unnecessary checks before the function call "iput"
@ 2014-11-18 18:00                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 18:00 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 17:17:46 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/udf/super.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index e229315..f93c65d 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -2237,8 +2237,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	return 0;
 
 error_out:
-	if (sbi->s_vat_inode)
-		iput(sbi->s_vat_inode);
+	iput(sbi->s_vat_inode);
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
@@ -2291,8 +2290,7 @@ static void udf_put_super(struct super_block *sb)
 
 	sbi = UDF_SB(sb);
 
-	if (sbi->s_vat_inode)
-		iput(sbi->s_vat_inode);
+	iput(sbi->s_vat_inode);
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
-- 
2.1.3

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

* [PATCH 2/2] fs-udf: One function call less in udf_fill_super() after error detection
  2014-11-18 17:55                                   ` SF Markus Elfring
  (?)
@ 2014-11-18 18:02                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 18:02 UTC (permalink / raw)
  To: Jan Kara; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 18:29:10 +0100

The iput() function was called in up to three cases by the udf_fill_super()
function during error handling even if the passed data structure element
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/udf/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index f93c65d..3ccb2f1 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -2082,12 +2082,12 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	mutex_init(&sbi->s_alloc_mutex);
 
 	if (!udf_parse_options((char *)options, &uopt, false))
-		goto error_out;
+		goto parse_options_failure;
 
 	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
 	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
 		udf_err(sb, "utf8 cannot be combined with iocharset\n");
-		goto error_out;
+		goto parse_options_failure;
 	}
 #ifdef CONFIG_UDF_NLS
 	if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) {
@@ -2238,6 +2238,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 error_out:
 	iput(sbi->s_vat_inode);
+parse_options_failure:
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
-- 
2.1.3


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

* [PATCH 2/2] fs-udf: One function call less in udf_fill_super() after error detection
@ 2014-11-18 18:02                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 18:02 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 18:29:10 +0100

The iput() function was called in up to three cases by the udf_fill_super()
function during error handling even if the passed data structure element
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/udf/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index f93c65d..3ccb2f1 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -2082,12 +2082,12 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	mutex_init(&sbi->s_alloc_mutex);
 
 	if (!udf_parse_options((char *)options, &uopt, false))
-		goto error_out;
+		goto parse_options_failure;
 
 	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
 	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
 		udf_err(sb, "utf8 cannot be combined with iocharset\n");
-		goto error_out;
+		goto parse_options_failure;
 	}
 #ifdef CONFIG_UDF_NLS
 	if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) {
@@ -2238,6 +2238,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 error_out:
 	iput(sbi->s_vat_inode);
+parse_options_failure:
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
-- 
2.1.3


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

* [Cocci] [PATCH 2/2] fs-udf: One function call less in udf_fill_super() after error detection
@ 2014-11-18 18:02                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 18:02 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 18:29:10 +0100

The iput() function was called in up to three cases by the udf_fill_super()
function during error handling even if the passed data structure element
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/udf/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index f93c65d..3ccb2f1 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -2082,12 +2082,12 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	mutex_init(&sbi->s_alloc_mutex);
 
 	if (!udf_parse_options((char *)options, &uopt, false))
-		goto error_out;
+		goto parse_options_failure;
 
 	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
 	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
 		udf_err(sb, "utf8 cannot be combined with iocharset\n");
-		goto error_out;
+		goto parse_options_failure;
 	}
 #ifdef CONFIG_UDF_NLS
 	if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) {
@@ -2238,6 +2238,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 error_out:
 	iput(sbi->s_vat_inode);
+parse_options_failure:
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
-- 
2.1.3

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

* [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-18 19:16                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 19:16 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:10:34 +0100

The proc_remove() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/core/pktgen.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8b849dd..35046a8 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3698,8 +3698,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
 	/* Remove proc before if_list entry, because add_device uses
 	 * list to determine if interface already exist, avoid race
 	 * with proc_create_data() */
-	if (pkt_dev->entry)
-		proc_remove(pkt_dev->entry);
+	proc_remove(pkt_dev->entry);
 
 	/* And update the thread if_list */
 	_rem_dev_from_if_list(t, pkt_dev);
-- 
2.1.3


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

* [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"
@ 2014-11-18 19:16                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 19:16 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:10:34 +0100

The proc_remove() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/core/pktgen.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8b849dd..35046a8 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3698,8 +3698,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
 	/* Remove proc before if_list entry, because add_device uses
 	 * list to determine if interface already exist, avoid race
 	 * with proc_create_data() */
-	if (pkt_dev->entry)
-		proc_remove(pkt_dev->entry);
+	proc_remove(pkt_dev->entry);
 
 	/* And update the thread if_list */
 	_rem_dev_from_if_list(t, pkt_dev);
-- 
2.1.3

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

* [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"
@ 2014-11-18 19:16                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 19:16 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:10:34 +0100

The proc_remove() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/core/pktgen.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8b849dd..35046a8 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3698,8 +3698,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
 	/* Remove proc before if_list entry, because add_device uses
 	 * list to determine if interface already exist, avoid race
 	 * with proc_create_data() */
-	if (pkt_dev->entry)
-		proc_remove(pkt_dev->entry);
+	proc_remove(pkt_dev->entry);
 
 	/* And update the thread if_list */
 	_rem_dev_from_if_list(t, pkt_dev);
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"
@ 2014-11-18 19:16                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 19:16 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:10:34 +0100

The proc_remove() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/core/pktgen.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8b849dd..35046a8 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3698,8 +3698,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
 	/* Remove proc before if_list entry, because add_device uses
 	 * list to determine if interface already exist, avoid race
 	 * with proc_create_data() */
-	if (pkt_dev->entry)
-		proc_remove(pkt_dev->entry);
+	proc_remove(pkt_dev->entry);
 
 	/* And update the thread if_list */
 	_rem_dev_from_if_list(t, pkt_dev);
-- 
2.1.3

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

* [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-18 19:47                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 19:47 UTC (permalink / raw)
  To: David S. Miller, Jozsef Kadlecsik, Julian Anastasov,
	Pablo Neira Ayuso, Patrick McHardy, Simon Horman, Wensong Zhang,
	netdev, lvs-devel, netfilter-devel, coreteam
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:37:05 +0100

The functions free_percpu() and module_put() test whether their argument
is NULL and then return immediately. Thus the test around the call is
not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
 net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
 net/netfilter/ipvs/ip_vs_sched.c | 3 +--
 net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
 net/netfilter/nf_tables_api.c    | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index fd3f444..7c5e40a 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 
 static void ip_vs_service_free(struct ip_vs_service *svc)
 {
-	if (svc->stats.cpustats)
-		free_percpu(svc->stats.cpustats);
+	free_percpu(svc->stats.cpustats);
 	kfree(svc);
 }
 
diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
index 1a82b29..0df17ca 100644
--- a/net/netfilter/ipvs/ip_vs_pe.c
+++ b/net/netfilter/ipvs/ip_vs_pe.c
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
 			rcu_read_unlock();
 			return pe;
 		}
-		if (pe->module)
-			module_put(pe->module);
+		module_put(pe->module);
 	}
 	rcu_read_unlock();
 
diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
index 4dbcda6..199760c 100644
--- a/net/netfilter/ipvs/ip_vs_sched.c
+++ b/net/netfilter/ipvs/ip_vs_sched.c
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
 			mutex_unlock(&ip_vs_sched_mutex);
 			return sched;
 		}
-		if (sched->module)
-			module_put(sched->module);
+		module_put(sched->module);
 	}
 
 	mutex_unlock(&ip_vs_sched_mutex);
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index eadffb2..cafe28d 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
 
 		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
 		if (!p->pe_data) {
-			if (p->pe->module)
-				module_put(p->pe->module);
+			module_put(p->pe->module);
 			return -ENOMEM;
 		}
 		p->pe_data_len = pe_data_len;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index deeb95f..b115f54 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
 			break;
 		case NFT_MSG_NEWCHAIN:
 			if (nft_trans_chain_update(trans)) {
-				if (nft_trans_chain_stats(trans))
-					free_percpu(nft_trans_chain_stats(trans));
+				free_percpu(nft_trans_chain_stats(trans));
 
 				nft_trans_destroy(trans);
 			} else {
-- 
2.1.3


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

* [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
@ 2014-11-18 19:47                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 19:47 UTC (permalink / raw)
  To: David S. Miller, Jozsef Kadlecsik, Julian Anastasov,
	Pablo Neira Ayuso, Patrick McHardy, Simon Horman, Wensong Zhang,
	netdev, lvs-devel, netfilter-devel, coreteam
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:37:05 +0100

The functions free_percpu() and module_put() test whether their argument
is NULL and then return immediately. Thus the test around the call is
not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
 net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
 net/netfilter/ipvs/ip_vs_sched.c | 3 +--
 net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
 net/netfilter/nf_tables_api.c    | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index fd3f444..7c5e40a 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 
 static void ip_vs_service_free(struct ip_vs_service *svc)
 {
-	if (svc->stats.cpustats)
-		free_percpu(svc->stats.cpustats);
+	free_percpu(svc->stats.cpustats);
 	kfree(svc);
 }
 
diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
index 1a82b29..0df17ca 100644
--- a/net/netfilter/ipvs/ip_vs_pe.c
+++ b/net/netfilter/ipvs/ip_vs_pe.c
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
 			rcu_read_unlock();
 			return pe;
 		}
-		if (pe->module)
-			module_put(pe->module);
+		module_put(pe->module);
 	}
 	rcu_read_unlock();
 
diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
index 4dbcda6..199760c 100644
--- a/net/netfilter/ipvs/ip_vs_sched.c
+++ b/net/netfilter/ipvs/ip_vs_sched.c
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
 			mutex_unlock(&ip_vs_sched_mutex);
 			return sched;
 		}
-		if (sched->module)
-			module_put(sched->module);
+		module_put(sched->module);
 	}
 
 	mutex_unlock(&ip_vs_sched_mutex);
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index eadffb2..cafe28d 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
 
 		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
 		if (!p->pe_data) {
-			if (p->pe->module)
-				module_put(p->pe->module);
+			module_put(p->pe->module);
 			return -ENOMEM;
 		}
 		p->pe_data_len = pe_data_len;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index deeb95f..b115f54 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
 			break;
 		case NFT_MSG_NEWCHAIN:
 			if (nft_trans_chain_update(trans)) {
-				if (nft_trans_chain_stats(trans))
-					free_percpu(nft_trans_chain_stats(trans));
+				free_percpu(nft_trans_chain_stats(trans));
 
 				nft_trans_destroy(trans);
 			} else {
-- 
2.1.3


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

* [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
@ 2014-11-18 19:47                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 19:47 UTC (permalink / raw)
  To: David S. Miller, Jozsef Kadlecsik, Julian Anastasov,
	Pablo Neira Ayuso, Patrick McHardy, Simon Horman, Wensong Zhang,
	netdev, lvs-devel, netfilter-devel, coreteam
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:37:05 +0100

The functions free_percpu() and module_put() test whether their argument
is NULL and then return immediately. Thus the test around the call is
not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
 net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
 net/netfilter/ipvs/ip_vs_sched.c | 3 +--
 net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
 net/netfilter/nf_tables_api.c    | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index fd3f444..7c5e40a 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 
 static void ip_vs_service_free(struct ip_vs_service *svc)
 {
-	if (svc->stats.cpustats)
-		free_percpu(svc->stats.cpustats);
+	free_percpu(svc->stats.cpustats);
 	kfree(svc);
 }
 
diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
index 1a82b29..0df17ca 100644
--- a/net/netfilter/ipvs/ip_vs_pe.c
+++ b/net/netfilter/ipvs/ip_vs_pe.c
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
 			rcu_read_unlock();
 			return pe;
 		}
-		if (pe->module)
-			module_put(pe->module);
+		module_put(pe->module);
 	}
 	rcu_read_unlock();
 
diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
index 4dbcda6..199760c 100644
--- a/net/netfilter/ipvs/ip_vs_sched.c
+++ b/net/netfilter/ipvs/ip_vs_sched.c
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
 			mutex_unlock(&ip_vs_sched_mutex);
 			return sched;
 		}
-		if (sched->module)
-			module_put(sched->module);
+		module_put(sched->module);
 	}
 
 	mutex_unlock(&ip_vs_sched_mutex);
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index eadffb2..cafe28d 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
 
 		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
 		if (!p->pe_data) {
-			if (p->pe->module)
-				module_put(p->pe->module);
+			module_put(p->pe->module);
 			return -ENOMEM;
 		}
 		p->pe_data_len = pe_data_len;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index deeb95f..b115f54 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
 			break;
 		case NFT_MSG_NEWCHAIN:
 			if (nft_trans_chain_update(trans)) {
-				if (nft_trans_chain_stats(trans))
-					free_percpu(nft_trans_chain_stats(trans));
+				free_percpu(nft_trans_chain_stats(trans));
 
 				nft_trans_destroy(trans);
 			} else {
-- 
2.1.3


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

* [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-18 20:08                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:08 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:03:13 +0100

The __module_get() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlink/af_netlink.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f1de72d..0317b91 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -142,8 +142,7 @@ int netlink_add_tap(struct netlink_tap *nt)
 	list_add_rcu(&nt->list, &netlink_tap_all);
 	spin_unlock(&netlink_tap_lock);
 
-	if (nt->module)
-		__module_get(nt->module);
+	__module_get(nt->module);
 
 	return 0;
 }
-- 
2.1.3


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

* [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get"
@ 2014-11-18 20:08                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:08 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:03:13 +0100

The __module_get() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlink/af_netlink.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f1de72d..0317b91 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -142,8 +142,7 @@ int netlink_add_tap(struct netlink_tap *nt)
 	list_add_rcu(&nt->list, &netlink_tap_all);
 	spin_unlock(&netlink_tap_lock);
 
-	if (nt->module)
-		__module_get(nt->module);
+	__module_get(nt->module);
 
 	return 0;
 }
-- 
2.1.3

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

* [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get"
@ 2014-11-18 20:08                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:08 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:03:13 +0100

The __module_get() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlink/af_netlink.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f1de72d..0317b91 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -142,8 +142,7 @@ int netlink_add_tap(struct netlink_tap *nt)
 	list_add_rcu(&nt->list, &netlink_tap_all);
 	spin_unlock(&netlink_tap_lock);
 
-	if (nt->module)
-		__module_get(nt->module);
+	__module_get(nt->module);
 
 	return 0;
 }
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get"
@ 2014-11-18 20:08                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:08 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:03:13 +0100

The __module_get() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlink/af_netlink.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f1de72d..0317b91 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -142,8 +142,7 @@ int netlink_add_tap(struct netlink_tap *nt)
 	list_add_rcu(&nt->list, &netlink_tap_all);
 	spin_unlock(&netlink_tap_lock);
 
-	if (nt->module)
-		__module_get(nt->module);
+	__module_get(nt->module);
 
 	return 0;
 }
-- 
2.1.3

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

* [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-18 20:26                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:26 UTC (permalink / raw)
  To: David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:21:16 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/sched/cls_bpf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 0e30d58..f323944 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
 
 	if (fp_old)
 		bpf_prog_destroy(fp_old);
-	if (bpf_old)
-		kfree(bpf_old);
+	kfree(bpf_old);
 
 	return 0;
 
-- 
2.1.3


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

* [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-18 20:26                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:26 UTC (permalink / raw)
  To: David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:21:16 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/sched/cls_bpf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 0e30d58..f323944 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
 
 	if (fp_old)
 		bpf_prog_destroy(fp_old);
-	if (bpf_old)
-		kfree(bpf_old);
+	kfree(bpf_old);
 
 	return 0;
 
-- 
2.1.3

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

* [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-18 20:26                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:26 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:21:16 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/sched/cls_bpf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 0e30d58..f323944 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
 
 	if (fp_old)
 		bpf_prog_destroy(fp_old);
-	if (bpf_old)
-		kfree(bpf_old);
+	kfree(bpf_old);
 
 	return 0;
 
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-18 20:26                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:26 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:21:16 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/sched/cls_bpf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 0e30d58..f323944 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
 
 	if (fp_old)
 		bpf_prog_destroy(fp_old);
-	if (bpf_old)
-		kfree(bpf_old);
+	kfree(bpf_old);
 
 	return 0;
 
-- 
2.1.3

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

* [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-18 20:45                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:45 UTC (permalink / raw)
  To: David S. Miller, Herbert Xu, Steffen Klassert, netdev
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:41:26 +0100

The ipcomp_free_tfms() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/xfrm/xfrm_ipcomp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index ccfdc71..47863cd 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -320,8 +320,7 @@ error:
 
 static void ipcomp_free_data(struct ipcomp_data *ipcd)
 {
-	if (ipcd->tfms)
-		ipcomp_free_tfms(ipcd->tfms);
+	ipcomp_free_tfms(ipcd->tfms);
 	ipcomp_free_scratches();
 }
 
-- 
2.1.3


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

* [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
@ 2014-11-18 20:45                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:45 UTC (permalink / raw)
  To: David S. Miller, Herbert Xu, Steffen Klassert, netdev
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:41:26 +0100

The ipcomp_free_tfms() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/xfrm/xfrm_ipcomp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index ccfdc71..47863cd 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -320,8 +320,7 @@ error:
 
 static void ipcomp_free_data(struct ipcomp_data *ipcd)
 {
-	if (ipcd->tfms)
-		ipcomp_free_tfms(ipcd->tfms);
+	ipcomp_free_tfms(ipcd->tfms);
 	ipcomp_free_scratches();
 }
 
-- 
2.1.3

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

* [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
@ 2014-11-18 20:45                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:45 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:41:26 +0100

The ipcomp_free_tfms() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/xfrm/xfrm_ipcomp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index ccfdc71..47863cd 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -320,8 +320,7 @@ error:
 
 static void ipcomp_free_data(struct ipcomp_data *ipcd)
 {
-	if (ipcd->tfms)
-		ipcomp_free_tfms(ipcd->tfms);
+	ipcomp_free_tfms(ipcd->tfms);
 	ipcomp_free_scratches();
 }
 
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
@ 2014-11-18 20:45                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:45 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:41:26 +0100

The ipcomp_free_tfms() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/xfrm/xfrm_ipcomp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index ccfdc71..47863cd 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -320,8 +320,7 @@ error:
 
 static void ipcomp_free_data(struct ipcomp_data *ipcd)
 {
-	if (ipcd->tfms)
-		ipcomp_free_tfms(ipcd->tfms);
+	ipcomp_free_tfms(ipcd->tfms);
 	ipcomp_free_scratches();
 }
 
-- 
2.1.3

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

* [PATCH 1/1] keys: Deletion of an unnecessary check before the function call "key_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-18 21:03                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 21:03 UTC (permalink / raw)
  To: David Howells, James Morris, Serge E. Hallyn, keyrings,
	linux-security-module
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:57:14 +0100

The key_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 security/keys/process_keys.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 0cf8a13..ce00e11 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -242,8 +242,7 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
 	old = cred->session_keyring;
 	rcu_assign_pointer(cred->session_keyring, keyring);
 
-	if (old)
-		key_put(old);
+	key_put(old);
 
 	return 0;
 }
-- 
2.1.3


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

* [PATCH 1/1] keys: Deletion of an unnecessary check before the function call "key_put"
@ 2014-11-18 21:03                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 21:03 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:57:14 +0100

The key_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 security/keys/process_keys.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 0cf8a13..ce00e11 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -242,8 +242,7 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
 	old = cred->session_keyring;
 	rcu_assign_pointer(cred->session_keyring, keyring);
 
-	if (old)
-		key_put(old);
+	key_put(old);
 
 	return 0;
 }
-- 
2.1.3


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

* [Cocci] [PATCH 1/1] keys: Deletion of an unnecessary check before the function call "key_put"
@ 2014-11-18 21:03                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-18 21:03 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:57:14 +0100

The key_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 security/keys/process_keys.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 0cf8a13..ce00e11 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -242,8 +242,7 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
 	old = cred->session_keyring;
 	rcu_assign_pointer(cred->session_keyring, keyring);
 
-	if (old)
-		key_put(old);
+	key_put(old);
 
 	return 0;
 }
-- 
2.1.3

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

* Re: [PATCH 1/1] mm/zswap: Deletion of an unnecessary check before the function call "free_percpu"
  2014-11-17 17:40                                   ` SF Markus Elfring
  (?)
@ 2014-11-18 22:17                                     ` Seth Jennings
  -1 siblings, 0 replies; 3633+ messages in thread
From: Seth Jennings @ 2014-11-18 22:17 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-mm, LKML, kernel-janitors, Coccinelle

On Mon, Nov 17, 2014 at 06:40:18PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 18:33:33 +0100
> 
> The free_percpu() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.

Thanks for the cleanup!

Acked-by: Seth Jennings <sjennings@variantweb.net>

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  mm/zswap.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index ea064c1..35629f0 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -152,8 +152,7 @@ static int __init zswap_comp_init(void)
>  static void zswap_comp_exit(void)
>  {
>  	/* free percpu transforms */
> -	if (zswap_comp_pcpu_tfms)
> -		free_percpu(zswap_comp_pcpu_tfms);
> +	free_percpu(zswap_comp_pcpu_tfms);
>  }
>  
>  /*********************************
> -- 
> 2.1.3
> 

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

* Re: [PATCH 1/1] mm/zswap: Deletion of an unnecessary check before the function call "free_percpu"
@ 2014-11-18 22:17                                     ` Seth Jennings
  0 siblings, 0 replies; 3633+ messages in thread
From: Seth Jennings @ 2014-11-18 22:17 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-mm, LKML, kernel-janitors, Coccinelle

On Mon, Nov 17, 2014 at 06:40:18PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 18:33:33 +0100
> 
> The free_percpu() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.

Thanks for the cleanup!

Acked-by: Seth Jennings <sjennings@variantweb.net>

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  mm/zswap.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index ea064c1..35629f0 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -152,8 +152,7 @@ static int __init zswap_comp_init(void)
>  static void zswap_comp_exit(void)
>  {
>  	/* free percpu transforms */
> -	if (zswap_comp_pcpu_tfms)
> -		free_percpu(zswap_comp_pcpu_tfms);
> +	free_percpu(zswap_comp_pcpu_tfms);
>  }
>  
>  /*********************************
> -- 
> 2.1.3
> 

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

* Re: [PATCH 1/1] mm/zswap: Deletion of an unnecessary check before the function call "free_percpu"
@ 2014-11-18 22:17                                     ` Seth Jennings
  0 siblings, 0 replies; 3633+ messages in thread
From: Seth Jennings @ 2014-11-18 22:17 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-mm, LKML, kernel-janitors, Coccinelle

On Mon, Nov 17, 2014 at 06:40:18PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Nov 2014 18:33:33 +0100
> 
> The free_percpu() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.

Thanks for the cleanup!

Acked-by: Seth Jennings <sjennings@variantweb.net>

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  mm/zswap.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index ea064c1..35629f0 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -152,8 +152,7 @@ static int __init zswap_comp_init(void)
>  static void zswap_comp_exit(void)
>  {
>  	/* free percpu transforms */
> -	if (zswap_comp_pcpu_tfms)
> -		free_percpu(zswap_comp_pcpu_tfms);
> +	free_percpu(zswap_comp_pcpu_tfms);
>  }
>  
>  /*********************************
> -- 
> 2.1.3
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH 1/1] kernel-power: Deletion of an unnecessary check before the function call "vfree"
  2014-11-16 13:28                                   ` SF Markus Elfring
@ 2014-11-18 23:32                                     ` Rafael J. Wysocki
  -1 siblings, 0 replies; 3633+ messages in thread
From: Rafael J. Wysocki @ 2014-11-18 23:32 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Len Brown, Pavel Machek, linux-pm, LKML, kernel-janitors, Coccinelle

On Sunday, November 16, 2014 02:28:23 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 14:18:28 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Queued up for 3.19-rc1, thanks!

> ---
>  kernel/power/swap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index aaa3261..337c7a9 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -1374,7 +1374,7 @@ out_clean:
>  				kthread_stop(data[thr].thr);
>  		vfree(data);
>  	}
> -	if (page) vfree(page);
> +	vfree(page);
>  
>  	return ret;
>  }
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH 1/1] kernel-power: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-18 23:32                                     ` Rafael J. Wysocki
  0 siblings, 0 replies; 3633+ messages in thread
From: Rafael J. Wysocki @ 2014-11-18 23:32 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Len Brown, Pavel Machek, linux-pm, LKML, kernel-janitors, Coccinelle

On Sunday, November 16, 2014 02:28:23 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Nov 2014 14:18:28 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Queued up for 3.19-rc1, thanks!

> ---
>  kernel/power/swap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index aaa3261..337c7a9 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -1374,7 +1374,7 @@ out_clean:
>  				kthread_stop(data[thr].thr);
>  		vfree(data);
>  	}
> -	if (page) vfree(page);
> +	vfree(page);
>  
>  	return ret;
>  }
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH 1/1] nilfs2: Deletion of an unnecessary check before the function call "iput"
  2014-11-18 13:48                                   ` SF Markus Elfring
@ 2014-11-19  0:09                                     ` Ryusuke Konishi
  -1 siblings, 0 replies; 3633+ messages in thread
From: Ryusuke Konishi @ 2014-11-19  0:09 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-nilfs, LKML, kernel-janitors, cocci

On Tue, 18 Nov 2014 14:48:09 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 14:41:27 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to nilfs2 git tree.  Thanks.

Ryusuke Konishi


> ---
>  fs/nilfs2/the_nilfs.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
> index 9da25fe..69bd801 100644
> --- a/fs/nilfs2/the_nilfs.c
> +++ b/fs/nilfs2/the_nilfs.c
> @@ -808,8 +808,7 @@ void nilfs_put_root(struct nilfs_root *root)
>  		spin_lock(&nilfs->ns_cptree_lock);
>  		rb_erase(&root->rb_node, &nilfs->ns_cptree);
>  		spin_unlock(&nilfs->ns_cptree_lock);
> -		if (root->ifile)
> -			iput(root->ifile);
> +		iput(root->ifile);
>  
>  		kfree(root);
>  	}
> -- 
> 2.1.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] nilfs2: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-19  0:09                                     ` Ryusuke Konishi
  0 siblings, 0 replies; 3633+ messages in thread
From: Ryusuke Konishi @ 2014-11-19  0:09 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-nilfs, LKML, kernel-janitors, cocci

On Tue, 18 Nov 2014 14:48:09 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 14:41:27 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to nilfs2 git tree.  Thanks.

Ryusuke Konishi


> ---
>  fs/nilfs2/the_nilfs.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
> index 9da25fe..69bd801 100644
> --- a/fs/nilfs2/the_nilfs.c
> +++ b/fs/nilfs2/the_nilfs.c
> @@ -808,8 +808,7 @@ void nilfs_put_root(struct nilfs_root *root)
>  		spin_lock(&nilfs->ns_cptree_lock);
>  		rb_erase(&root->rb_node, &nilfs->ns_cptree);
>  		spin_unlock(&nilfs->ns_cptree_lock);
> -		if (root->ifile)
> -			iput(root->ifile);
> +		iput(root->ifile);
>  
>  		kfree(root);
>  	}
> -- 
> 2.1.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
  2014-11-17  8:23                                     ` Masami Hiramatsu
  (?)
@ 2014-11-19  7:08                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19  7:08 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, linux-kernel, kernel-janitors, Coccinelle

>> index 3995f54..f1e7d45 100644
>> --- a/kernel/kprobes.c
>> +++ b/kernel/kprobes.c
>> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>>  out:
>>  	mutex_unlock(&kprobe_mutex);
>>  
>> -	if (probed_mod)
>> -		module_put(probed_mod);
>> +	module_put(probed_mod);
> 
> This is OK, but I you request a comment line over there so that
> code reader can understand it is safe to pass a NULL pointer to
> module_put().

Do you want that I replace the shown null pointer check by a short
comment which repeats an expectation for the affected function call?

Regards,
Markus


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

* Re: [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-19  7:08                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19  7:08 UTC (permalink / raw)
  To: cocci

>> index 3995f54..f1e7d45 100644
>> --- a/kernel/kprobes.c
>> +++ b/kernel/kprobes.c
>> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>>  out:
>>  	mutex_unlock(&kprobe_mutex);
>>  
>> -	if (probed_mod)
>> -		module_put(probed_mod);
>> +	module_put(probed_mod);
> 
> This is OK, but I you request a comment line over there so that
> code reader can understand it is safe to pass a NULL pointer to
> module_put().

Do you want that I replace the shown null pointer check by a short
comment which repeats an expectation for the affected function call?

Regards,
Markus


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

* [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-19  7:08                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19  7:08 UTC (permalink / raw)
  To: cocci

>> index 3995f54..f1e7d45 100644
>> --- a/kernel/kprobes.c
>> +++ b/kernel/kprobes.c
>> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>>  out:
>>  	mutex_unlock(&kprobe_mutex);
>>  
>> -	if (probed_mod)
>> -		module_put(probed_mod);
>> +	module_put(probed_mod);
> 
> This is OK, but I you request a comment line over there so that
> code reader can understand it is safe to pass a NULL pointer to
> module_put().

Do you want that I replace the shown null pointer check by a short
comment which repeats an expectation for the affected function call?

Regards,
Markus

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

* Re: [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-18 20:45                                   ` SF Markus Elfring
  (?)
@ 2014-11-19  8:45                                     ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-19  8:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Herbert Xu, Steffen Klassert, netdev, LKML,
	kernel-janitors, Coccinelle

On Tue, Nov 18, 2014 at 09:45:41PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:41:26 +0100
> 
> The ipcomp_free_tfms() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 

It doesn't though...

regards,
dan carpenter


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

* Re: [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tf
@ 2014-11-19  8:45                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-19  8:45 UTC (permalink / raw)
  To: cocci

On Tue, Nov 18, 2014 at 09:45:41PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:41:26 +0100
> 
> The ipcomp_free_tfms() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 

It doesn't though...

regards,
dan carpenter


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

* [Cocci] [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
@ 2014-11-19  8:45                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-19  8:45 UTC (permalink / raw)
  To: cocci

On Tue, Nov 18, 2014 at 09:45:41PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:41:26 +0100
> 
> The ipcomp_free_tfms() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 

It doesn't though...

regards,
dan carpenter

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

* [PATCH 1/1] crypto-drbg: Deletion of unnecessary checks before the function call "kzfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19  9:20                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19  9:20 UTC (permalink / raw)
  To: David S. Miller, Herbert Xu, linux-crypto
  Cc: Linux Kernel Mailing List, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 10:11:04 +0100

The kzfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 crypto/drbg.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/crypto/drbg.c b/crypto/drbg.c
index a53ee09..b6f22d4 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1151,8 +1151,7 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers,
 	drbg->reseed_ctr = 1;
 
 out:
-	if (entropy)
-		kzfree(entropy);
+	kzfree(entropy);
 	return ret;
 }
 
@@ -1161,19 +1160,15 @@ static inline void drbg_dealloc_state(struct drbg_state *drbg)
 {
 	if (!drbg)
 		return;
-	if (drbg->V)
-		kzfree(drbg->V);
+	kzfree(drbg->V);
 	drbg->V = NULL;
-	if (drbg->C)
-		kzfree(drbg->C);
+	kzfree(drbg->C);
 	drbg->C = NULL;
-	if (drbg->scratchpad)
-		kzfree(drbg->scratchpad);
+	kzfree(drbg->scratchpad);
 	drbg->scratchpad = NULL;
 	drbg->reseed_ctr = 0;
 #ifdef CONFIG_CRYPTO_FIPS
-	if (drbg->prev)
-		kzfree(drbg->prev);
+	kzfree(drbg->prev);
 	drbg->prev = NULL;
 	drbg->fips_primed = false;
 #endif
@@ -1293,8 +1288,7 @@ static int drbg_make_shadow(struct drbg_state *drbg, struct drbg_state **shadow)
 	return 0;
 
 err:
-	if (tmp)
-		kzfree(tmp);
+	kzfree(tmp);
 	return ret;
 }
 
-- 
2.1.3

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

* [PATCH 1/1] crypto-drbg: Deletion of unnecessary checks before the function call "kzfree"
@ 2014-11-19  9:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19  9:20 UTC (permalink / raw)
  To: David S. Miller, Herbert Xu, linux-crypto
  Cc: Linux Kernel Mailing List, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 10:11:04 +0100

The kzfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 crypto/drbg.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/crypto/drbg.c b/crypto/drbg.c
index a53ee09..b6f22d4 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1151,8 +1151,7 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers,
 	drbg->reseed_ctr = 1;
 
 out:
-	if (entropy)
-		kzfree(entropy);
+	kzfree(entropy);
 	return ret;
 }
 
@@ -1161,19 +1160,15 @@ static inline void drbg_dealloc_state(struct drbg_state *drbg)
 {
 	if (!drbg)
 		return;
-	if (drbg->V)
-		kzfree(drbg->V);
+	kzfree(drbg->V);
 	drbg->V = NULL;
-	if (drbg->C)
-		kzfree(drbg->C);
+	kzfree(drbg->C);
 	drbg->C = NULL;
-	if (drbg->scratchpad)
-		kzfree(drbg->scratchpad);
+	kzfree(drbg->scratchpad);
 	drbg->scratchpad = NULL;
 	drbg->reseed_ctr = 0;
 #ifdef CONFIG_CRYPTO_FIPS
-	if (drbg->prev)
-		kzfree(drbg->prev);
+	kzfree(drbg->prev);
 	drbg->prev = NULL;
 	drbg->fips_primed = false;
 #endif
@@ -1293,8 +1288,7 @@ static int drbg_make_shadow(struct drbg_state *drbg, struct drbg_state **shadow)
 	return 0;
 
 err:
-	if (tmp)
-		kzfree(tmp);
+	kzfree(tmp);
 	return ret;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] crypto-drbg: Deletion of unnecessary checks before the function call "kzfree"
@ 2014-11-19  9:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19  9:20 UTC (permalink / raw)
  To: David S. Miller, Herbert Xu, linux-crypto
  Cc: Linux Kernel Mailing List, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 10:11:04 +0100

The kzfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 crypto/drbg.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/crypto/drbg.c b/crypto/drbg.c
index a53ee09..b6f22d4 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1151,8 +1151,7 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers,
 	drbg->reseed_ctr = 1;
 
 out:
-	if (entropy)
-		kzfree(entropy);
+	kzfree(entropy);
 	return ret;
 }
 
@@ -1161,19 +1160,15 @@ static inline void drbg_dealloc_state(struct drbg_state *drbg)
 {
 	if (!drbg)
 		return;
-	if (drbg->V)
-		kzfree(drbg->V);
+	kzfree(drbg->V);
 	drbg->V = NULL;
-	if (drbg->C)
-		kzfree(drbg->C);
+	kzfree(drbg->C);
 	drbg->C = NULL;
-	if (drbg->scratchpad)
-		kzfree(drbg->scratchpad);
+	kzfree(drbg->scratchpad);
 	drbg->scratchpad = NULL;
 	drbg->reseed_ctr = 0;
 #ifdef CONFIG_CRYPTO_FIPS
-	if (drbg->prev)
-		kzfree(drbg->prev);
+	kzfree(drbg->prev);
 	drbg->prev = NULL;
 	drbg->fips_primed = false;
 #endif
@@ -1293,8 +1288,7 @@ static int drbg_make_shadow(struct drbg_state *drbg, struct drbg_state **shadow)
 	return 0;
 
 err:
-	if (tmp)
-		kzfree(tmp);
+	kzfree(tmp);
 	return ret;
 }
 
-- 
2.1.3


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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-19  8:45                                     ` [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tf Dan Carpenter
@ 2014-11-19  9:51                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19  9:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David S. Miller, Herbert Xu, Steffen Klassert, netdev, LKML,
	kernel-janitors, Julia Lawall

>> The ipcomp_free_tfms() function tests whether its argument is NULL and then
>> returns immediately. Thus the test around the call is not needed.
> 
> It doesn't though...

You are right that this function implementation does a bit more before
returning because of a detected null pointer.
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/xfrm/xfrm_ipcomp.c?id=394efd19d5fcae936261bd48e5b33b21897aacf8#n247

Can you agree that input parameter validation is also performed there?
Do you want that I resend my patch with a corrected commit message?

Regards,
Markus

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
@ 2014-11-19  9:51                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19  9:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David S. Miller, Herbert Xu, Steffen Klassert, netdev, LKML,
	kernel-janitors, Julia Lawall

>> The ipcomp_free_tfms() function tests whether its argument is NULL and then
>> returns immediately. Thus the test around the call is not needed.
> 
> It doesn't though...

You are right that this function implementation does a bit more before
returning because of a detected null pointer.
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/xfrm/xfrm_ipcomp.c?id94efd19d5fcae936261bd48e5b33b21897aacf8#n247

Can you agree that input parameter validation is also performed there?
Do you want that I resend my patch with a corrected commit message?

Regards,
Markus

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-19  9:51                                       ` SF Markus Elfring
@ 2014-11-19  9:58                                         ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-19  9:58 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, David S. Miller, Herbert Xu, Steffen Klassert,
	netdev, LKML, kernel-janitors



On Wed, 19 Nov 2014, SF Markus Elfring wrote:

> >> The ipcomp_free_tfms() function tests whether its argument is NULL and then
> >> returns immediately. Thus the test around the call is not needed.
> >
> > It doesn't though...
>
> You are right that this function implementation does a bit more before
> returning because of a detected null pointer.
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/xfrm/xfrm_ipcomp.c?id=394efd19d5fcae936261bd48e5b33b21897aacf8#n247
>
> Can you agree that input parameter validation is also performed there?
> Do you want that I resend my patch with a corrected commit message?

This is completely crazy.  The function performs a side effect on a data
structure.  If the call site doesn't want that done in a certain case,
then it should not be done.

julia

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
@ 2014-11-19  9:58                                         ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-19  9:58 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, David S. Miller, Herbert Xu, Steffen Klassert,
	netdev, LKML, kernel-janitors



On Wed, 19 Nov 2014, SF Markus Elfring wrote:

> >> The ipcomp_free_tfms() function tests whether its argument is NULL and then
> >> returns immediately. Thus the test around the call is not needed.
> >
> > It doesn't though...
>
> You are right that this function implementation does a bit more before
> returning because of a detected null pointer.
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/xfrm/xfrm_ipcomp.c?id94efd19d5fcae936261bd48e5b33b21897aacf8#n247
>
> Can you agree that input parameter validation is also performed there?
> Do you want that I resend my patch with a corrected commit message?

This is completely crazy.  The function performs a side effect on a data
structure.  If the call site doesn't want that done in a certain case,
then it should not be done.

julia

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-19  9:51                                       ` SF Markus Elfring
@ 2014-11-19 10:10                                         ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-19 10:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Herbert Xu, Steffen Klassert, netdev, LKML,
	kernel-janitors, Julia Lawall

I have come to view you as a very clever troll.  You will say
infuriating things like "That is an interesting background information
but the function implementation update suggestion is correct" and
pretend to not see the bug for nine emails.  Then you'll say something
"Ha ha, I audited all the call trees and it can't actually be NULL so
you were getting angry for no reason."  Except you'll say it in a
more obfuscated way than that.  This is what you did last time.

regards,
dan carpenter


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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
@ 2014-11-19 10:10                                         ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-19 10:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Herbert Xu, Steffen Klassert, netdev, LKML,
	kernel-janitors, Julia Lawall

I have come to view you as a very clever troll.  You will say
infuriating things like "That is an interesting background information
but the function implementation update suggestion is correct" and
pretend to not see the bug for nine emails.  Then you'll say something
"Ha ha, I audited all the call trees and it can't actually be NULL so
you were getting angry for no reason."  Except you'll say it in a
more obfuscated way than that.  This is what you did last time.

regards,
dan carpenter


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

* [PATCH 1/1] firmware class: Deletion of an unnecessary check before the function call "vunmap"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-19 10:44                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 10:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ming Lei; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 11:38:38 +0100

The vunmap() function performes also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/base/firmware_class.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 3d785eb..532662c 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -591,8 +591,7 @@ static int fw_map_pages_buf(struct firmware_buf *buf)
 	if (!buf->is_paged_buf)
 		return 0;
 
-	if (buf->data)
-		vunmap(buf->data);
+	vunmap(buf->data);
 	buf->data = vmap(buf->pages, buf->nr_pages, 0, PAGE_KERNEL_RO);
 	if (!buf->data)
 		return -ENOMEM;
-- 
2.1.3


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

* [PATCH 1/1] firmware class: Deletion of an unnecessary check before the function call "vunmap"
@ 2014-11-19 10:44                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 10:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ming Lei; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 11:38:38 +0100

The vunmap() function performes also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/base/firmware_class.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 3d785eb..532662c 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -591,8 +591,7 @@ static int fw_map_pages_buf(struct firmware_buf *buf)
 	if (!buf->is_paged_buf)
 		return 0;
 
-	if (buf->data)
-		vunmap(buf->data);
+	vunmap(buf->data);
 	buf->data = vmap(buf->pages, buf->nr_pages, 0, PAGE_KERNEL_RO);
 	if (!buf->data)
 		return -ENOMEM;
-- 
2.1.3


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

* [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 11:26                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 11:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Len Brown, Pavel Machek, Rafael J. Wysocki, linux-pm
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 12:21:24 +0100

The wakeup_source_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/base/power/wakeup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index eb1bd2e..87dfc1d 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
+	wakeup_source_unregister(ws);
 
 	return 0;
 }
-- 
2.1.3


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

* [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unre
@ 2014-11-19 11:26                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 11:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Len Brown, Pavel Machek, Rafael J. Wysocki, linux-pm
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 12:21:24 +0100

The wakeup_source_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/base/power/wakeup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index eb1bd2e..87dfc1d 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
+	wakeup_source_unregister(ws);
 
 	return 0;
 }
-- 
2.1.3


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

* [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"
@ 2014-11-19 11:26                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 11:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Len Brown, Pavel Machek, Rafael J. Wysocki, linux-pm
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 12:21:24 +0100

The wakeup_source_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/base/power/wakeup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index eb1bd2e..87dfc1d 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
+	wakeup_source_unregister(ws);
 
 	return 0;
 }
-- 
2.1.3

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

* Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"
  2014-11-19 11:26                                   ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unre SF Markus Elfring
@ 2014-11-19 12:09                                     ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-19 12:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, Len Brown, Pavel Machek, Rafael J. Wysocki,
	linux-pm, LKML, kernel-janitors, Julia Lawall

On Wed, Nov 19, 2014 at 12:26:45PM +0100, SF Markus Elfring wrote:
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
>  		return -EINVAL;
>  
>  	ws = device_wakeup_detach(dev);
> -	if (ws)
> -		wakeup_source_unregister(ws);
> +	wakeup_source_unregister(ws);

In the original code, it's clear that the programmer thought about what
happens when the device_wakeup_detach() returns NULL but in the new code
that's not clear.

I guess the information is still there in the git archive, but why hide
the good code by covering it with confusing code?

regards,
dan carpenter


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

* Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_
@ 2014-11-19 12:09                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-19 12:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, Len Brown, Pavel Machek, Rafael J. Wysocki,
	linux-pm, LKML, kernel-janitors, Julia Lawall

On Wed, Nov 19, 2014 at 12:26:45PM +0100, SF Markus Elfring wrote:
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
>  		return -EINVAL;
>  
>  	ws = device_wakeup_detach(dev);
> -	if (ws)
> -		wakeup_source_unregister(ws);
> +	wakeup_source_unregister(ws);

In the original code, it's clear that the programmer thought about what
happens when the device_wakeup_detach() returns NULL but in the new code
that's not clear.

I guess the information is still there in the git archive, but why hide
the good code by covering it with confusing code?

regards,
dan carpenter


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

* [PATCH 1/1] drbd: Deletion of an unnecessary check before the function call "lc_destroy"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-19 12:43                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 12:43 UTC (permalink / raw)
  To: Lars Ellenberg, drbd-user; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 13:33:32 +0100

The lc_destroy() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/drbd/drbd_nl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 1cd47df..0bcb3e0 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1115,8 +1115,7 @@ static int drbd_check_al_size(struct drbd_device *device, struct disk_conf *dc)
 		lc_destroy(n);
 		return -EBUSY;
 	} else {
-		if (t)
-			lc_destroy(t);
+		lc_destroy(t);
 	}
 	drbd_md_mark_dirty(device); /* we changed device->act_log->nr_elemens */
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] drbd: Deletion of an unnecessary check before the function call "lc_destroy"
@ 2014-11-19 12:43                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 12:43 UTC (permalink / raw)
  To: Lars Ellenberg, drbd-user; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 13:33:32 +0100

The lc_destroy() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/drbd/drbd_nl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 1cd47df..0bcb3e0 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1115,8 +1115,7 @@ static int drbd_check_al_size(struct drbd_device *device, struct disk_conf *dc)
 		lc_destroy(n);
 		return -EBUSY;
 	} else {
-		if (t)
-			lc_destroy(t);
+		lc_destroy(t);
 	}
 	drbd_md_mark_dirty(device); /* we changed device->act_log->nr_elemens */
 	return 0;
-- 
2.1.3


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

* Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"
  2014-11-19 12:09                                     ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_ Dan Carpenter
@ 2014-11-19 12:54                                       ` walter harms
  -1 siblings, 0 replies; 3633+ messages in thread
From: walter harms @ 2014-11-19 12:54 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, Greg Kroah-Hartman, Len Brown, Pavel Machek,
	Rafael J. Wysocki, linux-pm, LKML, kernel-janitors, Julia Lawall



Am 19.11.2014 13:09, schrieb Dan Carpenter:
> On Wed, Nov 19, 2014 at 12:26:45PM +0100, SF Markus Elfring wrote:
>> --- a/drivers/base/power/wakeup.c
>> +++ b/drivers/base/power/wakeup.c
>> @@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
>>  		return -EINVAL;
>>  
>>  	ws = device_wakeup_detach(dev);
>> -	if (ws)
>> -		wakeup_source_unregister(ws);
>> +	wakeup_source_unregister(ws);
> 
> In the original code, it's clear that the programmer thought about what
> happens when the device_wakeup_detach() returns NULL but in the new code
> that's not clear.
> 
> I guess the information is still there in the git archive, but why hide
> the good code by covering it with confusing code?
> 

hi,
just to add an other point of view ...

device_wakeup_detach returns dev->power.wakeup what is never NULL in this case.
(not visible here but a few line before exactly this is checked)

so this code can be compacted to:
wakeup_source_unregister(device_wakeup_detach(dev));

--readability

let the maintainer decide this byte-saving vs readability

re,
 wh

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

* Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_
@ 2014-11-19 12:54                                       ` walter harms
  0 siblings, 0 replies; 3633+ messages in thread
From: walter harms @ 2014-11-19 12:54 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, Greg Kroah-Hartman, Len Brown, Pavel Machek,
	Rafael J. Wysocki, linux-pm, LKML, kernel-janitors, Julia Lawall



Am 19.11.2014 13:09, schrieb Dan Carpenter:
> On Wed, Nov 19, 2014 at 12:26:45PM +0100, SF Markus Elfring wrote:
>> --- a/drivers/base/power/wakeup.c
>> +++ b/drivers/base/power/wakeup.c
>> @@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
>>  		return -EINVAL;
>>  
>>  	ws = device_wakeup_detach(dev);
>> -	if (ws)
>> -		wakeup_source_unregister(ws);
>> +	wakeup_source_unregister(ws);
> 
> In the original code, it's clear that the programmer thought about what
> happens when the device_wakeup_detach() returns NULL but in the new code
> that's not clear.
> 
> I guess the information is still there in the git archive, but why hide
> the good code by covering it with confusing code?
> 

hi,
just to add an other point of view ...

device_wakeup_detach returns dev->power.wakeup what is never NULL in this case.
(not visible here but a few line before exactly this is checked)

so this code can be compacted to:
wakeup_source_unregister(device_wakeup_detach(dev));

--readability

let the maintainer decide this byte-saving vs readability

re,
 wh

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

* Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"
  2014-11-19 12:54                                       ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_ walter harms
@ 2014-11-19 13:05                                         ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-19 13:05 UTC (permalink / raw)
  To: walter harms
  Cc: SF Markus Elfring, Greg Kroah-Hartman, Len Brown, Pavel Machek,
	Rafael J. Wysocki, linux-pm, LKML, kernel-janitors, Julia Lawall

On Wed, Nov 19, 2014 at 01:54:49PM +0100, walter harms wrote:
> device_wakeup_detach returns dev->power.wakeup what is never NULL in this case.
> (not visible here but a few line before exactly this is checked)

Huh?  I don't see a NULL check.

I think you may be confusing "dev->power.can_wakeup" with
"dev->power.wakeup"?

regards,
dan carpenter



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

* Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_
@ 2014-11-19 13:05                                         ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-19 13:05 UTC (permalink / raw)
  To: walter harms
  Cc: SF Markus Elfring, Greg Kroah-Hartman, Len Brown, Pavel Machek,
	Rafael J. Wysocki, linux-pm, LKML, kernel-janitors, Julia Lawall

On Wed, Nov 19, 2014 at 01:54:49PM +0100, walter harms wrote:
> device_wakeup_detach returns dev->power.wakeup what is never NULL in this case.
> (not visible here but a few line before exactly this is checked)

Huh?  I don't see a NULL check.

I think you may be confusing "dev->power.can_wakeup" with
"dev->power.wakeup"?

regards,
dan carpenter



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

* [PATCH 1/1] agp/intel-gtt: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-19 13:28                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 13:28 UTC (permalink / raw)
  To: David Airlie; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 14:24:20 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/agp/intel-gtt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 9a024f8..db5877e 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -1434,10 +1434,8 @@ void intel_gmch_remove(void)
 	if (--intel_private.refcount)
 		return;
 
-	if (intel_private.pcidev)
-		pci_dev_put(intel_private.pcidev);
-	if (intel_private.bridge_dev)
-		pci_dev_put(intel_private.bridge_dev);
+	pci_dev_put(intel_private.pcidev);
+	pci_dev_put(intel_private.bridge_dev);
 	intel_private.driver = NULL;
 }
 EXPORT_SYMBOL(intel_gmch_remove);
-- 
2.1.3


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

* [PATCH 1/1] agp/intel-gtt: Deletion of unnecessary checks before the function call "pci_dev_put"
@ 2014-11-19 13:28                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 13:28 UTC (permalink / raw)
  To: David Airlie; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 14:24:20 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/agp/intel-gtt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 9a024f8..db5877e 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -1434,10 +1434,8 @@ void intel_gmch_remove(void)
 	if (--intel_private.refcount)
 		return;
 
-	if (intel_private.pcidev)
-		pci_dev_put(intel_private.pcidev);
-	if (intel_private.bridge_dev)
-		pci_dev_put(intel_private.bridge_dev);
+	pci_dev_put(intel_private.pcidev);
+	pci_dev_put(intel_private.bridge_dev);
 	intel_private.driver = NULL;
 }
 EXPORT_SYMBOL(intel_gmch_remove);
-- 
2.1.3


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

* Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"
  2014-11-19 13:05                                         ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_ Dan Carpenter
@ 2014-11-19 13:39                                           ` walter harms
  -1 siblings, 0 replies; 3633+ messages in thread
From: walter harms @ 2014-11-19 13:39 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, Greg Kroah-Hartman, Len Brown, Pavel Machek,
	Rafael J. Wysocki, linux-pm, LKML, kernel-janitors, Julia Lawall



Am 19.11.2014 14:05, schrieb Dan Carpenter:
> On Wed, Nov 19, 2014 at 01:54:49PM +0100, walter harms wrote:
>> device_wakeup_detach returns dev->power.wakeup what is never NULL in this case.
>> (not visible here but a few line before exactly this is checked)
> 
> Huh?  I don't see a NULL check.
> 
> I think you may be confusing "dev->power.can_wakeup" with
> "dev->power.wakeup"?
> 
>

mea culpa,
you are right  dev->power.can_wakeup != dev->power.wakeup

therefore device_wakeup_detach(dev) CAN return NULL

re,
 wh

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

* Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_
@ 2014-11-19 13:39                                           ` walter harms
  0 siblings, 0 replies; 3633+ messages in thread
From: walter harms @ 2014-11-19 13:39 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, Greg Kroah-Hartman, Len Brown, Pavel Machek,
	Rafael J. Wysocki, linux-pm, LKML, kernel-janitors, Julia Lawall



Am 19.11.2014 14:05, schrieb Dan Carpenter:
> On Wed, Nov 19, 2014 at 01:54:49PM +0100, walter harms wrote:
>> device_wakeup_detach returns dev->power.wakeup what is never NULL in this case.
>> (not visible here but a few line before exactly this is checked)
> 
> Huh?  I don't see a NULL check.
> 
> I think you may be confusing "dev->power.can_wakeup" with
> "dev->power.wakeup"?
> 
>

mea culpa,
you are right  dev->power.can_wakeup != dev->power.wakeup

therefore device_wakeup_detach(dev) CAN return NULL

re,
 wh

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
  2014-11-18 19:47                                   ` SF Markus Elfring
@ 2014-11-19 13:40                                     ` Pablo Neira Ayuso
  -1 siblings, 0 replies; 3633+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-19 13:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jozsef Kadlecsik, Julian Anastasov,
	Patrick McHardy, Simon Horman, Wensong Zhang, netdev, lvs-devel,
	netfilter-devel, coreteam, LKML, kernel-janitors, Coccinelle

On Tue, Nov 18, 2014 at 08:47:31PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 20:37:05 +0100
> 
> The functions free_percpu() and module_put() test whether their argument
> is NULL and then return immediately. Thus the test around the call is
> not needed.

@IPVS folks: Since this involves a nf_tables specific chunk, ack your
chunks and I'll put this into nf-next to speed up things.

Thanks.

> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
>  net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
>  net/netfilter/ipvs/ip_vs_sched.c | 3 +--
>  net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
>  net/netfilter/nf_tables_api.c    | 3 +--
>  5 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index fd3f444..7c5e40a 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
>  
>  static void ip_vs_service_free(struct ip_vs_service *svc)
>  {
> -	if (svc->stats.cpustats)
> -		free_percpu(svc->stats.cpustats);
> +	free_percpu(svc->stats.cpustats);
>  	kfree(svc);
>  }
>  
> diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
> index 1a82b29..0df17ca 100644
> --- a/net/netfilter/ipvs/ip_vs_pe.c
> +++ b/net/netfilter/ipvs/ip_vs_pe.c
> @@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
>  			rcu_read_unlock();
>  			return pe;
>  		}
> -		if (pe->module)
> -			module_put(pe->module);
> +		module_put(pe->module);
>  	}
>  	rcu_read_unlock();
>  
> diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
> index 4dbcda6..199760c 100644
> --- a/net/netfilter/ipvs/ip_vs_sched.c
> +++ b/net/netfilter/ipvs/ip_vs_sched.c
> @@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
>  			mutex_unlock(&ip_vs_sched_mutex);
>  			return sched;
>  		}
> -		if (sched->module)
> -			module_put(sched->module);
> +		module_put(sched->module);
>  	}
>  
>  	mutex_unlock(&ip_vs_sched_mutex);
> diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> index eadffb2..cafe28d 100644
> --- a/net/netfilter/ipvs/ip_vs_sync.c
> +++ b/net/netfilter/ipvs/ip_vs_sync.c
> @@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
>  
>  		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
>  		if (!p->pe_data) {
> -			if (p->pe->module)
> -				module_put(p->pe->module);
> +			module_put(p->pe->module);
>  			return -ENOMEM;
>  		}
>  		p->pe_data_len = pe_data_len;
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index deeb95f..b115f54 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
>  			break;
>  		case NFT_MSG_NEWCHAIN:
>  			if (nft_trans_chain_update(trans)) {
> -				if (nft_trans_chain_stats(trans))
> -					free_percpu(nft_trans_chain_stats(trans));
> +				free_percpu(nft_trans_chain_stats(trans));
>  
>  				nft_trans_destroy(trans);
>  			} else {
> -- 
> 2.1.3
> 

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
@ 2014-11-19 13:40                                     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 3633+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-19 13:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jozsef Kadlecsik, Julian Anastasov,
	Patrick McHardy, Simon Horman, Wensong Zhang, netdev, lvs-devel,
	netfilter-devel, coreteam, LKML, kernel-janitors, Coccinelle

On Tue, Nov 18, 2014 at 08:47:31PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 20:37:05 +0100
> 
> The functions free_percpu() and module_put() test whether their argument
> is NULL and then return immediately. Thus the test around the call is
> not needed.

@IPVS folks: Since this involves a nf_tables specific chunk, ack your
chunks and I'll put this into nf-next to speed up things.

Thanks.

> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
>  net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
>  net/netfilter/ipvs/ip_vs_sched.c | 3 +--
>  net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
>  net/netfilter/nf_tables_api.c    | 3 +--
>  5 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index fd3f444..7c5e40a 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
>  
>  static void ip_vs_service_free(struct ip_vs_service *svc)
>  {
> -	if (svc->stats.cpustats)
> -		free_percpu(svc->stats.cpustats);
> +	free_percpu(svc->stats.cpustats);
>  	kfree(svc);
>  }
>  
> diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
> index 1a82b29..0df17ca 100644
> --- a/net/netfilter/ipvs/ip_vs_pe.c
> +++ b/net/netfilter/ipvs/ip_vs_pe.c
> @@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
>  			rcu_read_unlock();
>  			return pe;
>  		}
> -		if (pe->module)
> -			module_put(pe->module);
> +		module_put(pe->module);
>  	}
>  	rcu_read_unlock();
>  
> diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
> index 4dbcda6..199760c 100644
> --- a/net/netfilter/ipvs/ip_vs_sched.c
> +++ b/net/netfilter/ipvs/ip_vs_sched.c
> @@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
>  			mutex_unlock(&ip_vs_sched_mutex);
>  			return sched;
>  		}
> -		if (sched->module)
> -			module_put(sched->module);
> +		module_put(sched->module);
>  	}
>  
>  	mutex_unlock(&ip_vs_sched_mutex);
> diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> index eadffb2..cafe28d 100644
> --- a/net/netfilter/ipvs/ip_vs_sync.c
> +++ b/net/netfilter/ipvs/ip_vs_sync.c
> @@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
>  
>  		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
>  		if (!p->pe_data) {
> -			if (p->pe->module)
> -				module_put(p->pe->module);
> +			module_put(p->pe->module);
>  			return -ENOMEM;
>  		}
>  		p->pe_data_len = pe_data_len;
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index deeb95f..b115f54 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
>  			break;
>  		case NFT_MSG_NEWCHAIN:
>  			if (nft_trans_chain_update(trans)) {
> -				if (nft_trans_chain_stats(trans))
> -					free_percpu(nft_trans_chain_stats(trans));
> +				free_percpu(nft_trans_chain_stats(trans));
>  
>  				nft_trans_destroy(trans);
>  			} else {
> -- 
> 2.1.3
> 

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

* [PATCH 1/1] char: tpm: Deletion of unnecessary checks before the function call "tpm_dev_vendor_release"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-19 13:50                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 13:50 UTC (permalink / raw)
  To: Ashley Lai, Marcel Selhorst, Peter Huewe, tpmdd-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 14:44:15 +0100

The tpm_dev_vendor_release() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/tpm/tpm_i2c_atmel.c   | 3 +--
 drivers/char/tpm/tpm_i2c_nuvoton.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
index 7727292..19c3a7b 100644
--- a/drivers/char/tpm/tpm_i2c_atmel.c
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -202,8 +202,7 @@ static int i2c_atmel_remove(struct i2c_client *client)
 	struct device *dev = &(client->dev);
 	struct tpm_chip *chip = dev_get_drvdata(dev);
 
-	if (chip)
-		tpm_dev_vendor_release(chip);
+	tpm_dev_vendor_release(chip);
 	tpm_remove_hardware(dev);
 	kfree(chip);
 	return 0;
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 7b158ef..8d09628 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -625,8 +625,7 @@ static int i2c_nuvoton_remove(struct i2c_client *client)
 	struct device *dev = &(client->dev);
 	struct tpm_chip *chip = dev_get_drvdata(dev);
 
-	if (chip)
-		tpm_dev_vendor_release(chip);
+	tpm_dev_vendor_release(chip);
 	tpm_remove_hardware(dev);
 	kfree(chip);
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] char: tpm: Deletion of unnecessary checks before the function call "tpm_dev_vendor_relea
@ 2014-11-19 13:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 13:50 UTC (permalink / raw)
  To: Ashley Lai, Marcel Selhorst, Peter Huewe, tpmdd-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 14:44:15 +0100

The tpm_dev_vendor_release() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/tpm/tpm_i2c_atmel.c   | 3 +--
 drivers/char/tpm/tpm_i2c_nuvoton.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
index 7727292..19c3a7b 100644
--- a/drivers/char/tpm/tpm_i2c_atmel.c
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -202,8 +202,7 @@ static int i2c_atmel_remove(struct i2c_client *client)
 	struct device *dev = &(client->dev);
 	struct tpm_chip *chip = dev_get_drvdata(dev);
 
-	if (chip)
-		tpm_dev_vendor_release(chip);
+	tpm_dev_vendor_release(chip);
 	tpm_remove_hardware(dev);
 	kfree(chip);
 	return 0;
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 7b158ef..8d09628 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -625,8 +625,7 @@ static int i2c_nuvoton_remove(struct i2c_client *client)
 	struct device *dev = &(client->dev);
 	struct tpm_chip *chip = dev_get_drvdata(dev);
 
-	if (chip)
-		tpm_dev_vendor_release(chip);
+	tpm_dev_vendor_release(chip);
 	tpm_remove_hardware(dev);
 	kfree(chip);
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] EDAC: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-19 15:06                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 15:06 UTC (permalink / raw)
  To: Borislav Petkov, Doug Thompson, Jason Uhlenkott,
	Mauro Carvalho Chehab, Tim Small, linux-edac
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 16:00:13 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/edac/i3000_edac.c      | 3 +--
 drivers/edac/i3200_edac.c      | 3 +--
 drivers/edac/i82443bxgx_edac.c | 3 +--
 drivers/edac/x38_edac.c        | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/edac/i3000_edac.c b/drivers/edac/i3000_edac.c
index cd28b96..5cb36a6 100644
--- a/drivers/edac/i3000_edac.c
+++ b/drivers/edac/i3000_edac.c
@@ -542,8 +542,7 @@ fail1:
 	pci_unregister_driver(&i3000_driver);
 
 fail0:
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 
 	return pci_rc;
 }
diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
index aa98b13..4ad062b 100644
--- a/drivers/edac/i3200_edac.c
+++ b/drivers/edac/i3200_edac.c
@@ -523,8 +523,7 @@ fail1:
 	pci_unregister_driver(&i3200_driver);
 
 fail0:
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 
 	return pci_rc;
 }
diff --git a/drivers/edac/i82443bxgx_edac.c b/drivers/edac/i82443bxgx_edac.c
index d730e276..b4705d9 100644
--- a/drivers/edac/i82443bxgx_edac.c
+++ b/drivers/edac/i82443bxgx_edac.c
@@ -458,8 +458,7 @@ static void __exit i82443bxgx_edacmc_exit(void)
 	if (!i82443bxgx_registered)
 		i82443bxgx_edacmc_remove_one(mci_pdev);
 
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 }
 
 module_init(i82443bxgx_edacmc_init);
diff --git a/drivers/edac/x38_edac.c b/drivers/edac/x38_edac.c
index e644b52..7c5cdc6 100644
--- a/drivers/edac/x38_edac.c
+++ b/drivers/edac/x38_edac.c
@@ -500,8 +500,7 @@ fail1:
 	pci_unregister_driver(&x38_driver);
 
 fail0:
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 
 	return pci_rc;
 }
-- 
2.1.3


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

* [PATCH 1/1] EDAC: Deletion of unnecessary checks before the function call "pci_dev_put"
@ 2014-11-19 15:06                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 15:06 UTC (permalink / raw)
  To: Borislav Petkov, Doug Thompson, Jason Uhlenkott,
	Mauro Carvalho Chehab, Tim Small, linux-edac
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 16:00:13 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/edac/i3000_edac.c      | 3 +--
 drivers/edac/i3200_edac.c      | 3 +--
 drivers/edac/i82443bxgx_edac.c | 3 +--
 drivers/edac/x38_edac.c        | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/edac/i3000_edac.c b/drivers/edac/i3000_edac.c
index cd28b96..5cb36a6 100644
--- a/drivers/edac/i3000_edac.c
+++ b/drivers/edac/i3000_edac.c
@@ -542,8 +542,7 @@ fail1:
 	pci_unregister_driver(&i3000_driver);
 
 fail0:
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 
 	return pci_rc;
 }
diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
index aa98b13..4ad062b 100644
--- a/drivers/edac/i3200_edac.c
+++ b/drivers/edac/i3200_edac.c
@@ -523,8 +523,7 @@ fail1:
 	pci_unregister_driver(&i3200_driver);
 
 fail0:
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 
 	return pci_rc;
 }
diff --git a/drivers/edac/i82443bxgx_edac.c b/drivers/edac/i82443bxgx_edac.c
index d730e276..b4705d9 100644
--- a/drivers/edac/i82443bxgx_edac.c
+++ b/drivers/edac/i82443bxgx_edac.c
@@ -458,8 +458,7 @@ static void __exit i82443bxgx_edacmc_exit(void)
 	if (!i82443bxgx_registered)
 		i82443bxgx_edacmc_remove_one(mci_pdev);
 
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 }
 
 module_init(i82443bxgx_edacmc_init);
diff --git a/drivers/edac/x38_edac.c b/drivers/edac/x38_edac.c
index e644b52..7c5cdc6 100644
--- a/drivers/edac/x38_edac.c
+++ b/drivers/edac/x38_edac.c
@@ -500,8 +500,7 @@ fail1:
 	pci_unregister_driver(&x38_driver);
 
 fail0:
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 
 	return pci_rc;
 }
-- 
2.1.3


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

* [PATCH 1/1] DRM-EDID: Deletion of an unnecessary check before the function call "release_firmware"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 15:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 15:40 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 16:33:17 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_edid_load.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
index 0a235fe..732cb6f 100644
--- a/drivers/gpu/drm/drm_edid_load.c
+++ b/drivers/gpu/drm/drm_edid_load.c
@@ -254,8 +254,7 @@ static void *edid_load(struct drm_connector *connector, const char *name,
 	    name, connector_name);
 
 out:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 	return edid;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] DRM-EDID: Deletion of an unnecessary check before the function call "release_firmware"
@ 2014-11-19 15:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 15:40 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 16:33:17 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_edid_load.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
index 0a235fe..732cb6f 100644
--- a/drivers/gpu/drm/drm_edid_load.c
+++ b/drivers/gpu/drm/drm_edid_load.c
@@ -254,8 +254,7 @@ static void *edid_load(struct drm_connector *connector, const char *name,
 	    name, connector_name);
 
 out:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 	return edid;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] DRM-EDID: Deletion of an unnecessary check before the function call "release_firmware"
@ 2014-11-19 15:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 15:40 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 16:33:17 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_edid_load.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
index 0a235fe..732cb6f 100644
--- a/drivers/gpu/drm/drm_edid_load.c
+++ b/drivers/gpu/drm/drm_edid_load.c
@@ -254,8 +254,7 @@ static void *edid_load(struct drm_connector *connector, const char *name,
 	    name, connector_name);
 
 out:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 	return edid;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hotplug_event"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 16:14                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 16:14 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 17:05:20 +0100

The drm_fbdev_cma_hotplug_event() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 000428e..335b1dc 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -58,8 +58,7 @@ static struct drm_framebuffer *tilcdc_fb_create(struct drm_device *dev,
 static void tilcdc_fb_output_poll_changed(struct drm_device *dev)
 {
 	struct tilcdc_drm_private *priv = dev->dev_private;
-	if (priv->fbdev)
-		drm_fbdev_cma_hotplug_event(priv->fbdev);
+	drm_fbdev_cma_hotplug_event(priv->fbdev);
 }
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
-- 
2.1.3


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

* [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hot
@ 2014-11-19 16:14                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 16:14 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 17:05:20 +0100

The drm_fbdev_cma_hotplug_event() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 000428e..335b1dc 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -58,8 +58,7 @@ static struct drm_framebuffer *tilcdc_fb_create(struct drm_device *dev,
 static void tilcdc_fb_output_poll_changed(struct drm_device *dev)
 {
 	struct tilcdc_drm_private *priv = dev->dev_private;
-	if (priv->fbdev)
-		drm_fbdev_cma_hotplug_event(priv->fbdev);
+	drm_fbdev_cma_hotplug_event(priv->fbdev);
 }
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
-- 
2.1.3


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

* [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hotplug_event"
@ 2014-11-19 16:14                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 16:14 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 17:05:20 +0100

The drm_fbdev_cma_hotplug_event() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 000428e..335b1dc 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -58,8 +58,7 @@ static struct drm_framebuffer *tilcdc_fb_create(struct drm_device *dev,
 static void tilcdc_fb_output_poll_changed(struct drm_device *dev)
 {
 	struct tilcdc_drm_private *priv = dev->dev_private;
-	if (priv->fbdev)
-		drm_fbdev_cma_hotplug_event(priv->fbdev);
+	drm_fbdev_cma_hotplug_event(priv->fbdev);
 }
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
-- 
2.1.3

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

* [PATCH 1/1] DRM-UDL: Deletion of an unnecessary check before the function call "vunmap"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 16:37                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 16:37 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 17:33:32 +0100

The vunmap() function performes also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/udl/udl_gem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 8044f5f..2979625 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -164,8 +164,7 @@ void udl_gem_vunmap(struct udl_gem_object *obj)
 		return;
 	}
 
-	if (obj->vmapping)
-		vunmap(obj->vmapping);
+	vunmap(obj->vmapping);
 
 	udl_gem_put_pages(obj);
 }
-- 
2.1.3


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

* [PATCH 1/1] DRM-UDL: Deletion of an unnecessary check before the function call "vunmap"
@ 2014-11-19 16:37                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 16:37 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 17:33:32 +0100

The vunmap() function performes also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/udl/udl_gem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 8044f5f..2979625 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -164,8 +164,7 @@ void udl_gem_vunmap(struct udl_gem_object *obj)
 		return;
 	}
 
-	if (obj->vmapping)
-		vunmap(obj->vmapping);
+	vunmap(obj->vmapping);
 
 	udl_gem_put_pages(obj);
 }
-- 
2.1.3


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

* [PATCH 1/1] DRM-UDL: Deletion of an unnecessary check before the function call "vunmap"
@ 2014-11-19 16:37                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 16:37 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 17:33:32 +0100

The vunmap() function performes also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/udl/udl_gem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 8044f5f..2979625 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -164,8 +164,7 @@ void udl_gem_vunmap(struct udl_gem_object *obj)
 		return;
 	}
 
-	if (obj->vmapping)
-		vunmap(obj->vmapping);
+	vunmap(obj->vmapping);
 
 	udl_gem_put_pages(obj);
 }
-- 
2.1.3

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

* Re: [PATCH 1/1] EDAC: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-11-19 15:06                                   ` SF Markus Elfring
@ 2014-11-19 16:40                                     ` Borislav Petkov
  -1 siblings, 0 replies; 3633+ messages in thread
From: Borislav Petkov @ 2014-11-19 16:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Doug Thompson, Jason Uhlenkott, Mauro Carvalho Chehab, Tim Small,
	linux-edac, LKML, kernel-janitors, Julia Lawall

On Wed, Nov 19, 2014 at 04:06:53PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 16:00:13 +0100
> 
> The pci_dev_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

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

* Re: [PATCH 1/1] EDAC: Deletion of unnecessary checks before the function call "pci_dev_put"
@ 2014-11-19 16:40                                     ` Borislav Petkov
  0 siblings, 0 replies; 3633+ messages in thread
From: Borislav Petkov @ 2014-11-19 16:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Doug Thompson, Jason Uhlenkott, Mauro Carvalho Chehab, Tim Small,
	linux-edac, LKML, kernel-janitors, Julia Lawall

On Wed, Nov 19, 2014 at 04:06:53PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 16:00:13 +0100
> 
> The pci_dev_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

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

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-18 20:26                                   ` SF Markus Elfring
  (?)
@ 2014-11-19 16:47                                     ` John Fastabend
  -1 siblings, 0 replies; 3633+ messages in thread
From: John Fastabend @ 2014-11-19 16:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jamal Hadi Salim, netdev, LKML, kernel-janitors,
	Coccinelle

On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:21:16 +0100
>
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   net/sched/cls_bpf.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
> index 0e30d58..f323944 100644
> --- a/net/sched/cls_bpf.c
> +++ b/net/sched/cls_bpf.c
> @@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
>
>   	if (fp_old)
>   		bpf_prog_destroy(fp_old);
> -	if (bpf_old)
> -		kfree(bpf_old);
> +	kfree(bpf_old);
>
>   	return 0;
>
>

Maybe I need some coffee but I can't figure out what this
patch is against...

# grep bpf_old ./net/sched/cls_bpf.c
#

Marcus, what tree are you looking at?

-- 
John Fastabend         Intel Corporation

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

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-19 16:47                                     ` John Fastabend
  0 siblings, 0 replies; 3633+ messages in thread
From: John Fastabend @ 2014-11-19 16:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jamal Hadi Salim, netdev, LKML, kernel-janitors,
	Coccinelle

On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:21:16 +0100
>
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   net/sched/cls_bpf.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
> index 0e30d58..f323944 100644
> --- a/net/sched/cls_bpf.c
> +++ b/net/sched/cls_bpf.c
> @@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
>
>   	if (fp_old)
>   		bpf_prog_destroy(fp_old);
> -	if (bpf_old)
> -		kfree(bpf_old);
> +	kfree(bpf_old);
>
>   	return 0;
>
>

Maybe I need some coffee but I can't figure out what this
patch is against...

# grep bpf_old ./net/sched/cls_bpf.c
#

Marcus, what tree are you looking at?

-- 
John Fastabend         Intel Corporation

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

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-19 16:47                                     ` John Fastabend
  0 siblings, 0 replies; 3633+ messages in thread
From: John Fastabend @ 2014-11-19 16:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jamal Hadi Salim, netdev, LKML, kernel-janitors,
	Coccinelle

On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:21:16 +0100
>
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   net/sched/cls_bpf.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
> index 0e30d58..f323944 100644
> --- a/net/sched/cls_bpf.c
> +++ b/net/sched/cls_bpf.c
> @@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
>
>   	if (fp_old)
>   		bpf_prog_destroy(fp_old);
> -	if (bpf_old)
> -		kfree(bpf_old);
> +	kfree(bpf_old);
>
>   	return 0;
>
>

Maybe I need some coffee but I can't figure out what this
patch is against...

# grep bpf_old ./net/sched/cls_bpf.c
#

Marcus, what tree are you looking at?

-- 
John Fastabend         Intel Corporation

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

* [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 16:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 16:55 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 17:50:19 +0100

The vfree() function performes also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 14b2f50..f9a67b8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -889,8 +889,7 @@ static int vmw_driver_unload(struct drm_device *dev)
 
 	if (dev_priv->ctx.res_ht_initialized)
 		drm_ht_remove(&dev_priv->ctx.res_ht);
-	if (dev_priv->ctx.cmd_bounce)
-		vfree(dev_priv->ctx.cmd_bounce);
+	vfree(dev_priv->ctx.cmd_bounce);
 	if (dev_priv->enable_fb) {
 		vmw_fb_close(dev_priv);
 		vmw_kms_restore_vga(dev_priv);
-- 
2.1.3


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

* [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-19 16:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 16:55 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 17:50:19 +0100

The vfree() function performes also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 14b2f50..f9a67b8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -889,8 +889,7 @@ static int vmw_driver_unload(struct drm_device *dev)
 
 	if (dev_priv->ctx.res_ht_initialized)
 		drm_ht_remove(&dev_priv->ctx.res_ht);
-	if (dev_priv->ctx.cmd_bounce)
-		vfree(dev_priv->ctx.cmd_bounce);
+	vfree(dev_priv->ctx.cmd_bounce);
 	if (dev_priv->enable_fb) {
 		vmw_fb_close(dev_priv);
 		vmw_kms_restore_vga(dev_priv);
-- 
2.1.3


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

* [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-19 16:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 16:55 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 17:50:19 +0100

The vfree() function performes also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 14b2f50..f9a67b8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -889,8 +889,7 @@ static int vmw_driver_unload(struct drm_device *dev)
 
 	if (dev_priv->ctx.res_ht_initialized)
 		drm_ht_remove(&dev_priv->ctx.res_ht);
-	if (dev_priv->ctx.cmd_bounce)
-		vfree(dev_priv->ctx.cmd_bounce);
+	vfree(dev_priv->ctx.cmd_bounce);
 	if (dev_priv->enable_fb) {
 		vmw_fb_close(dev_priv);
 		vmw_kms_restore_vga(dev_priv);
-- 
2.1.3

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

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-19 16:47                                     ` John Fastabend
  (?)
@ 2014-11-19 17:00                                       ` Daniel Borkmann
  -1 siblings, 0 replies; 3633+ messages in thread
From: Daniel Borkmann @ 2014-11-19 17:00 UTC (permalink / raw)
  To: John Fastabend
  Cc: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev,
	LKML, kernel-janitors, Coccinelle

On 11/19/2014 05:47 PM, John Fastabend wrote:
> On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
...
>>       if (fp_old)
>>           bpf_prog_destroy(fp_old);
>> -    if (bpf_old)
>> -        kfree(bpf_old);
>> +    kfree(bpf_old);
>>
>>       return 0;
>>
>
> Maybe I need some coffee but I can't figure out what this
> patch is against...
>
> # grep bpf_old ./net/sched/cls_bpf.c
> #

Coffee is always good. :)

Yeah, you actually removed this in commit 1f947bf151e90ec ("net:
sched: rcu'ify cls_bpf"), so looks like Markus's tree is not
up to date ...

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

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-19 17:00                                       ` Daniel Borkmann
  0 siblings, 0 replies; 3633+ messages in thread
From: Daniel Borkmann @ 2014-11-19 17:00 UTC (permalink / raw)
  To: John Fastabend
  Cc: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev,
	LKML, kernel-janitors, Coccinelle

On 11/19/2014 05:47 PM, John Fastabend wrote:
> On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
...
>>       if (fp_old)
>>           bpf_prog_destroy(fp_old);
>> -    if (bpf_old)
>> -        kfree(bpf_old);
>> +    kfree(bpf_old);
>>
>>       return 0;
>>
>
> Maybe I need some coffee but I can't figure out what this
> patch is against...
>
> # grep bpf_old ./net/sched/cls_bpf.c
> #

Coffee is always good. :)

Yeah, you actually removed this in commit 1f947bf151e90ec ("net:
sched: rcu'ify cls_bpf"), so looks like Markus's tree is not
up to date ...

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

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-19 17:00                                       ` Daniel Borkmann
  0 siblings, 0 replies; 3633+ messages in thread
From: Daniel Borkmann @ 2014-11-19 17:00 UTC (permalink / raw)
  To: John Fastabend
  Cc: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev,
	LKML, kernel-janitors, Coccinelle

On 11/19/2014 05:47 PM, John Fastabend wrote:
> On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
...
>>       if (fp_old)
>>           bpf_prog_destroy(fp_old);
>> -    if (bpf_old)
>> -        kfree(bpf_old);
>> +    kfree(bpf_old);
>>
>>       return 0;
>>
>
> Maybe I need some coffee but I can't figure out what this
> patch is against...
>
> # grep bpf_old ./net/sched/cls_bpf.c
> #

Coffee is always good. :)

Yeah, you actually removed this in commit 1f947bf151e90ec ("net:
sched: rcu'ify cls_bpf"), so looks like Markus's tree is not
up to date ...

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

* [PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 17:38                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 17:38 UTC (permalink / raw)
  To: Bruno Prémont, Jiri Kosina, linux-input
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 18:30:22 +0100

The functions backlight_device_unregister(), lcd_device_unregister() and
rc_unregister_device() test whether their argument is NULL and then
return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-picolcd_backlight.c | 3 +--
 drivers/hid/hid-picolcd_cir.c       | 3 +--
 drivers/hid/hid-picolcd_lcd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-picolcd_backlight.c b/drivers/hid/hid-picolcd_backlight.c
index a32c5f8..808807a 100644
--- a/drivers/hid/hid-picolcd_backlight.c
+++ b/drivers/hid/hid-picolcd_backlight.c
@@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
 	struct backlight_device *bdev = data->backlight;
 
 	data->backlight = NULL;
-	if (bdev)
-		backlight_device_unregister(bdev);
+	backlight_device_unregister(bdev);
 }
 
 int picolcd_resume_backlight(struct picolcd_data *data)
diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 045f8eb..9628651 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
 	struct rc_dev *rdev = data->rc_dev;
 
 	data->rc_dev = NULL;
-	if (rdev)
-		rc_unregister_device(rdev);
+	rc_unregister_device(rdev);
 }
 
diff --git a/drivers/hid/hid-picolcd_lcd.c b/drivers/hid/hid-picolcd_lcd.c
index 89821c2..22dcbe1 100644
--- a/drivers/hid/hid-picolcd_lcd.c
+++ b/drivers/hid/hid-picolcd_lcd.c
@@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
 	struct lcd_device *ldev = data->lcd;
 
 	data->lcd = NULL;
-	if (ldev)
-		lcd_device_unregister(ldev);
+	lcd_device_unregister(ldev);
 }
 
 int picolcd_resume_lcd(struct picolcd_data *data)
-- 
2.1.3


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

* [PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls
@ 2014-11-19 17:38                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 17:38 UTC (permalink / raw)
  To: Bruno Prémont, Jiri Kosina, linux-input
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 18:30:22 +0100

The functions backlight_device_unregister(), lcd_device_unregister() and
rc_unregister_device() test whether their argument is NULL and then
return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-picolcd_backlight.c | 3 +--
 drivers/hid/hid-picolcd_cir.c       | 3 +--
 drivers/hid/hid-picolcd_lcd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-picolcd_backlight.c b/drivers/hid/hid-picolcd_backlight.c
index a32c5f8..808807a 100644
--- a/drivers/hid/hid-picolcd_backlight.c
+++ b/drivers/hid/hid-picolcd_backlight.c
@@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
 	struct backlight_device *bdev = data->backlight;
 
 	data->backlight = NULL;
-	if (bdev)
-		backlight_device_unregister(bdev);
+	backlight_device_unregister(bdev);
 }
 
 int picolcd_resume_backlight(struct picolcd_data *data)
diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 045f8eb..9628651 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
 	struct rc_dev *rdev = data->rc_dev;
 
 	data->rc_dev = NULL;
-	if (rdev)
-		rc_unregister_device(rdev);
+	rc_unregister_device(rdev);
 }
 
diff --git a/drivers/hid/hid-picolcd_lcd.c b/drivers/hid/hid-picolcd_lcd.c
index 89821c2..22dcbe1 100644
--- a/drivers/hid/hid-picolcd_lcd.c
+++ b/drivers/hid/hid-picolcd_lcd.c
@@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
 	struct lcd_device *ldev = data->lcd;
 
 	data->lcd = NULL;
-	if (ldev)
-		lcd_device_unregister(ldev);
+	lcd_device_unregister(ldev);
 }
 
 int picolcd_resume_lcd(struct picolcd_data *data)
-- 
2.1.3


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

* [PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls
@ 2014-11-19 17:38                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 17:38 UTC (permalink / raw)
  To: Bruno Prémont, Jiri Kosina, linux-input
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 18:30:22 +0100

The functions backlight_device_unregister(), lcd_device_unregister() and
rc_unregister_device() test whether their argument is NULL and then
return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-picolcd_backlight.c | 3 +--
 drivers/hid/hid-picolcd_cir.c       | 3 +--
 drivers/hid/hid-picolcd_lcd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-picolcd_backlight.c b/drivers/hid/hid-picolcd_backlight.c
index a32c5f8..808807a 100644
--- a/drivers/hid/hid-picolcd_backlight.c
+++ b/drivers/hid/hid-picolcd_backlight.c
@@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
 	struct backlight_device *bdev = data->backlight;
 
 	data->backlight = NULL;
-	if (bdev)
-		backlight_device_unregister(bdev);
+	backlight_device_unregister(bdev);
 }
 
 int picolcd_resume_backlight(struct picolcd_data *data)
diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 045f8eb..9628651 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
 	struct rc_dev *rdev = data->rc_dev;
 
 	data->rc_dev = NULL;
-	if (rdev)
-		rc_unregister_device(rdev);
+	rc_unregister_device(rdev);
 }
 
diff --git a/drivers/hid/hid-picolcd_lcd.c b/drivers/hid/hid-picolcd_lcd.c
index 89821c2..22dcbe1 100644
--- a/drivers/hid/hid-picolcd_lcd.c
+++ b/drivers/hid/hid-picolcd_lcd.c
@@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
 	struct lcd_device *ldev = data->lcd;
 
 	data->lcd = NULL;
-	if (ldev)
-		lcd_device_unregister(ldev);
+	lcd_device_unregister(ldev);
 }
 
 int picolcd_resume_lcd(struct picolcd_data *data)
-- 
2.1.3

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-19 10:10                                         ` Dan Carpenter
@ 2014-11-19 18:19                                           ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-19 18:19 UTC (permalink / raw)
  To: dan.carpenter
  Cc: elfring, herbert, steffen.klassert, netdev, linux-kernel,
	kernel-janitors, julia.lawall

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 19 Nov 2014 13:10:03 +0300

> I have come to view you as a very clever troll.

+1

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
@ 2014-11-19 18:19                                           ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-19 18:19 UTC (permalink / raw)
  To: dan.carpenter
  Cc: elfring, herbert, steffen.klassert, netdev, linux-kernel,
	kernel-janitors, julia.lawall

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 19 Nov 2014 13:10:03 +0300

> I have come to view you as a very clever troll.

+1

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

* [PATCH 1/1] InfiniBand: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 18:25                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 18:25 UTC (permalink / raw)
  To: Hal Rosenstock, Roland Dreier, Sean Hefty,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Wed, 19 Nov 2014 19:19:21 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/infiniband/hw/mlx4/main.c         | 3 +--
 drivers/infiniband/hw/mthca/mthca_reset.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 8b72cf3..50dee1a 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2512,8 +2512,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		if (!dm[i]) {
 			pr_err("failed to allocate memory for tunneling qp update work struct\n");
 			for (i = 0; i < dev->caps.num_ports; i++) {
-				if (dm[i])
-					kfree(dm[i]);
+				kfree(dm[i]);
 			}
 			goto out;
 		}
diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c
index 74c6a94..c521654 100644
--- a/drivers/infiniband/hw/mthca/mthca_reset.c
+++ b/drivers/infiniband/hw/mthca/mthca_reset.c
@@ -279,8 +279,7 @@ good:
 	}
 
 out:
-	if (bridge)
-		pci_dev_put(bridge);
+	pci_dev_put(bridge);
 	kfree(bridge_header);
 	kfree(hca_header);
 
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/1] InfiniBand: Deletion of unnecessary checks before two function calls
@ 2014-11-19 18:25                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 18:25 UTC (permalink / raw)
  To: Hal Rosenstock, Roland Dreier, Sean Hefty, linux-rdma
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 19:19:21 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c         | 3 +--
 drivers/infiniband/hw/mthca/mthca_reset.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 8b72cf3..50dee1a 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2512,8 +2512,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		if (!dm[i]) {
 			pr_err("failed to allocate memory for tunneling qp update work struct\n");
 			for (i = 0; i < dev->caps.num_ports; i++) {
-				if (dm[i])
-					kfree(dm[i]);
+				kfree(dm[i]);
 			}
 			goto out;
 		}
diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c
index 74c6a94..c521654 100644
--- a/drivers/infiniband/hw/mthca/mthca_reset.c
+++ b/drivers/infiniband/hw/mthca/mthca_reset.c
@@ -279,8 +279,7 @@ good:
 	}
 
 out:
-	if (bridge)
-		pci_dev_put(bridge);
+	pci_dev_put(bridge);
 	kfree(bridge_header);
 	kfree(hca_header);
 
-- 
2.1.3


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

* [PATCH 1/1] InfiniBand: Deletion of unnecessary checks before two function calls
@ 2014-11-19 18:25                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 18:25 UTC (permalink / raw)
  To: Hal Rosenstock, Roland Dreier, Sean Hefty,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 19:19:21 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c         | 3 +--
 drivers/infiniband/hw/mthca/mthca_reset.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 8b72cf3..50dee1a 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2512,8 +2512,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		if (!dm[i]) {
 			pr_err("failed to allocate memory for tunneling qp update work struct\n");
 			for (i = 0; i < dev->caps.num_ports; i++) {
-				if (dm[i])
-					kfree(dm[i]);
+				kfree(dm[i]);
 			}
 			goto out;
 		}
diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c
index 74c6a94..c521654 100644
--- a/drivers/infiniband/hw/mthca/mthca_reset.c
+++ b/drivers/infiniband/hw/mthca/mthca_reset.c
@@ -279,8 +279,7 @@ good:
 	}
 
 out:
-	if (bridge)
-		pci_dev_put(bridge);
+	pci_dev_put(bridge);
 	kfree(bridge_header);
 	kfree(hca_header);
 
-- 
2.1.3


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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-19 16:47                                     ` John Fastabend
  (?)
@ 2014-11-19 18:49                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 18:49 UTC (permalink / raw)
  To: John Fastabend
  Cc: David S. Miller, Jamal Hadi Salim, netdev, LKML, kernel-janitors

> Marcus, what tree are you looking at?

I dared to base this update suggestion on the source files
for Linux 3.17.3. Are newer software developments relevant here?

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Regards,
Markus


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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-19 18:49                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 18:49 UTC (permalink / raw)
  To: John Fastabend
  Cc: David S. Miller, Jamal Hadi Salim, netdev, LKML, kernel-janitors

> Marcus, what tree are you looking at?

I dared to base this update suggestion on the source files
for Linux 3.17.3. Are newer software developments relevant here?

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Regards,
Markus

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-19 18:49                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 18:49 UTC (permalink / raw)
  To: John Fastabend
  Cc: David S. Miller, Jamal Hadi Salim, netdev, LKML, kernel-janitors

> Marcus, what tree are you looking at?

I dared to base this update suggestion on the source files
for Linux 3.17.3. Are newer software developments relevant here?

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Regards,
Markus


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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-19 18:49                                       ` SF Markus Elfring
  (?)
@ 2014-11-19 19:09                                         ` Daniel Borkmann
  -1 siblings, 0 replies; 3633+ messages in thread
From: Daniel Borkmann @ 2014-11-19 19:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: John Fastabend, David S. Miller, Jamal Hadi Salim, netdev, LKML,
	kernel-janitors

On 11/19/2014 07:49 PM, SF Markus Elfring wrote:
>> Marcus, what tree are you looking at?
>
> I dared to base this update suggestion on the source files
> for Linux 3.17.3. Are newer software developments relevant here?
>
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Pointing to linux-next and saying you based your changes on 3.17.3
is confusing, please look correctly when you provide a link ...

Again, John's commit 1f947bf151e90ec0b removed the relevant part in
cls_bpf_modify_existing() that you're trying to modify:

$ git grep -n bpf_old net/sched/cls_bpf.c
$

Therefore, this patch is not needed.

Thanks !

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-19 19:09                                         ` Daniel Borkmann
  0 siblings, 0 replies; 3633+ messages in thread
From: Daniel Borkmann @ 2014-11-19 19:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: John Fastabend, David S. Miller, Jamal Hadi Salim, netdev, LKML,
	kernel-janitors

On 11/19/2014 07:49 PM, SF Markus Elfring wrote:
>> Marcus, what tree are you looking at?
>
> I dared to base this update suggestion on the source files
> for Linux 3.17.3. Are newer software developments relevant here?
>
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Pointing to linux-next and saying you based your changes on 3.17.3
is confusing, please look correctly when you provide a link ...

Again, John's commit 1f947bf151e90ec0b removed the relevant part in
cls_bpf_modify_existing() that you're trying to modify:

$ git grep -n bpf_old net/sched/cls_bpf.c
$

Therefore, this patch is not needed.

Thanks !

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-19 19:09                                         ` Daniel Borkmann
  0 siblings, 0 replies; 3633+ messages in thread
From: Daniel Borkmann @ 2014-11-19 19:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: John Fastabend, David S. Miller, Jamal Hadi Salim, netdev, LKML,
	kernel-janitors

On 11/19/2014 07:49 PM, SF Markus Elfring wrote:
>> Marcus, what tree are you looking at?
>
> I dared to base this update suggestion on the source files
> for Linux 3.17.3. Are newer software developments relevant here?
>
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Pointing to linux-next and saying you based your changes on 3.17.3
is confusing, please look correctly when you provide a link ...

Again, John's commit 1f947bf151e90ec0b removed the relevant part in
cls_bpf_modify_existing() that you're trying to modify:

$ git grep -n bpf_old net/sched/cls_bpf.c
$

Therefore, this patch is not needed.

Thanks !

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

* [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 19:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 19:55 UTC (permalink / raw)
  To: Karsten Keil, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 20:48:26 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/isdn/mISDN/l1oip_codec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/isdn/mISDN/l1oip_codec.c b/drivers/isdn/mISDN/l1oip_codec.c
index a601c84..9b033be 100644
--- a/drivers/isdn/mISDN/l1oip_codec.c
+++ b/drivers/isdn/mISDN/l1oip_codec.c
@@ -312,10 +312,8 @@ l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result)
 void
 l1oip_4bit_free(void)
 {
-	if (table_dec)
-		vfree(table_dec);
-	if (table_com)
-		vfree(table_com);
+	vfree(table_dec);
+	vfree(table_com);
 	table_com = NULL;
 	table_dec = NULL;
 }
-- 
2.1.3


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

* [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree"
@ 2014-11-19 19:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 19:55 UTC (permalink / raw)
  To: Karsten Keil, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 20:48:26 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/isdn/mISDN/l1oip_codec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/isdn/mISDN/l1oip_codec.c b/drivers/isdn/mISDN/l1oip_codec.c
index a601c84..9b033be 100644
--- a/drivers/isdn/mISDN/l1oip_codec.c
+++ b/drivers/isdn/mISDN/l1oip_codec.c
@@ -312,10 +312,8 @@ l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result)
 void
 l1oip_4bit_free(void)
 {
-	if (table_dec)
-		vfree(table_dec);
-	if (table_com)
-		vfree(table_com);
+	vfree(table_dec);
+	vfree(table_com);
 	table_com = NULL;
 	table_dec = NULL;
 }
-- 
2.1.3

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

* [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree"
@ 2014-11-19 19:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 19:55 UTC (permalink / raw)
  To: Karsten Keil, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 20:48:26 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/isdn/mISDN/l1oip_codec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/isdn/mISDN/l1oip_codec.c b/drivers/isdn/mISDN/l1oip_codec.c
index a601c84..9b033be 100644
--- a/drivers/isdn/mISDN/l1oip_codec.c
+++ b/drivers/isdn/mISDN/l1oip_codec.c
@@ -312,10 +312,8 @@ l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result)
 void
 l1oip_4bit_free(void)
 {
-	if (table_dec)
-		vfree(table_dec);
-	if (table_com)
-		vfree(table_com);
+	vfree(table_dec);
+	vfree(table_com);
 	table_com = NULL;
 	table_dec = NULL;
 }
-- 
2.1.3


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

* Re: [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"
  2014-11-18 19:16                                   ` SF Markus Elfring
@ 2014-11-19 20:20                                     ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-19 20:20 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, cocci

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:16:05 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 20:10:34 +0100
> 
> The proc_remove() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

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

* Re: [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"
@ 2014-11-19 20:20                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-19 20:20 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, cocci

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:16:05 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 20:10:34 +0100
> 
> The proc_remove() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

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

* Re: [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get"
  2014-11-18 20:08                                   ` SF Markus Elfring
@ 2014-11-19 20:28                                     ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-19 20:28 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, cocci

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:08:39 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:03:13 +0100
> 
> The __module_get() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

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

* Re: [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get"
@ 2014-11-19 20:28                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-19 20:28 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, cocci

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:08:39 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:03:13 +0100
> 
> The __module_get() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

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

* [PATCH 1/1] bcache: Deletion of an unnecessary check before the function call "kobject_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 20:34                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 20:34 UTC (permalink / raw)
  To: Kent Overstreet, Neil Brown, linux-bcache
  Cc: linux-raid, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 21:25:39 +0100

The kobject_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bcache/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index d4713d0..1443c55 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2076,8 +2076,7 @@ static void bcache_exit(void)
 {
 	bch_debug_exit();
 	bch_request_exit();
-	if (bcache_kobj)
-		kobject_put(bcache_kobj);
+	kobject_put(bcache_kobj);
 	if (bcache_wq)
 		destroy_workqueue(bcache_wq);
 	if (bcache_major)
-- 
2.1.3

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

* [PATCH 1/1] bcache: Deletion of an unnecessary check before the function call "kobject_put"
@ 2014-11-19 20:34                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 20:34 UTC (permalink / raw)
  To: Kent Overstreet, Neil Brown, linux-bcache
  Cc: linux-raid, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 21:25:39 +0100

The kobject_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bcache/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index d4713d0..1443c55 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2076,8 +2076,7 @@ static void bcache_exit(void)
 {
 	bch_debug_exit();
 	bch_request_exit();
-	if (bcache_kobj)
-		kobject_put(bcache_kobj);
+	kobject_put(bcache_kobj);
 	if (bcache_wq)
 		destroy_workqueue(bcache_wq);
 	if (bcache_major)
-- 
2.1.3


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

* [PATCH 1/1] bcache: Deletion of an unnecessary check before the function call "kobject_put"
@ 2014-11-19 20:34                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 20:34 UTC (permalink / raw)
  To: Kent Overstreet, Neil Brown, linux-bcache
  Cc: linux-raid, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 21:25:39 +0100

The kobject_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bcache/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index d4713d0..1443c55 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2076,8 +2076,7 @@ static void bcache_exit(void)
 {
 	bch_debug_exit();
 	bch_request_exit();
-	if (bcache_kobj)
-		kobject_put(bcache_kobj);
+	kobject_put(bcache_kobj);
 	if (bcache_wq)
 		destroy_workqueue(bcache_wq);
 	if (bcache_major)
-- 
2.1.3


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

* [PATCH 1/1] dm: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-19 20:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 20:55 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Neil Brown, dm-devel, linux-raid
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 21:48:10 +0100

The functions dm_table_destroy() and vfree() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-ioctl.c           |  3 +--
 drivers/md/dm-snap-persistent.c | 12 ++++--------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 5152142..0b925a4 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1050,8 +1050,7 @@ static int do_resume(struct dm_ioctl *param)
 	 * Since dm_swap_table synchronizes RCU, nobody should be in
 	 * read-side critical section already.
 	 */
-	if (old_map)
-		dm_table_destroy(old_map);
+	dm_table_destroy(old_map);
 
 	if (!r)
 		__dev_status(md, param);
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index d6e8817..4b29bac 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -200,16 +200,13 @@ err_area:
 
 static void free_area(struct pstore *ps)
 {
-	if (ps->area)
-		vfree(ps->area);
+	vfree(ps->area);
 	ps->area = NULL;
 
-	if (ps->zero_area)
-		vfree(ps->zero_area);
+	vfree(ps->zero_area);
 	ps->zero_area = NULL;
 
-	if (ps->header_area)
-		vfree(ps->header_area);
+	vfree(ps->header_area);
 	ps->header_area = NULL;
 }
 
@@ -605,8 +602,7 @@ static void persistent_dtr(struct dm_exception_store *store)
 	free_area(ps);
 
 	/* Allocated in persistent_read_metadata */
-	if (ps->callbacks)
-		vfree(ps->callbacks);
+	vfree(ps->callbacks);
 
 	kfree(ps);
 }
-- 
2.1.3

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

* [PATCH 1/1] dm: Deletion of unnecessary checks before two function calls
@ 2014-11-19 20:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 20:55 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Neil Brown, dm-devel, linux-raid
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 21:48:10 +0100

The functions dm_table_destroy() and vfree() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-ioctl.c           |  3 +--
 drivers/md/dm-snap-persistent.c | 12 ++++--------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 5152142..0b925a4 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1050,8 +1050,7 @@ static int do_resume(struct dm_ioctl *param)
 	 * Since dm_swap_table synchronizes RCU, nobody should be in
 	 * read-side critical section already.
 	 */
-	if (old_map)
-		dm_table_destroy(old_map);
+	dm_table_destroy(old_map);
 
 	if (!r)
 		__dev_status(md, param);
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index d6e8817..4b29bac 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -200,16 +200,13 @@ err_area:
 
 static void free_area(struct pstore *ps)
 {
-	if (ps->area)
-		vfree(ps->area);
+	vfree(ps->area);
 	ps->area = NULL;
 
-	if (ps->zero_area)
-		vfree(ps->zero_area);
+	vfree(ps->zero_area);
 	ps->zero_area = NULL;
 
-	if (ps->header_area)
-		vfree(ps->header_area);
+	vfree(ps->header_area);
 	ps->header_area = NULL;
 }
 
@@ -605,8 +602,7 @@ static void persistent_dtr(struct dm_exception_store *store)
 	free_area(ps);
 
 	/* Allocated in persistent_read_metadata */
-	if (ps->callbacks)
-		vfree(ps->callbacks);
+	vfree(ps->callbacks);
 
 	kfree(ps);
 }
-- 
2.1.3


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

* [PATCH 1/1] dm: Deletion of unnecessary checks before two function calls
@ 2014-11-19 20:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-19 20:55 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Neil Brown, dm-devel, linux-raid
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 21:48:10 +0100

The functions dm_table_destroy() and vfree() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-ioctl.c           |  3 +--
 drivers/md/dm-snap-persistent.c | 12 ++++--------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 5152142..0b925a4 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1050,8 +1050,7 @@ static int do_resume(struct dm_ioctl *param)
 	 * Since dm_swap_table synchronizes RCU, nobody should be in
 	 * read-side critical section already.
 	 */
-	if (old_map)
-		dm_table_destroy(old_map);
+	dm_table_destroy(old_map);
 
 	if (!r)
 		__dev_status(md, param);
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index d6e8817..4b29bac 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -200,16 +200,13 @@ err_area:
 
 static void free_area(struct pstore *ps)
 {
-	if (ps->area)
-		vfree(ps->area);
+	vfree(ps->area);
 	ps->area = NULL;
 
-	if (ps->zero_area)
-		vfree(ps->zero_area);
+	vfree(ps->zero_area);
 	ps->zero_area = NULL;
 
-	if (ps->header_area)
-		vfree(ps->header_area);
+	vfree(ps->header_area);
 	ps->header_area = NULL;
 }
 
@@ -605,8 +602,7 @@ static void persistent_dtr(struct dm_exception_store *store)
 	free_area(ps);
 
 	/* Allocated in persistent_read_metadata */
-	if (ps->callbacks)
-		vfree(ps->callbacks);
+	vfree(ps->callbacks);
 
 	kfree(ps);
 }
-- 
2.1.3


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

* Re: [PATCH 0/2] fs-udf: Deletion of two unnecessary checks
  2014-11-18 17:55                                   ` SF Markus Elfring
@ 2014-11-19 20:57                                     ` Jan Kara
  -1 siblings, 0 replies; 3633+ messages in thread
From: Jan Kara @ 2014-11-19 20:57 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Jan Kara, LKML, kernel-janitors, Coccinelle

On Tue 18-11-14 18:55:32, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 18:33:08 +0100
> 
> Another update suggestion was taken into account after a patch was applied
> from static source code analysis.
  I've merged both patches. Thanks.

								Honza
> 
> Markus Elfring (2):
>   Deletion of unnecessary checks before the function call "iput"
>   One function call less in udf_fill_super() after error detection
> 
>  fs/udf/super.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> -- 
> 2.1.3
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 0/2] fs-udf: Deletion of two unnecessary checks
@ 2014-11-19 20:57                                     ` Jan Kara
  0 siblings, 0 replies; 3633+ messages in thread
From: Jan Kara @ 2014-11-19 20:57 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Jan Kara, LKML, kernel-janitors, Coccinelle

On Tue 18-11-14 18:55:32, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 18:33:08 +0100
> 
> Another update suggestion was taken into account after a patch was applied
> from static source code analysis.
  I've merged both patches. Thanks.

								Honza
> 
> Markus Elfring (2):
>   Deletion of unnecessary checks before the function call "iput"
>   One function call less in udf_fill_super() after error detection
> 
>  fs/udf/super.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> -- 
> 2.1.3
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree"
  2014-11-19 19:55                                   ` SF Markus Elfring
@ 2014-11-19 21:54                                     ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-19 21:54 UTC (permalink / raw)
  To: elfring; +Cc: isdn, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 20:55:18 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 20:48:26 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

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

* Re: [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree"
@ 2014-11-19 21:54                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-19 21:54 UTC (permalink / raw)
  To: elfring; +Cc: isdn, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 20:55:18 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 20:48:26 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
  2014-11-18 19:47                                   ` SF Markus Elfring
@ 2014-11-19 22:26                                     ` Julian Anastasov
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julian Anastasov @ 2014-11-19 22:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jozsef Kadlecsik, Pablo Neira Ayuso,
	Patrick McHardy, Simon Horman, Wensong Zhang, netdev, lvs-devel,
	netfilter-devel, coreteam, LKML, kernel-janitors, Coccinelle


	Hello,

On Tue, 18 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 20:37:05 +0100
> 
> The functions free_percpu() and module_put() test whether their argument
> is NULL and then return immediately. Thus the test around the call is
> not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

	Pablo, the IPVS parts look ok to me,

Acked-by: Julian Anastasov <ja@ssi.bg>

> ---
>  net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
>  net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
>  net/netfilter/ipvs/ip_vs_sched.c | 3 +--
>  net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
>  net/netfilter/nf_tables_api.c    | 3 +--
>  5 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index fd3f444..7c5e40a 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
>  
>  static void ip_vs_service_free(struct ip_vs_service *svc)
>  {
> -	if (svc->stats.cpustats)
> -		free_percpu(svc->stats.cpustats);
> +	free_percpu(svc->stats.cpustats);
>  	kfree(svc);
>  }
>  
> diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
> index 1a82b29..0df17ca 100644
> --- a/net/netfilter/ipvs/ip_vs_pe.c
> +++ b/net/netfilter/ipvs/ip_vs_pe.c
> @@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
>  			rcu_read_unlock();
>  			return pe;
>  		}
> -		if (pe->module)
> -			module_put(pe->module);
> +		module_put(pe->module);
>  	}
>  	rcu_read_unlock();
>  
> diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
> index 4dbcda6..199760c 100644
> --- a/net/netfilter/ipvs/ip_vs_sched.c
> +++ b/net/netfilter/ipvs/ip_vs_sched.c
> @@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
>  			mutex_unlock(&ip_vs_sched_mutex);
>  			return sched;
>  		}
> -		if (sched->module)
> -			module_put(sched->module);
> +		module_put(sched->module);
>  	}
>  
>  	mutex_unlock(&ip_vs_sched_mutex);
> diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> index eadffb2..cafe28d 100644
> --- a/net/netfilter/ipvs/ip_vs_sync.c
> +++ b/net/netfilter/ipvs/ip_vs_sync.c
> @@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
>  
>  		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
>  		if (!p->pe_data) {
> -			if (p->pe->module)
> -				module_put(p->pe->module);
> +			module_put(p->pe->module);
>  			return -ENOMEM;
>  		}
>  		p->pe_data_len = pe_data_len;
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index deeb95f..b115f54 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
>  			break;
>  		case NFT_MSG_NEWCHAIN:
>  			if (nft_trans_chain_update(trans)) {
> -				if (nft_trans_chain_stats(trans))
> -					free_percpu(nft_trans_chain_stats(trans));
> +				free_percpu(nft_trans_chain_stats(trans));
>  
>  				nft_trans_destroy(trans);
>  			} else {
> -- 
> 2.1.3

Regards

--
Julian Anastasov <ja@ssi.bg>

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
@ 2014-11-19 22:26                                     ` Julian Anastasov
  0 siblings, 0 replies; 3633+ messages in thread
From: Julian Anastasov @ 2014-11-19 22:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jozsef Kadlecsik, Pablo Neira Ayuso,
	Patrick McHardy, Simon Horman, Wensong Zhang, netdev, lvs-devel,
	netfilter-devel, coreteam, LKML, kernel-janitors, Coccinelle


	Hello,

On Tue, 18 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 20:37:05 +0100
> 
> The functions free_percpu() and module_put() test whether their argument
> is NULL and then return immediately. Thus the test around the call is
> not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

	Pablo, the IPVS parts look ok to me,

Acked-by: Julian Anastasov <ja@ssi.bg>

> ---
>  net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
>  net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
>  net/netfilter/ipvs/ip_vs_sched.c | 3 +--
>  net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
>  net/netfilter/nf_tables_api.c    | 3 +--
>  5 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index fd3f444..7c5e40a 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
>  
>  static void ip_vs_service_free(struct ip_vs_service *svc)
>  {
> -	if (svc->stats.cpustats)
> -		free_percpu(svc->stats.cpustats);
> +	free_percpu(svc->stats.cpustats);
>  	kfree(svc);
>  }
>  
> diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
> index 1a82b29..0df17ca 100644
> --- a/net/netfilter/ipvs/ip_vs_pe.c
> +++ b/net/netfilter/ipvs/ip_vs_pe.c
> @@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
>  			rcu_read_unlock();
>  			return pe;
>  		}
> -		if (pe->module)
> -			module_put(pe->module);
> +		module_put(pe->module);
>  	}
>  	rcu_read_unlock();
>  
> diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
> index 4dbcda6..199760c 100644
> --- a/net/netfilter/ipvs/ip_vs_sched.c
> +++ b/net/netfilter/ipvs/ip_vs_sched.c
> @@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
>  			mutex_unlock(&ip_vs_sched_mutex);
>  			return sched;
>  		}
> -		if (sched->module)
> -			module_put(sched->module);
> +		module_put(sched->module);
>  	}
>  
>  	mutex_unlock(&ip_vs_sched_mutex);
> diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> index eadffb2..cafe28d 100644
> --- a/net/netfilter/ipvs/ip_vs_sync.c
> +++ b/net/netfilter/ipvs/ip_vs_sync.c
> @@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
>  
>  		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
>  		if (!p->pe_data) {
> -			if (p->pe->module)
> -				module_put(p->pe->module);
> +			module_put(p->pe->module);
>  			return -ENOMEM;
>  		}
>  		p->pe_data_len = pe_data_len;
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index deeb95f..b115f54 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
>  			break;
>  		case NFT_MSG_NEWCHAIN:
>  			if (nft_trans_chain_update(trans)) {
> -				if (nft_trans_chain_stats(trans))
> -					free_percpu(nft_trans_chain_stats(trans));
> +				free_percpu(nft_trans_chain_stats(trans));
>  
>  				nft_trans_destroy(trans);
>  			} else {
> -- 
> 2.1.3

Regards

--
Julian Anastasov <ja@ssi.bg>

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
  2014-11-19 22:26                                     ` Julian Anastasov
@ 2014-11-20  1:13                                       ` Simon Horman
  -1 siblings, 0 replies; 3633+ messages in thread
From: Simon Horman @ 2014-11-20  1:13 UTC (permalink / raw)
  To: Julian Anastasov
  Cc: SF Markus Elfring, David S. Miller, Jozsef Kadlecsik,
	Pablo Neira Ayuso, Patrick McHardy, Wensong Zhang, netdev,
	lvs-devel, netfilter-devel, coreteam, LKML, kernel-janitors,
	Coccinelle

On Thu, Nov 20, 2014 at 12:26:56AM +0200, Julian Anastasov wrote:
> 
> 	Hello,
> 
> On Tue, 18 Nov 2014, SF Markus Elfring wrote:
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Tue, 18 Nov 2014 20:37:05 +0100
> > 
> > The functions free_percpu() and module_put() test whether their argument
> > is NULL and then return immediately. Thus the test around the call is
> > not needed.
> > 
> > This issue was detected by using the Coccinelle software.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> 	Pablo, the IPVS parts look ok to me,
> 
> Acked-by: Julian Anastasov <ja@ssi.bg>

Acked-by: Simon Horman <horms@verge.net.au>

> 
> > ---
> >  net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
> >  net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
> >  net/netfilter/ipvs/ip_vs_sched.c | 3 +--
> >  net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
> >  net/netfilter/nf_tables_api.c    | 3 +--
> >  5 files changed, 5 insertions(+), 10 deletions(-)
> > 
> > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> > index fd3f444..7c5e40a 100644
> > --- a/net/netfilter/ipvs/ip_vs_ctl.c
> > +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> > @@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
> >  
> >  static void ip_vs_service_free(struct ip_vs_service *svc)
> >  {
> > -	if (svc->stats.cpustats)
> > -		free_percpu(svc->stats.cpustats);
> > +	free_percpu(svc->stats.cpustats);
> >  	kfree(svc);
> >  }
> >  
> > diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
> > index 1a82b29..0df17ca 100644
> > --- a/net/netfilter/ipvs/ip_vs_pe.c
> > +++ b/net/netfilter/ipvs/ip_vs_pe.c
> > @@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
> >  			rcu_read_unlock();
> >  			return pe;
> >  		}
> > -		if (pe->module)
> > -			module_put(pe->module);
> > +		module_put(pe->module);
> >  	}
> >  	rcu_read_unlock();
> >  
> > diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
> > index 4dbcda6..199760c 100644
> > --- a/net/netfilter/ipvs/ip_vs_sched.c
> > +++ b/net/netfilter/ipvs/ip_vs_sched.c
> > @@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
> >  			mutex_unlock(&ip_vs_sched_mutex);
> >  			return sched;
> >  		}
> > -		if (sched->module)
> > -			module_put(sched->module);
> > +		module_put(sched->module);
> >  	}
> >  
> >  	mutex_unlock(&ip_vs_sched_mutex);
> > diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> > index eadffb2..cafe28d 100644
> > --- a/net/netfilter/ipvs/ip_vs_sync.c
> > +++ b/net/netfilter/ipvs/ip_vs_sync.c
> > @@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
> >  
> >  		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
> >  		if (!p->pe_data) {
> > -			if (p->pe->module)
> > -				module_put(p->pe->module);
> > +			module_put(p->pe->module);
> >  			return -ENOMEM;
> >  		}
> >  		p->pe_data_len = pe_data_len;
> > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> > index deeb95f..b115f54 100644
> > --- a/net/netfilter/nf_tables_api.c
> > +++ b/net/netfilter/nf_tables_api.c
> > @@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
> >  			break;
> >  		case NFT_MSG_NEWCHAIN:
> >  			if (nft_trans_chain_update(trans)) {
> > -				if (nft_trans_chain_stats(trans))
> > -					free_percpu(nft_trans_chain_stats(trans));
> > +				free_percpu(nft_trans_chain_stats(trans));
> >  
> >  				nft_trans_destroy(trans);
> >  			} else {
> > -- 
> > 2.1.3
> 
> Regards
> 
> --
> Julian Anastasov <ja@ssi.bg>
> 

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
@ 2014-11-20  1:13                                       ` Simon Horman
  0 siblings, 0 replies; 3633+ messages in thread
From: Simon Horman @ 2014-11-20  1:13 UTC (permalink / raw)
  To: Julian Anastasov
  Cc: SF Markus Elfring, David S. Miller, Jozsef Kadlecsik,
	Pablo Neira Ayuso, Patrick McHardy, Wensong Zhang, netdev,
	lvs-devel, netfilter-devel, coreteam, LKML, kernel-janitors,
	Coccinelle

On Thu, Nov 20, 2014 at 12:26:56AM +0200, Julian Anastasov wrote:
> 
> 	Hello,
> 
> On Tue, 18 Nov 2014, SF Markus Elfring wrote:
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Tue, 18 Nov 2014 20:37:05 +0100
> > 
> > The functions free_percpu() and module_put() test whether their argument
> > is NULL and then return immediately. Thus the test around the call is
> > not needed.
> > 
> > This issue was detected by using the Coccinelle software.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> 	Pablo, the IPVS parts look ok to me,
> 
> Acked-by: Julian Anastasov <ja@ssi.bg>

Acked-by: Simon Horman <horms@verge.net.au>

> 
> > ---
> >  net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
> >  net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
> >  net/netfilter/ipvs/ip_vs_sched.c | 3 +--
> >  net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
> >  net/netfilter/nf_tables_api.c    | 3 +--
> >  5 files changed, 5 insertions(+), 10 deletions(-)
> > 
> > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> > index fd3f444..7c5e40a 100644
> > --- a/net/netfilter/ipvs/ip_vs_ctl.c
> > +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> > @@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
> >  
> >  static void ip_vs_service_free(struct ip_vs_service *svc)
> >  {
> > -	if (svc->stats.cpustats)
> > -		free_percpu(svc->stats.cpustats);
> > +	free_percpu(svc->stats.cpustats);
> >  	kfree(svc);
> >  }
> >  
> > diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
> > index 1a82b29..0df17ca 100644
> > --- a/net/netfilter/ipvs/ip_vs_pe.c
> > +++ b/net/netfilter/ipvs/ip_vs_pe.c
> > @@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
> >  			rcu_read_unlock();
> >  			return pe;
> >  		}
> > -		if (pe->module)
> > -			module_put(pe->module);
> > +		module_put(pe->module);
> >  	}
> >  	rcu_read_unlock();
> >  
> > diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
> > index 4dbcda6..199760c 100644
> > --- a/net/netfilter/ipvs/ip_vs_sched.c
> > +++ b/net/netfilter/ipvs/ip_vs_sched.c
> > @@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
> >  			mutex_unlock(&ip_vs_sched_mutex);
> >  			return sched;
> >  		}
> > -		if (sched->module)
> > -			module_put(sched->module);
> > +		module_put(sched->module);
> >  	}
> >  
> >  	mutex_unlock(&ip_vs_sched_mutex);
> > diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> > index eadffb2..cafe28d 100644
> > --- a/net/netfilter/ipvs/ip_vs_sync.c
> > +++ b/net/netfilter/ipvs/ip_vs_sync.c
> > @@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
> >  
> >  		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
> >  		if (!p->pe_data) {
> > -			if (p->pe->module)
> > -				module_put(p->pe->module);
> > +			module_put(p->pe->module);
> >  			return -ENOMEM;
> >  		}
> >  		p->pe_data_len = pe_data_len;
> > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> > index deeb95f..b115f54 100644
> > --- a/net/netfilter/nf_tables_api.c
> > +++ b/net/netfilter/nf_tables_api.c
> > @@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
> >  			break;
> >  		case NFT_MSG_NEWCHAIN:
> >  			if (nft_trans_chain_update(trans)) {
> > -				if (nft_trans_chain_stats(trans))
> > -					free_percpu(nft_trans_chain_stats(trans));
> > +				free_percpu(nft_trans_chain_stats(trans));
> >  
> >  				nft_trans_destroy(trans);
> >  			} else {
> > -- 
> > 2.1.3
> 
> Regards
> 
> --
> Julian Anastasov <ja@ssi.bg>
> 

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

* Re: [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
  2014-11-19  7:08                                       ` SF Markus Elfring
@ 2014-11-20  3:53                                         ` Masami Hiramatsu
  -1 siblings, 0 replies; 3633+ messages in thread
From: Masami Hiramatsu @ 2014-11-20  3:53 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, linux-kernel, kernel-janitors, Coccinelle

(2014/11/19 16:08), SF Markus Elfring wrote:
>>> index 3995f54..f1e7d45 100644
>>> --- a/kernel/kprobes.c
>>> +++ b/kernel/kprobes.c
>>> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>>>  out:
>>>  	mutex_unlock(&kprobe_mutex);
>>>  
>>> -	if (probed_mod)
>>> -		module_put(probed_mod);
>>> +	module_put(probed_mod);
>>
>> This is OK, but I you request a comment line over there so that
>> code reader can understand it is safe to pass a NULL pointer to
>> module_put().
> 
> Do you want that I replace the shown null pointer check by a short
> comment which repeats an expectation for the affected function call?

No, not "want". IMHO, if try_module_get(mod) is done only when mod!=NULL,
we shouldn't call module_put(mod) when mod==NULL (even if it is possible),
because those get/put method must be used as a pair, for the better
understandings.

Thank you,


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* Re: [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-20  3:53                                         ` Masami Hiramatsu
  0 siblings, 0 replies; 3633+ messages in thread
From: Masami Hiramatsu @ 2014-11-20  3:53 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ananth N Mavinakayanahalli, Anil S Keshavamurthy,
	David S. Miller, linux-kernel, kernel-janitors, Coccinelle

(2014/11/19 16:08), SF Markus Elfring wrote:
>>> index 3995f54..f1e7d45 100644
>>> --- a/kernel/kprobes.c
>>> +++ b/kernel/kprobes.c
>>> @@ -1527,8 +1527,7 @@ int register_kprobe(struct kprobe *p)
>>>  out:
>>>  	mutex_unlock(&kprobe_mutex);
>>>  
>>> -	if (probed_mod)
>>> -		module_put(probed_mod);
>>> +	module_put(probed_mod);
>>
>> This is OK, but I you request a comment line over there so that
>> code reader can understand it is safe to pass a NULL pointer to
>> module_put().
> 
> Do you want that I replace the shown null pointer check by a short
> comment which repeats an expectation for the affected function call?

No, not "want". IMHO, if try_module_get(mod) is done only when mod!=NULL,
we shouldn't call module_put(mod) when mod=NULL (even if it is possible),
because those get/put method must be used as a pair, for the better
understandings.

Thank you,


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* Re: [PATCH 1/1] DRM-EDID: Deletion of an unnecessary check before the function call "release_firmware"
  2014-11-19 15:40                                   ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-20  4:03                                   ` Thierry Reding
  -1 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:03 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Julia Lawall, kernel-janitors, linux-kernel, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1070 bytes --]

On Nov 19, 2014 4:41 PM, "SF Markus Elfring" <elfring@users.sourceforge.net>
wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 16:33:17 +0100
>
> The release_firmware() function tests whether its argument is NULL and
then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/drm_edid_load.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid_load.c
b/drivers/gpu/drm/drm_edid_load.c
> index 0a235fe..732cb6f 100644
> --- a/drivers/gpu/drm/drm_edid_load.c
> +++ b/drivers/gpu/drm/drm_edid_load.c
> @@ -254,8 +254,7 @@ static void *edid_load(struct drm_connector
*connector, const char *name,
>             name, connector_name);
>
>  out:
> -       if (fw)
> -               release_firmware(fw);
> +       release_firmware(fw);
>         return edid;
>  }
>

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>

[-- Attachment #1.2: Type: text/html, Size: 1592 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hotplug_event"
  2014-11-19 16:14                                   ` [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hot SF Markus Elfring
  (?)
@ 2014-11-20  4:11                                     ` Thierry Reding
  -1 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:11 UTC (permalink / raw)
  To: SF Markus Elfring, David Airlie, dri-devel
  Cc: LKML, kernel-janitors, Julia Lawall

On November 19, 2014 5:28:59 PM SF Markus Elfring 
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 17:05:20 +0100
>
> The drm_fbdev_cma_hotplug_event() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
> b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 000428e..335b1dc 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -58,8 +58,7 @@ static struct drm_framebuffer *tilcdc_fb_create(struct 
> drm_device *dev,
>  static void tilcdc_fb_output_poll_changed(struct drm_device *dev)
>  {
>  	struct tilcdc_drm_private *priv = dev->dev_private;
> -	if (priv->fbdev)
> -		drm_fbdev_cma_hotplug_event(priv->fbdev);
> +	drm_fbdev_cma_hotplug_event(priv->fbdev);
>  }
>
>  static const struct drm_mode_config_funcs mode_config_funcs = {

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>



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

* Re: [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma
@ 2014-11-20  4:11                                     ` Thierry Reding
  0 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:11 UTC (permalink / raw)
  To: SF Markus Elfring, David Airlie, dri-devel
  Cc: Julia Lawall, kernel-janitors, LKML

On November 19, 2014 5:28:59 PM SF Markus Elfring 
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 17:05:20 +0100
>
> The drm_fbdev_cma_hotplug_event() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
> b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 000428e..335b1dc 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -58,8 +58,7 @@ static struct drm_framebuffer *tilcdc_fb_create(struct 
> drm_device *dev,
>  static void tilcdc_fb_output_poll_changed(struct drm_device *dev)
>  {
>  	struct tilcdc_drm_private *priv = dev->dev_private;
> -	if (priv->fbdev)
> -		drm_fbdev_cma_hotplug_event(priv->fbdev);
> +	drm_fbdev_cma_hotplug_event(priv->fbdev);
>  }
>
>  static const struct drm_mode_config_funcs mode_config_funcs = {

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>



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

* Re: [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hotplug_event"
@ 2014-11-20  4:11                                     ` Thierry Reding
  0 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:11 UTC (permalink / raw)
  To: SF Markus Elfring, David Airlie, dri-devel
  Cc: Julia Lawall, kernel-janitors, LKML

On November 19, 2014 5:28:59 PM SF Markus Elfring 
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 17:05:20 +0100
>
> The drm_fbdev_cma_hotplug_event() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
> b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 000428e..335b1dc 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -58,8 +58,7 @@ static struct drm_framebuffer *tilcdc_fb_create(struct 
> drm_device *dev,
>  static void tilcdc_fb_output_poll_changed(struct drm_device *dev)
>  {
>  	struct tilcdc_drm_private *priv = dev->dev_private;
> -	if (priv->fbdev)
> -		drm_fbdev_cma_hotplug_event(priv->fbdev);
> +	drm_fbdev_cma_hotplug_event(priv->fbdev);
>  }
>
>  static const struct drm_mode_config_funcs mode_config_funcs = {

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/1] DRM-UDL: Deletion of an unnecessary check before the function call "vunmap"
  2014-11-19 16:37                                   ` SF Markus Elfring
  (?)
@ 2014-11-20  4:17                                     ` Thierry Reding
  -1 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:17 UTC (permalink / raw)
  To: SF Markus Elfring, David Airlie, dri-devel
  Cc: LKML, kernel-janitors, Julia Lawall

On November 19, 2014 5:42:26 PM SF Markus Elfring 
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 17:33:32 +0100
>
> The vunmap() function performes also input parameter validation. Thus the test
> around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/udl/udl_gem.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
> index 8044f5f..2979625 100644
> --- a/drivers/gpu/drm/udl/udl_gem.c
> +++ b/drivers/gpu/drm/udl/udl_gem.c
> @@ -164,8 +164,7 @@ void udl_gem_vunmap(struct udl_gem_object *obj)
>  		return;
>  	}
>
> -	if (obj->vmapping)
> -		vunmap(obj->vmapping);
> +	vunmap(obj->vmapping);
>
>  	udl_gem_put_pages(obj);
>  }

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>



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

* Re: [PATCH 1/1] DRM-UDL: Deletion of an unnecessary check before the function call "vunmap"
@ 2014-11-20  4:17                                     ` Thierry Reding
  0 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:17 UTC (permalink / raw)
  To: SF Markus Elfring, David Airlie, dri-devel
  Cc: Julia Lawall, kernel-janitors, LKML

On November 19, 2014 5:42:26 PM SF Markus Elfring 
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 17:33:32 +0100
>
> The vunmap() function performes also input parameter validation. Thus the test
> around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/udl/udl_gem.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
> index 8044f5f..2979625 100644
> --- a/drivers/gpu/drm/udl/udl_gem.c
> +++ b/drivers/gpu/drm/udl/udl_gem.c
> @@ -164,8 +164,7 @@ void udl_gem_vunmap(struct udl_gem_object *obj)
>  		return;
>  	}
>
> -	if (obj->vmapping)
> -		vunmap(obj->vmapping);
> +	vunmap(obj->vmapping);
>
>  	udl_gem_put_pages(obj);
>  }

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>



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

* Re: [PATCH 1/1] DRM-UDL: Deletion of an unnecessary check before the function call "vunmap"
@ 2014-11-20  4:17                                     ` Thierry Reding
  0 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:17 UTC (permalink / raw)
  To: SF Markus Elfring, David Airlie, dri-devel
  Cc: Julia Lawall, kernel-janitors, LKML

On November 19, 2014 5:42:26 PM SF Markus Elfring 
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 17:33:32 +0100
>
> The vunmap() function performes also input parameter validation. Thus the test
> around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/udl/udl_gem.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
> index 8044f5f..2979625 100644
> --- a/drivers/gpu/drm/udl/udl_gem.c
> +++ b/drivers/gpu/drm/udl/udl_gem.c
> @@ -164,8 +164,7 @@ void udl_gem_vunmap(struct udl_gem_object *obj)
>  		return;
>  	}
>
> -	if (obj->vmapping)
> -		vunmap(obj->vmapping);
> +	vunmap(obj->vmapping);
>
>  	udl_gem_put_pages(obj);
>  }

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
  2014-11-19 16:55                                   ` SF Markus Elfring
  (?)
@ 2014-11-20  4:22                                     ` Thierry Reding
  -1 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:22 UTC (permalink / raw)
  To: SF Markus Elfring, David Airlie, dri-devel
  Cc: LKML, kernel-janitors, Julia Lawall

On November 19, 2014 5:57:13 PM SF Markus Elfring 
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 17:50:19 +0100
>
> The vfree() function performes also input parameter validation. Thus the test
> around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 14b2f50..f9a67b8 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -889,8 +889,7 @@ static int vmw_driver_unload(struct drm_device *dev)
>
>  	if (dev_priv->ctx.res_ht_initialized)
>  		drm_ht_remove(&dev_priv->ctx.res_ht);
> -	if (dev_priv->ctx.cmd_bounce)
> -		vfree(dev_priv->ctx.cmd_bounce);
> +	vfree(dev_priv->ctx.cmd_bounce);
>  	if (dev_priv->enable_fb) {
>  		vmw_fb_close(dev_priv);
>  		vmw_kms_restore_vga(dev_priv);

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>



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

* Re: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-20  4:22                                     ` Thierry Reding
  0 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:22 UTC (permalink / raw)
  To: SF Markus Elfring, David Airlie, dri-devel
  Cc: Julia Lawall, kernel-janitors, LKML

On November 19, 2014 5:57:13 PM SF Markus Elfring 
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 17:50:19 +0100
>
> The vfree() function performes also input parameter validation. Thus the test
> around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 14b2f50..f9a67b8 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -889,8 +889,7 @@ static int vmw_driver_unload(struct drm_device *dev)
>
>  	if (dev_priv->ctx.res_ht_initialized)
>  		drm_ht_remove(&dev_priv->ctx.res_ht);
> -	if (dev_priv->ctx.cmd_bounce)
> -		vfree(dev_priv->ctx.cmd_bounce);
> +	vfree(dev_priv->ctx.cmd_bounce);
>  	if (dev_priv->enable_fb) {
>  		vmw_fb_close(dev_priv);
>  		vmw_kms_restore_vga(dev_priv);

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>



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

* Re: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-20  4:22                                     ` Thierry Reding
  0 siblings, 0 replies; 3633+ messages in thread
From: Thierry Reding @ 2014-11-20  4:22 UTC (permalink / raw)
  To: SF Markus Elfring, David Airlie, dri-devel
  Cc: Julia Lawall, kernel-janitors, LKML

On November 19, 2014 5:57:13 PM SF Markus Elfring 
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 17:50:19 +0100
>
> The vfree() function performes also input parameter validation. Thus the test
> around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 14b2f50..f9a67b8 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -889,8 +889,7 @@ static int vmw_driver_unload(struct drm_device *dev)
>
>  	if (dev_priv->ctx.res_ht_initialized)
>  		drm_ht_remove(&dev_priv->ctx.res_ht);
> -	if (dev_priv->ctx.cmd_bounce)
> -		vfree(dev_priv->ctx.cmd_bounce);
> +	vfree(dev_priv->ctx.cmd_bounce);
>  	if (dev_priv->enable_fb) {
>  		vmw_fb_close(dev_priv);
>  		vmw_kms_restore_vga(dev_priv);

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-20  8:19                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:19 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 23:30:37 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (3):
  DVB-frontends: Deletion of unnecessary checks before the function
    call "release_firmware"
  m88ds3103: One function call less in m88ds3103_init() after error detection
  si2168: One function call less in si2168_init() after error detection

 drivers/media/dvb-frontends/drx39xyj/drxj.c |  3 +--
 drivers/media/dvb-frontends/drxk_hard.c     |  3 +--
 drivers/media/dvb-frontends/m88ds3103.c     | 12 ++++++------
 drivers/media/dvb-frontends/si2168.c        | 10 +++++-----
 4 files changed, 13 insertions(+), 15 deletions(-)

-- 
2.1.3


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

* [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks
@ 2014-11-20  8:19                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:19 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 23:30:37 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (3):
  DVB-frontends: Deletion of unnecessary checks before the function
    call "release_firmware"
  m88ds3103: One function call less in m88ds3103_init() after error detection
  si2168: One function call less in si2168_init() after error detection

 drivers/media/dvb-frontends/drx39xyj/drxj.c |  3 +--
 drivers/media/dvb-frontends/drxk_hard.c     |  3 +--
 drivers/media/dvb-frontends/m88ds3103.c     | 12 ++++++------
 drivers/media/dvb-frontends/si2168.c        | 10 +++++-----
 4 files changed, 13 insertions(+), 15 deletions(-)

-- 
2.1.3


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

* [PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection
  2014-11-20  8:19                                   ` SF Markus Elfring
@ 2014-11-20  8:29                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:29 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 23:20:51 +0100

The release_firmware() function was called in some cases by the
m88ds3103_init() function during error handling even if the passed variable
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/m88ds3103.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index e88f0f6..82da715 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -590,7 +590,7 @@ static int m88ds3103_init(struct dvb_frontend *fe)
 
 	ret = m88ds3103_wr_reg(priv, 0xb2, 0x01);
 	if (ret)
-		goto err;
+		goto error_fw_release;
 
 	for (remaining = fw->size; remaining > 0;
 			remaining -= (priv->cfg->i2c_wr_max - 1)) {
@@ -604,13 +604,13 @@ static int m88ds3103_init(struct dvb_frontend *fe)
 			dev_err(&priv->i2c->dev,
 					"%s: firmware download failed=%d\n",
 					KBUILD_MODNAME, ret);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
 	ret = m88ds3103_wr_reg(priv, 0xb2, 0x00);
 	if (ret)
-		goto err;
+		goto error_fw_release;
 
 	release_firmware(fw);
 	fw = NULL;
@@ -636,9 +636,10 @@ skip_fw_download:
 	priv->warm = true;
 
 	return 0;
-err:
-	release_firmware(fw);
 
+error_fw_release:
+	release_firmware(fw);
+err:
 	dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
 }
-- 
2.1.3


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

* [PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection
@ 2014-11-20  8:29                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:29 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 23:20:51 +0100

The release_firmware() function was called in some cases by the
m88ds3103_init() function during error handling even if the passed variable
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/m88ds3103.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index e88f0f6..82da715 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -590,7 +590,7 @@ static int m88ds3103_init(struct dvb_frontend *fe)
 
 	ret = m88ds3103_wr_reg(priv, 0xb2, 0x01);
 	if (ret)
-		goto err;
+		goto error_fw_release;
 
 	for (remaining = fw->size; remaining > 0;
 			remaining -= (priv->cfg->i2c_wr_max - 1)) {
@@ -604,13 +604,13 @@ static int m88ds3103_init(struct dvb_frontend *fe)
 			dev_err(&priv->i2c->dev,
 					"%s: firmware download failed=%d\n",
 					KBUILD_MODNAME, ret);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
 	ret = m88ds3103_wr_reg(priv, 0xb2, 0x00);
 	if (ret)
-		goto err;
+		goto error_fw_release;
 
 	release_firmware(fw);
 	fw = NULL;
@@ -636,9 +636,10 @@ skip_fw_download:
 	priv->warm = true;
 
 	return 0;
-err:
-	release_firmware(fw);
 
+error_fw_release:
+	release_firmware(fw);
+err:
 	dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
 }
-- 
2.1.3


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

* [PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call "release_firmware"
  2014-11-20  8:19                                   ` SF Markus Elfring
@ 2014-11-20  8:33                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:33 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 22:27:24 +0100

The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/drx39xyj/drxj.c | 3 +--
 drivers/media/dvb-frontends/drxk_hard.c     | 3 +--
 drivers/media/dvb-frontends/m88ds3103.c     | 3 +--
 drivers/media/dvb-frontends/si2168.c        | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 7ca7a21..08e6ca5 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -12255,8 +12255,7 @@ static void drx39xxj_release(struct dvb_frontend *fe)
 	kfree(demod->my_ext_attr);
 	kfree(demod->my_common_attr);
 	kfree(demod->my_i2c_dev_addr);
-	if (demod->firmware)
-		release_firmware(demod->firmware);
+	release_firmware(demod->firmware);
 	kfree(demod);
 	kfree(state);
 }
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index cce94a7..f871478 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -6309,8 +6309,7 @@ static void drxk_release(struct dvb_frontend *fe)
 	struct drxk_state *state = fe->demodulator_priv;
 
 	dprintk(1, "\n");
-	if (state->fw)
-		release_firmware(state->fw);
+	release_firmware(state->fw);
 
 	kfree(state);
 }
diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index dfe0c2f..e88f0f6 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -637,8 +637,7 @@ skip_fw_download:
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 8f81d97..6a455f9 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -469,8 +469,7 @@ static int si2168_init(struct dvb_frontend *fe)
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
-- 
2.1.3


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

* [PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call "release_
@ 2014-11-20  8:33                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:33 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 22:27:24 +0100

The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/drx39xyj/drxj.c | 3 +--
 drivers/media/dvb-frontends/drxk_hard.c     | 3 +--
 drivers/media/dvb-frontends/m88ds3103.c     | 3 +--
 drivers/media/dvb-frontends/si2168.c        | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 7ca7a21..08e6ca5 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -12255,8 +12255,7 @@ static void drx39xxj_release(struct dvb_frontend *fe)
 	kfree(demod->my_ext_attr);
 	kfree(demod->my_common_attr);
 	kfree(demod->my_i2c_dev_addr);
-	if (demod->firmware)
-		release_firmware(demod->firmware);
+	release_firmware(demod->firmware);
 	kfree(demod);
 	kfree(state);
 }
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index cce94a7..f871478 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -6309,8 +6309,7 @@ static void drxk_release(struct dvb_frontend *fe)
 	struct drxk_state *state = fe->demodulator_priv;
 
 	dprintk(1, "\n");
-	if (state->fw)
-		release_firmware(state->fw);
+	release_firmware(state->fw);
 
 	kfree(state);
 }
diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index dfe0c2f..e88f0f6 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -637,8 +637,7 @@ skip_fw_download:
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 8f81d97..6a455f9 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -469,8 +469,7 @@ static int si2168_init(struct dvb_frontend *fe)
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
-- 
2.1.3


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

* [PATCH 3/3] [media] si2168: One function call less in si2168_init() after error detection
  2014-11-20  8:19                                   ` SF Markus Elfring
@ 2014-11-20  8:39                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:39 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 23:23:15 +0100

The release_firmware() function was called in some cases by the
si2168_init() function during error handling even if the passed variable
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/si2168.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 6a455f9..b8c6372 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -428,7 +428,7 @@ static int si2168_init(struct dvb_frontend *fe)
 			dev_err(&s->client->dev,
 					"%s: firmware file '%s' not found\n",
 					KBUILD_MODNAME, fw_file);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
@@ -448,7 +448,7 @@ static int si2168_init(struct dvb_frontend *fe)
 			dev_err(&s->client->dev,
 					"%s: firmware download failed=%d\n",
 					KBUILD_MODNAME, ret);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
@@ -468,9 +468,10 @@ static int si2168_init(struct dvb_frontend *fe)
 	s->active = true;
 
 	return 0;
-err:
-	release_firmware(fw);
 
+error_fw_release:
+	release_firmware(fw);
+err:
 	dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
 }
-- 
2.1.3


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

* [PATCH 3/3] [media] si2168: One function call less in si2168_init() after error detection
@ 2014-11-20  8:39                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  8:39 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 23:23:15 +0100

The release_firmware() function was called in some cases by the
si2168_init() function during error handling even if the passed variable
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/si2168.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 6a455f9..b8c6372 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -428,7 +428,7 @@ static int si2168_init(struct dvb_frontend *fe)
 			dev_err(&s->client->dev,
 					"%s: firmware file '%s' not found\n",
 					KBUILD_MODNAME, fw_file);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
@@ -448,7 +448,7 @@ static int si2168_init(struct dvb_frontend *fe)
 			dev_err(&s->client->dev,
 					"%s: firmware download failed=%d\n",
 					KBUILD_MODNAME, ret);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
@@ -468,9 +468,10 @@ static int si2168_init(struct dvb_frontend *fe)
 	s->active = true;
 
 	return 0;
-err:
-	release_firmware(fw);
 
+error_fw_release:
+	release_firmware(fw);
+err:
 	dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
 }
-- 
2.1.3


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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-19 18:49                                       ` SF Markus Elfring
@ 2014-11-20  8:47                                         ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-20  8:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: John Fastabend, David S. Miller, Jamal Hadi Salim, netdev, LKML,
	kernel-janitors

On Wed, 19 Nov 2014, SF Markus Elfring wrote:

> > Marcus, what tree are you looking at?
>
> I dared to base this update suggestion on the source files
> for Linux 3.17.3. Are newer software developments relevant here?

You should always use linux-next.  You should update it every day.

julia

> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/
>
> Regards,
> Markus
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-20  8:47                                         ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-20  8:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: John Fastabend, David S. Miller, Jamal Hadi Salim, netdev, LKML,
	kernel-janitors

On Wed, 19 Nov 2014, SF Markus Elfring wrote:

> > Marcus, what tree are you looking at?
>
> I dared to base this update suggestion on the source files
> for Linux 3.17.3. Are newer software developments relevant here?

You should always use linux-next.  You should update it every day.

julia

> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/
>
> Regards,
> Markus
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-20  8:47                                         ` Julia Lawall
  (?)
@ 2014-11-20  9:22                                           ` Daniel Borkmann
  -1 siblings, 0 replies; 3633+ messages in thread
From: Daniel Borkmann @ 2014-11-20  9:22 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, John Fastabend, David S. Miller,
	Jamal Hadi Salim, netdev, LKML, kernel-janitors

On 11/20/2014 09:47 AM, Julia Lawall wrote:
> On Wed, 19 Nov 2014, SF Markus Elfring wrote:
>
>>> Marcus, what tree are you looking at?
>>
>> I dared to base this update suggestion on the source files
>> for Linux 3.17.3. Are newer software developments relevant here?
>
> You should always use linux-next.  You should update it every day.

Well, if you send in cleanups to netdev, you should always target
the net-next tree:

   git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-20  9:22                                           ` Daniel Borkmann
  0 siblings, 0 replies; 3633+ messages in thread
From: Daniel Borkmann @ 2014-11-20  9:22 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, John Fastabend, David S. Miller,
	Jamal Hadi Salim, netdev, LKML, kernel-janitors

On 11/20/2014 09:47 AM, Julia Lawall wrote:
> On Wed, 19 Nov 2014, SF Markus Elfring wrote:
>
>>> Marcus, what tree are you looking at?
>>
>> I dared to base this update suggestion on the source files
>> for Linux 3.17.3. Are newer software developments relevant here?
>
> You should always use linux-next.  You should update it every day.

Well, if you send in cleanups to netdev, you should always target
the net-next tree:

   git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-20  9:22                                           ` Daniel Borkmann
  0 siblings, 0 replies; 3633+ messages in thread
From: Daniel Borkmann @ 2014-11-20  9:22 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, John Fastabend, David S. Miller,
	Jamal Hadi Salim, netdev, LKML, kernel-janitors

On 11/20/2014 09:47 AM, Julia Lawall wrote:
> On Wed, 19 Nov 2014, SF Markus Elfring wrote:
>
>>> Marcus, what tree are you looking at?
>>
>> I dared to base this update suggestion on the source files
>> for Linux 3.17.3. Are newer software developments relevant here?
>
> You should always use linux-next.  You should update it every day.

Well, if you send in cleanups to netdev, you should always target
the net-next tree:

   git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

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

* [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-20  9:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  9:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Stefan Richter, linux-media, linux1394-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 10:49:07 +0100

The dvb_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/firewire/firedtv-ci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/firewire/firedtv-ci.c b/drivers/media/firewire/firedtv-ci.c
index e5ebdbf..e63f582 100644
--- a/drivers/media/firewire/firedtv-ci.c
+++ b/drivers/media/firewire/firedtv-ci.c
@@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv)
 
 void fdtv_ca_release(struct firedtv *fdtv)
 {
-	if (fdtv->cadev)
-		dvb_unregister_device(fdtv->cadev);
+	dvb_unregister_device(fdtv->cadev);
 }
-- 
2.1.3


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

* [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregis
@ 2014-11-20  9:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20  9:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Stefan Richter, linux-media, linux1394-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 10:49:07 +0100

The dvb_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/firewire/firedtv-ci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/firewire/firedtv-ci.c b/drivers/media/firewire/firedtv-ci.c
index e5ebdbf..e63f582 100644
--- a/drivers/media/firewire/firedtv-ci.c
+++ b/drivers/media/firewire/firedtv-ci.c
@@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv)
 
 void fdtv_ca_release(struct firedtv *fdtv)
 {
-	if (fdtv->cadev)
-		dvb_unregister_device(fdtv->cadev);
+	dvb_unregister_device(fdtv->cadev);
 }
-- 
2.1.3


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

* [PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call "rc_unregister_device"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-20 10:20                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 10:20 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 11:13:16 +0100

The rc_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/i2c/ir-kbd-i2c.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 8311f1a..175a761 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -464,8 +464,7 @@ static int ir_remove(struct i2c_client *client)
 	cancel_delayed_work_sync(&ir->work);
 
 	/* unregister device */
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* free memory */
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call "rc_unregister_de
@ 2014-11-20 10:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 10:20 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 11:13:16 +0100

The rc_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/i2c/ir-kbd-i2c.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 8311f1a..175a761 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -464,8 +464,7 @@ static int ir_remove(struct i2c_client *client)
 	cancel_delayed_work_sync(&ir->work);
 
 	/* unregister device */
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* free memory */
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-20 10:50                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 10:50 UTC (permalink / raw)
  To: Kukjin Kim, Kyungmin Park, Mauro Carvalho Chehab,
	Sylwester Nawrocki, linux-media, linux-arm-kernel
  Cc: linux-samsung-soc, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 11:44:20 +0100

The functions i2c_put_adapter() and release_firmware() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/exynos4-is/fimc-is.c   | 6 ++----
 drivers/media/platform/s3c-camif/camif-core.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 5476dce..a1db27b 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -428,8 +428,7 @@ static void fimc_is_load_firmware(const struct firmware *fw, void *context)
 	 * needed around for copying to the IS working memory every
 	 * time before the Cortex-A5 is restarted.
 	 */
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	is->fw.f_w = fw;
 done:
 	mutex_unlock(&is->lock);
@@ -937,8 +936,7 @@ static int fimc_is_remove(struct platform_device *pdev)
 	vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
 	fimc_is_put_clocks(is);
 	fimc_is_debugfs_remove(is);
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	fimc_is_free_cpu_memory(is);
 
 	return 0;
diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
index b385747..3b09b5b 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -256,8 +256,7 @@ static void camif_unregister_sensor(struct camif_dev *camif)
 	v4l2_device_unregister_subdev(sd);
 	camif->sensor.sd = NULL;
 	i2c_unregister_device(client);
-	if (adapter)
-		i2c_put_adapter(adapter);
+	i2c_put_adapter(adapter);
 }
 
 static int camif_create_media_links(struct camif_dev *camif)
-- 
2.1.3


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

* [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls
@ 2014-11-20 10:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 10:50 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 11:44:20 +0100

The functions i2c_put_adapter() and release_firmware() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/exynos4-is/fimc-is.c   | 6 ++----
 drivers/media/platform/s3c-camif/camif-core.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 5476dce..a1db27b 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -428,8 +428,7 @@ static void fimc_is_load_firmware(const struct firmware *fw, void *context)
 	 * needed around for copying to the IS working memory every
 	 * time before the Cortex-A5 is restarted.
 	 */
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	is->fw.f_w = fw;
 done:
 	mutex_unlock(&is->lock);
@@ -937,8 +936,7 @@ static int fimc_is_remove(struct platform_device *pdev)
 	vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
 	fimc_is_put_clocks(is);
 	fimc_is_debugfs_remove(is);
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	fimc_is_free_cpu_memory(is);
 
 	return 0;
diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
index b385747..3b09b5b 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -256,8 +256,7 @@ static void camif_unregister_sensor(struct camif_dev *camif)
 	v4l2_device_unregister_subdev(sd);
 	camif->sensor.sd = NULL;
 	i2c_unregister_device(client);
-	if (adapter)
-		i2c_put_adapter(adapter);
+	i2c_put_adapter(adapter);
 }
 
 static int camif_create_media_links(struct camif_dev *camif)
-- 
2.1.3


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

* [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls
@ 2014-11-20 10:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 10:50 UTC (permalink / raw)
  To: Kukjin Kim, Kyungmin Park, Mauro Carvalho Chehab,
	Sylwester Nawrocki, linux-media, linux-arm-kernel
  Cc: linux-samsung-soc, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 11:44:20 +0100

The functions i2c_put_adapter() and release_firmware() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/exynos4-is/fimc-is.c   | 6 ++----
 drivers/media/platform/s3c-camif/camif-core.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 5476dce..a1db27b 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -428,8 +428,7 @@ static void fimc_is_load_firmware(const struct firmware *fw, void *context)
 	 * needed around for copying to the IS working memory every
 	 * time before the Cortex-A5 is restarted.
 	 */
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	is->fw.f_w = fw;
 done:
 	mutex_unlock(&is->lock);
@@ -937,8 +936,7 @@ static int fimc_is_remove(struct platform_device *pdev)
 	vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
 	fimc_is_put_clocks(is);
 	fimc_is_debugfs_remove(is);
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	fimc_is_free_cpu_memory(is);
 
 	return 0;
diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
index b385747..3b09b5b 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -256,8 +256,7 @@ static void camif_unregister_sensor(struct camif_dev *camif)
 	v4l2_device_unregister_subdev(sd);
 	camif->sensor.sd = NULL;
 	i2c_unregister_device(client);
-	if (adapter)
-		i2c_put_adapter(adapter);
+	i2c_put_adapter(adapter);
 }
 
 static int camif_create_media_links(struct camif_dev *camif)
-- 
2.1.3

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

* [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls
@ 2014-11-20 10:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 10:50 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 11:44:20 +0100

The functions i2c_put_adapter() and release_firmware() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/exynos4-is/fimc-is.c   | 6 ++----
 drivers/media/platform/s3c-camif/camif-core.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 5476dce..a1db27b 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -428,8 +428,7 @@ static void fimc_is_load_firmware(const struct firmware *fw, void *context)
 	 * needed around for copying to the IS working memory every
 	 * time before the Cortex-A5 is restarted.
 	 */
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	is->fw.f_w = fw;
 done:
 	mutex_unlock(&is->lock);
@@ -937,8 +936,7 @@ static int fimc_is_remove(struct platform_device *pdev)
 	vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
 	fimc_is_put_clocks(is);
 	fimc_is_debugfs_remove(is);
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	fimc_is_free_cpu_memory(is);
 
 	return 0;
diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
index b385747..3b09b5b 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -256,8 +256,7 @@ static void camif_unregister_sensor(struct camif_dev *camif)
 	v4l2_device_unregister_subdev(sd);
 	camif->sensor.sd = NULL;
 	i2c_unregister_device(client);
-	if (adapter)
-		i2c_put_adapter(adapter);
+	i2c_put_adapter(adapter);
 }
 
 static int camif_create_media_links(struct camif_dev *camif)
-- 
2.1.3

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

* [PATCH 1/1] [media] rc: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-20 12:08                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 12:08 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 13:01:32 +0100

The functions input_free_device() and rc_close() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/rc/lirc_dev.c | 3 +--
 drivers/media/rc/rc-main.c  | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index dc5cbff..5c232e6 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -518,8 +518,7 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)
 
 	WARN_ON(mutex_lock_killable(&lirc_dev_lock));
 
-	if (ir->d.rdev)
-		rc_close(ir->d.rdev);
+	rc_close(ir->d.rdev);
 
 	ir->open--;
 	if (ir->attached) {
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 8d3b74c..66df9fb 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1298,8 +1298,7 @@ void rc_free_device(struct rc_dev *dev)
 	if (!dev)
 		return;
 
-	if (dev->input_dev)
-		input_free_device(dev->input_dev);
+	input_free_device(dev->input_dev);
 
 	put_device(&dev->dev);
 
-- 
2.1.3


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

* [PATCH 1/1] [media] rc: Deletion of unnecessary checks before two function calls
@ 2014-11-20 12:08                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 12:08 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 13:01:32 +0100

The functions input_free_device() and rc_close() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/rc/lirc_dev.c | 3 +--
 drivers/media/rc/rc-main.c  | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index dc5cbff..5c232e6 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -518,8 +518,7 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)
 
 	WARN_ON(mutex_lock_killable(&lirc_dev_lock));
 
-	if (ir->d.rdev)
-		rc_close(ir->d.rdev);
+	rc_close(ir->d.rdev);
 
 	ir->open--;
 	if (ir->attached) {
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 8d3b74c..66df9fb 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1298,8 +1298,7 @@ void rc_free_device(struct rc_dev *dev)
 	if (!dev)
 		return;
 
-	if (dev->input_dev)
-		input_free_device(dev->input_dev);
+	input_free_device(dev->input_dev);
 
 	put_device(&dev->dev);
 
-- 
2.1.3


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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
  2014-11-20  1:13                                       ` Simon Horman
@ 2014-11-20 12:16                                         ` Pablo Neira Ayuso
  -1 siblings, 0 replies; 3633+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-20 12:16 UTC (permalink / raw)
  To: Simon Horman
  Cc: Julian Anastasov, SF Markus Elfring, David S. Miller,
	Jozsef Kadlecsik, Patrick McHardy, Wensong Zhang, netdev,
	lvs-devel, netfilter-devel, coreteam, LKML, kernel-janitors,
	Coccinelle

On Thu, Nov 20, 2014 at 10:13:59AM +0900, Simon Horman wrote:
> On Thu, Nov 20, 2014 at 12:26:56AM +0200, Julian Anastasov wrote:
> > 
> > 	Hello,
> > 
> > On Tue, 18 Nov 2014, SF Markus Elfring wrote:
> > 
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Tue, 18 Nov 2014 20:37:05 +0100
> > > 
> > > The functions free_percpu() and module_put() test whether their argument
> > > is NULL and then return immediately. Thus the test around the call is
> > > not needed.
> > > 
> > > This issue was detected by using the Coccinelle software.
> > > 
> > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > 
> > 	Pablo, the IPVS parts look ok to me,
> > 
> > Acked-by: Julian Anastasov <ja@ssi.bg>
> 
> Acked-by: Simon Horman <horms@verge.net.au>

Applied, thanks.

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
@ 2014-11-20 12:16                                         ` Pablo Neira Ayuso
  0 siblings, 0 replies; 3633+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-20 12:16 UTC (permalink / raw)
  To: Simon Horman
  Cc: Julian Anastasov, SF Markus Elfring, David S. Miller,
	Jozsef Kadlecsik, Patrick McHardy, Wensong Zhang, netdev,
	lvs-devel, netfilter-devel, coreteam, LKML, kernel-janitors,
	Coccinelle

On Thu, Nov 20, 2014 at 10:13:59AM +0900, Simon Horman wrote:
> On Thu, Nov 20, 2014 at 12:26:56AM +0200, Julian Anastasov wrote:
> > 
> > 	Hello,
> > 
> > On Tue, 18 Nov 2014, SF Markus Elfring wrote:
> > 
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Tue, 18 Nov 2014 20:37:05 +0100
> > > 
> > > The functions free_percpu() and module_put() test whether their argument
> > > is NULL and then return immediately. Thus the test around the call is
> > > not needed.
> > > 
> > > This issue was detected by using the Coccinelle software.
> > > 
> > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > 
> > 	Pablo, the IPVS parts look ok to me,
> > 
> > Acked-by: Julian Anastasov <ja@ssi.bg>
> 
> Acked-by: Simon Horman <horms@verge.net.au>

Applied, thanks.

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

* [PATCH 1/1] [media] USB: Deletion of unnecessary checks before three function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-20 12:33                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 12:33 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Mike Isely, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 13:26:36 +0100

The functions pvr2_hdw_destroy(), rc_unregister_device() and vfree() perform
also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/au0828/au0828-input.c     | 3 +--
 drivers/media/usb/em28xx/em28xx-input.c     | 3 +--
 drivers/media/usb/pvrusb2/pvrusb2-context.c | 2 +-
 drivers/media/usb/s2255/s2255drv.c          | 3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c
index fd0d3a90..3357141 100644
--- a/drivers/media/usb/au0828/au0828-input.c
+++ b/drivers/media/usb/au0828/au0828-input.c
@@ -353,8 +353,7 @@ void au0828_rc_unregister(struct au0828_dev *dev)
 	if (!ir)
 		return;
 
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* done */
 	kfree(ir);
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index ed843bd..67a22f4 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -838,8 +838,7 @@ static int em28xx_ir_fini(struct em28xx *dev)
 	if (!ir)
 		goto ref_put;
 
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* done */
 	kfree(ir);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
index 7c19ff7..c8761c7 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
@@ -80,7 +80,7 @@ static void pvr2_context_set_notify(struct pvr2_context *mp, int fl)
 static void pvr2_context_destroy(struct pvr2_context *mp)
 {
 	pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (destroy)",mp);
-	if (mp->hdw) pvr2_hdw_destroy(mp->hdw);
+	pvr2_hdw_destroy(mp->hdw);
 	pvr2_context_set_notify(mp, 0);
 	mutex_lock(&pvr2_context_mutex);
 	if (mp->exist_next) {
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 2c90186..3cab886 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1976,8 +1976,7 @@ static int s2255_release_sys_buffers(struct s2255_vc *vc)
 {
 	unsigned long i;
 	for (i = 0; i < SYS_FRAMES; i++) {
-		if (vc->buffer.frame[i].lpvbits)
-			vfree(vc->buffer.frame[i].lpvbits);
+		vfree(vc->buffer.frame[i].lpvbits);
 		vc->buffer.frame[i].lpvbits = NULL;
 	}
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] [media] USB: Deletion of unnecessary checks before three function calls
@ 2014-11-20 12:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 12:33 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Mike Isely, linux-media
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 13:26:36 +0100

The functions pvr2_hdw_destroy(), rc_unregister_device() and vfree() perform
also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/au0828/au0828-input.c     | 3 +--
 drivers/media/usb/em28xx/em28xx-input.c     | 3 +--
 drivers/media/usb/pvrusb2/pvrusb2-context.c | 2 +-
 drivers/media/usb/s2255/s2255drv.c          | 3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c
index fd0d3a90..3357141 100644
--- a/drivers/media/usb/au0828/au0828-input.c
+++ b/drivers/media/usb/au0828/au0828-input.c
@@ -353,8 +353,7 @@ void au0828_rc_unregister(struct au0828_dev *dev)
 	if (!ir)
 		return;
 
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* done */
 	kfree(ir);
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index ed843bd..67a22f4 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -838,8 +838,7 @@ static int em28xx_ir_fini(struct em28xx *dev)
 	if (!ir)
 		goto ref_put;
 
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* done */
 	kfree(ir);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
index 7c19ff7..c8761c7 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
@@ -80,7 +80,7 @@ static void pvr2_context_set_notify(struct pvr2_context *mp, int fl)
 static void pvr2_context_destroy(struct pvr2_context *mp)
 {
 	pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (destroy)",mp);
-	if (mp->hdw) pvr2_hdw_destroy(mp->hdw);
+	pvr2_hdw_destroy(mp->hdw);
 	pvr2_context_set_notify(mp, 0);
 	mutex_lock(&pvr2_context_mutex);
 	if (mp->exist_next) {
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 2c90186..3cab886 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1976,8 +1976,7 @@ static int s2255_release_sys_buffers(struct s2255_vc *vc)
 {
 	unsigned long i;
 	for (i = 0; i < SYS_FRAMES; i++) {
-		if (vc->buffer.frame[i].lpvbits)
-			vfree(vc->buffer.frame[i].lpvbits);
+		vfree(vc->buffer.frame[i].lpvbits);
 		vc->buffer.frame[i].lpvbits = NULL;
 	}
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] MTD: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 12:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 12:55 UTC (permalink / raw)
  To: Brian Norris, David Woodhouse, linux-mtd
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 13:50:43 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/chips/cfi_cmdset_0001.c | 3 +--
 drivers/mtd/devices/pmc551.c        | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 3096f3d..286b97a 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -2654,8 +2654,7 @@ static void cfi_intelext_destroy(struct mtd_info *mtd)
 	kfree(cfi);
 	for (i = 0; i < mtd->numeraseregions; i++) {
 		region = &mtd->eraseregions[i];
-		if (region->lockmap)
-			kfree(region->lockmap);
+		kfree(region->lockmap);
 	}
 	kfree(mtd->eraseregions);
 }
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index f02603e..708b7e8 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -812,8 +812,7 @@ static int __init init_pmc551(void)
 	}
 
 	/* Exited early, reference left over */
-	if (PCI_Device)
-		pci_dev_put(PCI_Device);
+	pci_dev_put(PCI_Device);
 
 	if (!pmc551list) {
 		printk(KERN_NOTICE "pmc551: not detected\n");
-- 
2.1.3


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

* [PATCH 1/1] MTD: Deletion of unnecessary checks before two function calls
@ 2014-11-20 12:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 12:55 UTC (permalink / raw)
  To: Brian Norris, David Woodhouse, linux-mtd
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 13:50:43 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/chips/cfi_cmdset_0001.c | 3 +--
 drivers/mtd/devices/pmc551.c        | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 3096f3d..286b97a 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -2654,8 +2654,7 @@ static void cfi_intelext_destroy(struct mtd_info *mtd)
 	kfree(cfi);
 	for (i = 0; i < mtd->numeraseregions; i++) {
 		region = &mtd->eraseregions[i];
-		if (region->lockmap)
-			kfree(region->lockmap);
+		kfree(region->lockmap);
 	}
 	kfree(mtd->eraseregions);
 }
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index f02603e..708b7e8 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -812,8 +812,7 @@ static int __init init_pmc551(void)
 	}
 
 	/* Exited early, reference left over */
-	if (PCI_Device)
-		pci_dev_put(PCI_Device);
+	pci_dev_put(PCI_Device);
 
 	if (!pmc551list) {
 		printk(KERN_NOTICE "pmc551: not detected\n");
-- 
2.1.3


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

* [PATCH 1/1] MTD: Deletion of unnecessary checks before two function calls
@ 2014-11-20 12:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 12:55 UTC (permalink / raw)
  To: Brian Norris, David Woodhouse, linux-mtd
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 13:50:43 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/chips/cfi_cmdset_0001.c | 3 +--
 drivers/mtd/devices/pmc551.c        | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 3096f3d..286b97a 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -2654,8 +2654,7 @@ static void cfi_intelext_destroy(struct mtd_info *mtd)
 	kfree(cfi);
 	for (i = 0; i < mtd->numeraseregions; i++) {
 		region = &mtd->eraseregions[i];
-		if (region->lockmap)
-			kfree(region->lockmap);
+		kfree(region->lockmap);
 	}
 	kfree(mtd->eraseregions);
 }
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index f02603e..708b7e8 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -812,8 +812,7 @@ static int __init init_pmc551(void)
 	}
 
 	/* Exited early, reference left over */
-	if (PCI_Device)
-		pci_dev_put(PCI_Device);
+	pci_dev_put(PCI_Device);
 
 	if (!pmc551list) {
 		printk(KERN_NOTICE "pmc551: not detected\n");
-- 
2.1.3

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

* [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 13:28                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:28 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:22:47 +0100

The of_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/ibm/emac/core.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 87bd953..3f3fba9 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2323,16 +2323,11 @@ static int emac_check_deps(struct emac_instance *dev,
 
 static void emac_put_deps(struct emac_instance *dev)
 {
-	if (dev->mal_dev)
-		of_dev_put(dev->mal_dev);
-	if (dev->zmii_dev)
-		of_dev_put(dev->zmii_dev);
-	if (dev->rgmii_dev)
-		of_dev_put(dev->rgmii_dev);
-	if (dev->mdio_dev)
-		of_dev_put(dev->mdio_dev);
-	if (dev->tah_dev)
-		of_dev_put(dev->tah_dev);
+	of_dev_put(dev->mal_dev);
+	of_dev_put(dev->zmii_dev);
+	of_dev_put(dev->rgmii_dev);
+	of_dev_put(dev->mdio_dev);
+	of_dev_put(dev->tah_dev);
 }
 
 static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action,
@@ -2371,8 +2366,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 	bus_unregister_notifier(&platform_bus_type, &emac_of_bus_notifier);
 	err = emac_check_deps(dev, deps) ? 0 : -ENODEV;
 	for (i = 0; i < EMAC_DEP_COUNT; i++) {
-		if (deps[i].node)
-			of_node_put(deps[i].node);
+		of_node_put(deps[i].node);
 		if (err && deps[i].ofdev)
 			of_dev_put(deps[i].ofdev);
 	}
@@ -2383,8 +2377,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 		dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev;
 		dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev;
 	}
-	if (deps[EMAC_DEP_PREV_IDX].ofdev)
-		of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
+	of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
 	return err;
 }
 
@@ -3113,8 +3106,7 @@ static void __exit emac_exit(void)
 
 	/* Destroy EMAC boot list */
 	for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++)
-		if (emac_boot_list[i])
-			of_node_put(emac_boot_list[i]);
+		of_node_put(emac_boot_list[i]);
 }
 
 module_init(emac_init);
-- 
2.1.3


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

* [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put"
@ 2014-11-20 13:28                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:28 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:22:47 +0100

The of_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/ibm/emac/core.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 87bd953..3f3fba9 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2323,16 +2323,11 @@ static int emac_check_deps(struct emac_instance *dev,
 
 static void emac_put_deps(struct emac_instance *dev)
 {
-	if (dev->mal_dev)
-		of_dev_put(dev->mal_dev);
-	if (dev->zmii_dev)
-		of_dev_put(dev->zmii_dev);
-	if (dev->rgmii_dev)
-		of_dev_put(dev->rgmii_dev);
-	if (dev->mdio_dev)
-		of_dev_put(dev->mdio_dev);
-	if (dev->tah_dev)
-		of_dev_put(dev->tah_dev);
+	of_dev_put(dev->mal_dev);
+	of_dev_put(dev->zmii_dev);
+	of_dev_put(dev->rgmii_dev);
+	of_dev_put(dev->mdio_dev);
+	of_dev_put(dev->tah_dev);
 }
 
 static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action,
@@ -2371,8 +2366,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 	bus_unregister_notifier(&platform_bus_type, &emac_of_bus_notifier);
 	err = emac_check_deps(dev, deps) ? 0 : -ENODEV;
 	for (i = 0; i < EMAC_DEP_COUNT; i++) {
-		if (deps[i].node)
-			of_node_put(deps[i].node);
+		of_node_put(deps[i].node);
 		if (err && deps[i].ofdev)
 			of_dev_put(deps[i].ofdev);
 	}
@@ -2383,8 +2377,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 		dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev;
 		dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev;
 	}
-	if (deps[EMAC_DEP_PREV_IDX].ofdev)
-		of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
+	of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
 	return err;
 }
 
@@ -3113,8 +3106,7 @@ static void __exit emac_exit(void)
 
 	/* Destroy EMAC boot list */
 	for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++)
-		if (emac_boot_list[i])
-			of_node_put(emac_boot_list[i]);
+		of_node_put(emac_boot_list[i]);
 }
 
 module_init(emac_init);
-- 
2.1.3


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

* [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put"
@ 2014-11-20 13:28                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:28 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:22:47 +0100

The of_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/ibm/emac/core.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 87bd953..3f3fba9 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2323,16 +2323,11 @@ static int emac_check_deps(struct emac_instance *dev,
 
 static void emac_put_deps(struct emac_instance *dev)
 {
-	if (dev->mal_dev)
-		of_dev_put(dev->mal_dev);
-	if (dev->zmii_dev)
-		of_dev_put(dev->zmii_dev);
-	if (dev->rgmii_dev)
-		of_dev_put(dev->rgmii_dev);
-	if (dev->mdio_dev)
-		of_dev_put(dev->mdio_dev);
-	if (dev->tah_dev)
-		of_dev_put(dev->tah_dev);
+	of_dev_put(dev->mal_dev);
+	of_dev_put(dev->zmii_dev);
+	of_dev_put(dev->rgmii_dev);
+	of_dev_put(dev->mdio_dev);
+	of_dev_put(dev->tah_dev);
 }
 
 static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action,
@@ -2371,8 +2366,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 	bus_unregister_notifier(&platform_bus_type, &emac_of_bus_notifier);
 	err = emac_check_deps(dev, deps) ? 0 : -ENODEV;
 	for (i = 0; i < EMAC_DEP_COUNT; i++) {
-		if (deps[i].node)
-			of_node_put(deps[i].node);
+		of_node_put(deps[i].node);
 		if (err && deps[i].ofdev)
 			of_dev_put(deps[i].ofdev);
 	}
@@ -2383,8 +2377,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 		dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev;
 		dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev;
 	}
-	if (deps[EMAC_DEP_PREV_IDX].ofdev)
-		of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
+	of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
 	return err;
 }
 
@@ -3113,8 +3106,7 @@ static void __exit emac_exit(void)
 
 	/* Destroy EMAC boot list */
 	for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++)
-		if (emac_boot_list[i])
-			of_node_put(emac_boot_list[i]);
+		of_node_put(emac_boot_list[i]);
 }
 
 module_init(emac_init);
-- 
2.1.3


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

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-20 13:50                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:50 UTC (permalink / raw)
  To: Michal Simek, netdev, linux-arm-kernel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:47:12 +0100

The functions kfree() and of_node_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/xilinx/ll_temac_main.c   | 3 +--
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index fda5891..af60867 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -224,8 +224,7 @@ static void temac_dma_bd_release(struct net_device *ndev)
 		dma_free_coherent(ndev->dev.parent,
 				sizeof(*lp->tx_bd_v) * TX_BD_NUM,
 				lp->tx_bd_v, lp->tx_bd_p);
-	if (lp->rx_skb)
-		kfree(lp->rx_skb);
+	kfree(lp->rx_skb);
 }
 
 /**
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 28dbbdc..2485879 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1200,8 +1200,7 @@ static int xemaclite_of_remove(struct platform_device *of_dev)
 
 	unregister_netdev(ndev);
 
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	lp->phy_node = NULL;
 
 	xemaclite_remove_ndev(ndev);
-- 
2.1.3


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

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
@ 2014-11-20 13:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:50 UTC (permalink / raw)
  To: Michal Simek, netdev, linux-arm-kernel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:47:12 +0100

The functions kfree() and of_node_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/xilinx/ll_temac_main.c   | 3 +--
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index fda5891..af60867 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -224,8 +224,7 @@ static void temac_dma_bd_release(struct net_device *ndev)
 		dma_free_coherent(ndev->dev.parent,
 				sizeof(*lp->tx_bd_v) * TX_BD_NUM,
 				lp->tx_bd_v, lp->tx_bd_p);
-	if (lp->rx_skb)
-		kfree(lp->rx_skb);
+	kfree(lp->rx_skb);
 }
 
 /**
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 28dbbdc..2485879 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1200,8 +1200,7 @@ static int xemaclite_of_remove(struct platform_device *of_dev)
 
 	unregister_netdev(ndev);
 
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	lp->phy_node = NULL;
 
 	xemaclite_remove_ndev(ndev);
-- 
2.1.3

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

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
@ 2014-11-20 13:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:47:12 +0100

The functions kfree() and of_node_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/xilinx/ll_temac_main.c   | 3 +--
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index fda5891..af60867 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -224,8 +224,7 @@ static void temac_dma_bd_release(struct net_device *ndev)
 		dma_free_coherent(ndev->dev.parent,
 				sizeof(*lp->tx_bd_v) * TX_BD_NUM,
 				lp->tx_bd_v, lp->tx_bd_p);
-	if (lp->rx_skb)
-		kfree(lp->rx_skb);
+	kfree(lp->rx_skb);
 }
 
 /**
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 28dbbdc..2485879 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1200,8 +1200,7 @@ static int xemaclite_of_remove(struct platform_device *of_dev)
 
 	unregister_netdev(ndev);
 
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	lp->phy_node = NULL;
 
 	xemaclite_remove_ndev(ndev);
-- 
2.1.3


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

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
@ 2014-11-20 13:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:47:12 +0100

The functions kfree() and of_node_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/xilinx/ll_temac_main.c   | 3 +--
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index fda5891..af60867 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -224,8 +224,7 @@ static void temac_dma_bd_release(struct net_device *ndev)
 		dma_free_coherent(ndev->dev.parent,
 				sizeof(*lp->tx_bd_v) * TX_BD_NUM,
 				lp->tx_bd_v, lp->tx_bd_p);
-	if (lp->rx_skb)
-		kfree(lp->rx_skb);
+	kfree(lp->rx_skb);
 }
 
 /**
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 28dbbdc..2485879 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1200,8 +1200,7 @@ static int xemaclite_of_remove(struct platform_device *of_dev)
 
 	unregister_netdev(ndev);
 
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	lp->phy_node = NULL;
 
 	xemaclite_remove_ndev(ndev);
-- 
2.1.3

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

* [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 14:25                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 14:25 UTC (permalink / raw)
  To: Haiyang Zhang, K. Y. Srinivasan, devel, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 15:15:21 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/hyperv/netvsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index da2d346..ffe7481 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -548,8 +548,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
+	vfree(net_device->sub_cb_buf);
 
 	kfree(net_device);
 	return 0;
-- 
2.1.3


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

* [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-20 14:25                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 14:25 UTC (permalink / raw)
  To: Haiyang Zhang, K. Y. Srinivasan, devel, netdev
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 15:15:21 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/hyperv/netvsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index da2d346..ffe7481 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -548,8 +548,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
+	vfree(net_device->sub_cb_buf);
 
 	kfree(net_device);
 	return 0;
-- 
2.1.3

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

* [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-20 14:25                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 14:25 UTC (permalink / raw)
  To: Haiyang Zhang, K. Y. Srinivasan, devel, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 15:15:21 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/hyperv/netvsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index da2d346..ffe7481 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -548,8 +548,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
+	vfree(net_device->sub_cb_buf);
 
 	kfree(net_device);
 	return 0;
-- 
2.1.3


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

* Re: [PATCH 1/1] crypto-drbg: Deletion of unnecessary checks before the function call "kzfree"
  2014-11-19  9:20                                   ` SF Markus Elfring
@ 2014-11-20 14:39                                     ` Herbert Xu
  -1 siblings, 0 replies; 3633+ messages in thread
From: Herbert Xu @ 2014-11-20 14:39 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, linux-crypto, Linux Kernel Mailing List,
	kernel-janitors, Julia Lawall

On Wed, Nov 19, 2014 at 10:20:32AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 10:11:04 +0100
> 
> The kzfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Sorry but you're too late as someone else has already fixed this :)

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH 1/1] crypto-drbg: Deletion of unnecessary checks before the function call "kzfree"
@ 2014-11-20 14:39                                     ` Herbert Xu
  0 siblings, 0 replies; 3633+ messages in thread
From: Herbert Xu @ 2014-11-20 14:39 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, linux-crypto, Linux Kernel Mailing List,
	kernel-janitors, Julia Lawall

On Wed, Nov 19, 2014 at 10:20:32AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 10:11:04 +0100
> 
> The kzfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Sorry but you're too late as someone else has already fixed this :)

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device"
  2014-11-20  9:55                                   ` [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregis SF Markus Elfring
@ 2014-11-20 14:41                                     ` Stefan Richter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Stefan Richter @ 2014-11-20 14:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Mauro Carvalho Chehab, linux-media, linux1394-devel, LKML,
	kernel-janitors, Julia Lawall

On Nov 20 SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 10:49:07 +0100
> 
> The dvb_unregister_device() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Reviewed-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

> ---
>  drivers/media/firewire/firedtv-ci.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/media/firewire/firedtv-ci.c b/drivers/media/firewire/firedtv-ci.c
> index e5ebdbf..e63f582 100644
> --- a/drivers/media/firewire/firedtv-ci.c
> +++ b/drivers/media/firewire/firedtv-ci.c
> @@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv)
>  
>  void fdtv_ca_release(struct firedtv *fdtv)
>  {
> -	if (fdtv->cadev)
> -		dvb_unregister_device(fdtv->cadev);
> +	dvb_unregister_device(fdtv->cadev);
>  }



-- 
Stefan Richter
-=====-====- =-== =-=--
http://arcgraph.de/sr/

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

* Re: [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unr
@ 2014-11-20 14:41                                     ` Stefan Richter
  0 siblings, 0 replies; 3633+ messages in thread
From: Stefan Richter @ 2014-11-20 14:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Mauro Carvalho Chehab, linux-media, linux1394-devel, LKML,
	kernel-janitors, Julia Lawall

On Nov 20 SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 10:49:07 +0100
> 
> The dvb_unregister_device() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Reviewed-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

> ---
>  drivers/media/firewire/firedtv-ci.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/media/firewire/firedtv-ci.c b/drivers/media/firewire/firedtv-ci.c
> index e5ebdbf..e63f582 100644
> --- a/drivers/media/firewire/firedtv-ci.c
> +++ b/drivers/media/firewire/firedtv-ci.c
> @@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv)
>  
>  void fdtv_ca_release(struct firedtv *fdtv)
>  {
> -	if (fdtv->cadev)
> -		dvb_unregister_device(fdtv->cadev);
> +	dvb_unregister_device(fdtv->cadev);
>  }



-- 
Stefan Richter
-===-==- =-= =-=--
http://arcgraph.de/sr/

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

* [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 15:16                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 15:16 UTC (permalink / raw)
  To: Jan Dumon, linux-usb, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:11:56 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/usb/asix_devices.c | 3 +--
 drivers/net/usb/hso.c          | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 5d19409..8a7582b 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -499,8 +499,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	if (dev->driver_priv)
-		kfree(dev->driver_priv);
+	kfree(dev->driver_priv);
 }
 
 static const struct ethtool_ops ax88178_ethtool_ops = {
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index babda7d..9c5aa92 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2746,8 +2746,7 @@ exit:
 		tty_unregister_device(tty_drv, serial->minor);
 		kfree(serial);
 	}
-	if (hso_dev)
-		kfree(hso_dev);
+	kfree(hso_dev);
 	return NULL;
 
 }
-- 
2.1.3


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

* [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree"
@ 2014-11-20 15:16                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 15:16 UTC (permalink / raw)
  To: Jan Dumon, linux-usb, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:11:56 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/usb/asix_devices.c | 3 +--
 drivers/net/usb/hso.c          | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 5d19409..8a7582b 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -499,8 +499,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	if (dev->driver_priv)
-		kfree(dev->driver_priv);
+	kfree(dev->driver_priv);
 }
 
 static const struct ethtool_ops ax88178_ethtool_ops = {
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index babda7d..9c5aa92 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2746,8 +2746,7 @@ exit:
 		tty_unregister_device(tty_drv, serial->minor);
 		kfree(serial);
 	}
-	if (hso_dev)
-		kfree(hso_dev);
+	kfree(hso_dev);
 	return NULL;
 
 }
-- 
2.1.3

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

* [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree"
@ 2014-11-20 15:16                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 15:16 UTC (permalink / raw)
  To: Jan Dumon, linux-usb, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:11:56 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/usb/asix_devices.c | 3 +--
 drivers/net/usb/hso.c          | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 5d19409..8a7582b 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -499,8 +499,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	if (dev->driver_priv)
-		kfree(dev->driver_priv);
+	kfree(dev->driver_priv);
 }
 
 static const struct ethtool_ops ax88178_ethtool_ops = {
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index babda7d..9c5aa92 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2746,8 +2746,7 @@ exit:
 		tty_unregister_device(tty_drv, serial->minor);
 		kfree(serial);
 	}
-	if (hso_dev)
-		kfree(hso_dev);
+	kfree(hso_dev);
 	return NULL;
 
 }
-- 
2.1.3


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

* [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 15:50                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 15:50 UTC (permalink / raw)
  To: Arend van Spriel, Brett Rudley, Franky (Zhenhui) Lin,
	Hante Meuleman, John W. Linville, linux-wireless,
	brcm80211-dev-list, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:42:51 +0100

The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether
their argument is NULL and then return immediately. Thus the test around
the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
 drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index f55f625..8ff7037 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
 	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
 
 	/* Clear any held glomming stuff */
-	if (bus->glomd)
-		brcmu_pkt_buf_free_skb(bus->glomd);
+	brcmu_pkt_buf_free_skb(bus->glomd);
 	brcmf_sdio_free_glom(bus);
 
 	/* Clear rx control and wake any waiters */
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
index 8ea9f28..3a2d014 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
@@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 
 fail:
 	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
-	if (fwctx->code)
-		release_firmware(fwctx->code);
+	release_firmware(fwctx->code);
 	device_release_driver(fwctx->dev);
 	kfree(fwctx);
 }
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
index 8f8b937..0cb00dc 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
@@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
 		memcpy(buf, skb->data, (len < msgbuf->ioctl_resp_ret_len) ?
 				       len : msgbuf->ioctl_resp_ret_len);
 	}
-	if (skb)
-		brcmu_pkt_buf_free_skb(skb);
+	brcmu_pkt_buf_free_skb(skb);
 
 	return msgbuf->ioctl_resp_status;
 }
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index 1b47482..ce538a1 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
 		if (txh)
 			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
 					   sizeof(*txh));
-		if (p)
-			brcmu_pkt_buf_free_skb(p);
+		brcmu_pkt_buf_free_skb(p);
 	}
 
 	if (dma && queue < NFIFO) {
-- 
2.1.3


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

* [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls
@ 2014-11-20 15:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 15:50 UTC (permalink / raw)
  To: Arend van Spriel, Brett Rudley, Franky (Zhenhui) Lin,
	Hante Meuleman, John W. Linville, linux-wireless,
	brcm80211-dev-list, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:42:51 +0100

The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether
their argument is NULL and then return immediately. Thus the test around
the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
 drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index f55f625..8ff7037 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
 	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
 
 	/* Clear any held glomming stuff */
-	if (bus->glomd)
-		brcmu_pkt_buf_free_skb(bus->glomd);
+	brcmu_pkt_buf_free_skb(bus->glomd);
 	brcmf_sdio_free_glom(bus);
 
 	/* Clear rx control and wake any waiters */
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
index 8ea9f28..3a2d014 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
@@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 
 fail:
 	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
-	if (fwctx->code)
-		release_firmware(fwctx->code);
+	release_firmware(fwctx->code);
 	device_release_driver(fwctx->dev);
 	kfree(fwctx);
 }
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
index 8f8b937..0cb00dc 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
@@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
 		memcpy(buf, skb->data, (len < msgbuf->ioctl_resp_ret_len) ?
 				       len : msgbuf->ioctl_resp_ret_len);
 	}
-	if (skb)
-		brcmu_pkt_buf_free_skb(skb);
+	brcmu_pkt_buf_free_skb(skb);
 
 	return msgbuf->ioctl_resp_status;
 }
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index 1b47482..ce538a1 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
 		if (txh)
 			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
 					   sizeof(*txh));
-		if (p)
-			brcmu_pkt_buf_free_skb(p);
+		brcmu_pkt_buf_free_skb(p);
 	}
 
 	if (dma && queue < NFIFO) {
-- 
2.1.3

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

* [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls
@ 2014-11-20 15:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 15:50 UTC (permalink / raw)
  To: Arend van Spriel, Brett Rudley, Franky (Zhenhui) Lin,
	Hante Meuleman, John W. Linville, linux-wireless,
	brcm80211-dev-list, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:42:51 +0100

The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether
their argument is NULL and then return immediately. Thus the test around
the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
 drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index f55f625..8ff7037 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
 	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
 
 	/* Clear any held glomming stuff */
-	if (bus->glomd)
-		brcmu_pkt_buf_free_skb(bus->glomd);
+	brcmu_pkt_buf_free_skb(bus->glomd);
 	brcmf_sdio_free_glom(bus);
 
 	/* Clear rx control and wake any waiters */
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
index 8ea9f28..3a2d014 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
@@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 
 fail:
 	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
-	if (fwctx->code)
-		release_firmware(fwctx->code);
+	release_firmware(fwctx->code);
 	device_release_driver(fwctx->dev);
 	kfree(fwctx);
 }
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
index 8f8b937..0cb00dc 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
@@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
 		memcpy(buf, skb->data, (len < msgbuf->ioctl_resp_ret_len) ?
 				       len : msgbuf->ioctl_resp_ret_len);
 	}
-	if (skb)
-		brcmu_pkt_buf_free_skb(skb);
+	brcmu_pkt_buf_free_skb(skb);
 
 	return msgbuf->ioctl_resp_status;
 }
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index 1b47482..ce538a1 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
 		if (txh)
 			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
 					   sizeof(*txh));
-		if (p)
-			brcmu_pkt_buf_free_skb(p);
+		brcmu_pkt_buf_free_skb(p);
 	}
 
 	if (dma && queue < NFIFO) {
-- 
2.1.3


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

* Re: crypto-drbg: Deletion of unnecessary checks before the function call "kzfree"
  2014-11-20 14:39                                     ` Herbert Xu
@ 2014-11-20 16:00                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 16:00 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, linux-crypto, Linux Kernel Mailing List,
	kernel-janitors, Julia Lawall

> Sorry but you're too late as someone else has already fixed this :)

Thanks for your feedback.

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/crypto/drbg.c?id=46f64f6ef978dc1f36ebaa50ed79c7c8386711ee

Regards,
Markus


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

* Re: crypto-drbg: Deletion of unnecessary checks before the function call "kzfree"
@ 2014-11-20 16:00                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 16:00 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, linux-crypto, Linux Kernel Mailing List,
	kernel-janitors, Julia Lawall

> Sorry but you're too late as someone else has already fixed this :)

Thanks for your feedback.

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/crypto/drbg.c?idFf64f6ef978dc1f36ebaa50ed79c7c8386711ee

Regards,
Markus


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

* [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-20 16:47                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 16:47 UTC (permalink / raw)
  To: Bjorn Helgaas, Scott Murray, linux-pci
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 17:42:23 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pci/hotplug/cpci_hotplug_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index e09cf78..82c969b 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -211,8 +211,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 
 	kfree(slot->hotplug_slot->info);
 	kfree(slot->hotplug_slot);
-	if (slot->dev)
-		pci_dev_put(slot->dev);
+	pci_dev_put(slot->dev);
 	kfree(slot);
 }
 
-- 
2.1.3


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

* [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-20 16:47                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 16:47 UTC (permalink / raw)
  To: Bjorn Helgaas, Scott Murray, linux-pci
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 17:42:23 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pci/hotplug/cpci_hotplug_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index e09cf78..82c969b 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -211,8 +211,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 
 	kfree(slot->hotplug_slot->info);
 	kfree(slot->hotplug_slot);
-	if (slot->dev)
-		pci_dev_put(slot->dev);
+	pci_dev_put(slot->dev);
 	kfree(slot);
 }
 
-- 
2.1.3


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

* [PATCH 1/1] SCSI-OSD: Deletion of an unnecessary check before the function call "put_disk"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 17:23                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 17:23 UTC (permalink / raw)
  To: Benny Halevy, Boaz Harrosh, James E. J. Bottomley, osd-dev, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 18:11:28 +0100

The put_disk() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/osd/osd_uld.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index e1d9a4c..3d82ee1 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -408,8 +408,7 @@ static void __remove(struct device *dev)
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
 
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
-- 
2.1.3


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

* [PATCH 1/1] SCSI-OSD: Deletion of an unnecessary check before the function call "put_disk"
@ 2014-11-20 17:23                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 17:23 UTC (permalink / raw)
  To: Benny Halevy, Boaz Harrosh, James E. J. Bottomley, osd-dev, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 18:11:28 +0100

The put_disk() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/osd/osd_uld.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index e1d9a4c..3d82ee1 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -408,8 +408,7 @@ static void __remove(struct device *dev)
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
 
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
-- 
2.1.3


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

* [PATCH 1/1] SCSI-OSD: Deletion of an unnecessary check before the function call "put_disk"
@ 2014-11-20 17:23                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 17:23 UTC (permalink / raw)
  To: Benny Halevy, Boaz Harrosh, James E. J. Bottomley, osd-dev, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 18:11:28 +0100

The put_disk() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/osd/osd_uld.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index e1d9a4c..3d82ee1 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -408,8 +408,7 @@ static void __remove(struct device *dev)
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
 
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
-- 
2.1.3

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

* Re: [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
  2014-11-20 13:50                                   ` SF Markus Elfring
  (?)
@ 2014-11-20 17:29                                     ` Sören Brinkmann
  -1 siblings, 0 replies; 3633+ messages in thread
From: Sören Brinkmann @ 2014-11-20 17:29 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Michal Simek, netdev, linux-arm-kernel, LKML, kernel-janitors,
	Julia Lawall

On Thu, 2014-11-20 at 02:50PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Soren Brinkmann <soren.brinkmann@xilinx.com>

	Sören

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

* Re: [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
@ 2014-11-20 17:29                                     ` Sören Brinkmann
  0 siblings, 0 replies; 3633+ messages in thread
From: Sören Brinkmann @ 2014-11-20 17:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2014-11-20 at 02:50PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Soren Brinkmann <soren.brinkmann@xilinx.com>

	Sören
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
@ 2014-11-20 17:29                                     ` Sören Brinkmann
  0 siblings, 0 replies; 3633+ messages in thread
From: Sören Brinkmann @ 2014-11-20 17:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2014-11-20 at 02:50PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Soren Brinkmann <soren.brinkmann@xilinx.com>

	S?ren

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

* [PATCH 1/1] SCSI: Deletion of unnecessary checks before the function call "put_device"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 17:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 17:55 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 18:48:52 +0100

The put_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/hosts.c      | 3 +--
 drivers/scsi/scsi_sysfs.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 6de80e3..57afb19 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -337,8 +337,7 @@ static void scsi_host_dev_release(struct device *dev)
 
 	kfree(shost->shost_data);
 
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 	kfree(shost);
 }
 
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 8b4105a..c977c99 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -426,8 +426,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
 	kfree(sdev->inquiry);
 	kfree(sdev);
 
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 }
 
 static void scsi_device_dev_release(struct device *dev)
-- 
2.1.3


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

* [PATCH 1/1] SCSI: Deletion of unnecessary checks before the function call "put_device"
@ 2014-11-20 17:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 17:55 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 18:48:52 +0100

The put_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/hosts.c      | 3 +--
 drivers/scsi/scsi_sysfs.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 6de80e3..57afb19 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -337,8 +337,7 @@ static void scsi_host_dev_release(struct device *dev)
 
 	kfree(shost->shost_data);
 
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 	kfree(shost);
 }
 
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 8b4105a..c977c99 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -426,8 +426,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
 	kfree(sdev->inquiry);
 	kfree(sdev);
 
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 }
 
 static void scsi_device_dev_release(struct device *dev)
-- 
2.1.3


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

* [PATCH 1/1] SCSI: Deletion of unnecessary checks before the function call "put_device"
@ 2014-11-20 17:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 17:55 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 18:48:52 +0100

The put_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/hosts.c      | 3 +--
 drivers/scsi/scsi_sysfs.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 6de80e3..57afb19 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -337,8 +337,7 @@ static void scsi_host_dev_release(struct device *dev)
 
 	kfree(shost->shost_data);
 
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 	kfree(shost);
 }
 
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 8b4105a..c977c99 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -426,8 +426,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
 	kfree(sdev->inquiry);
 	kfree(sdev);
 
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 }
 
 static void scsi_device_dev_release(struct device *dev)
-- 
2.1.3

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

* Re: [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls
  2014-11-20 15:50                                   ` SF Markus Elfring
  (?)
@ 2014-11-20 18:04                                     ` Arend van Spriel
  -1 siblings, 0 replies; 3633+ messages in thread
From: Arend van Spriel @ 2014-11-20 18:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Brett Rudley, Franky (Zhenhui) Lin, Hante Meuleman,
	John W. Linville, linux-wireless, brcm80211-dev-list, netdev,
	LKML, kernel-janitors, Julia Lawall

On 11/20/14 16:50, SF Markus Elfring wrote:
> From: Markus Elfring<elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 16:42:51 +0100
>
> The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether
> their argument is NULL and then return immediately. Thus the test around
> the call is not needed.
>
> This issue was detected by using the Coccinelle software.

Goodo for coccinelle and you for running it.

Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Markus Elfring<elfring@users.sourceforge.net>
> ---
>   drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
>   drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
>   drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
>   drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
>   4 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> index f55f625..8ff7037 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> @@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
>   	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
>
>   	/* Clear any held glomming stuff */
> -	if (bus->glomd)
> -		brcmu_pkt_buf_free_skb(bus->glomd);
> +	brcmu_pkt_buf_free_skb(bus->glomd);
>   	brcmf_sdio_free_glom(bus);
>
>   	/* Clear rx control and wake any waiters */
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> index 8ea9f28..3a2d014 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> @@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
>
>   fail:
>   	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
> -	if (fwctx->code)
> -		release_firmware(fwctx->code);
> +	release_firmware(fwctx->code);
>   	device_release_driver(fwctx->dev);
>   	kfree(fwctx);
>   }
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> index 8f8b937..0cb00dc 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> @@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
>   		memcpy(buf, skb->data, (len<  msgbuf->ioctl_resp_ret_len) ?
>   				       len : msgbuf->ioctl_resp_ret_len);
>   	}
> -	if (skb)
> -		brcmu_pkt_buf_free_skb(skb);
> +	brcmu_pkt_buf_free_skb(skb);
>
>   	return msgbuf->ioctl_resp_status;
>   }
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
> index 1b47482..ce538a1 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
> @@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
>   		if (txh)
>   			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
>   					   sizeof(*txh));
> -		if (p)
> -			brcmu_pkt_buf_free_skb(p);
> +		brcmu_pkt_buf_free_skb(p);
>   	}
>
>   	if (dma&&  queue<  NFIFO) {


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

* Re: [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls
@ 2014-11-20 18:04                                     ` Arend van Spriel
  0 siblings, 0 replies; 3633+ messages in thread
From: Arend van Spriel @ 2014-11-20 18:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Brett Rudley, Franky (Zhenhui) Lin, Hante Meuleman,
	John W. Linville, linux-wireless, brcm80211-dev-list, netdev,
	LKML, kernel-janitors, Julia Lawall

On 11/20/14 16:50, SF Markus Elfring wrote:
> From: Markus Elfring<elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 16:42:51 +0100
>
> The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether
> their argument is NULL and then return immediately. Thus the test around
> the call is not needed.
>
> This issue was detected by using the Coccinelle software.

Goodo for coccinelle and you for running it.

Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Markus Elfring<elfring@users.sourceforge.net>
> ---
>   drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
>   drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
>   drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
>   drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
>   4 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> index f55f625..8ff7037 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> @@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
>   	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
>
>   	/* Clear any held glomming stuff */
> -	if (bus->glomd)
> -		brcmu_pkt_buf_free_skb(bus->glomd);
> +	brcmu_pkt_buf_free_skb(bus->glomd);
>   	brcmf_sdio_free_glom(bus);
>
>   	/* Clear rx control and wake any waiters */
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> index 8ea9f28..3a2d014 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> @@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
>
>   fail:
>   	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
> -	if (fwctx->code)
> -		release_firmware(fwctx->code);
> +	release_firmware(fwctx->code);
>   	device_release_driver(fwctx->dev);
>   	kfree(fwctx);
>   }
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> index 8f8b937..0cb00dc 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> @@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
>   		memcpy(buf, skb->data, (len<  msgbuf->ioctl_resp_ret_len) ?
>   				       len : msgbuf->ioctl_resp_ret_len);
>   	}
> -	if (skb)
> -		brcmu_pkt_buf_free_skb(skb);
> +	brcmu_pkt_buf_free_skb(skb);
>
>   	return msgbuf->ioctl_resp_status;
>   }
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
> index 1b47482..ce538a1 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
> @@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
>   		if (txh)
>   			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
>   					   sizeof(*txh));
> -		if (p)
> -			brcmu_pkt_buf_free_skb(p);
> +		brcmu_pkt_buf_free_skb(p);
>   	}
>
>   	if (dma&&  queue<  NFIFO) {

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

* Re: [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls
@ 2014-11-20 18:04                                     ` Arend van Spriel
  0 siblings, 0 replies; 3633+ messages in thread
From: Arend van Spriel @ 2014-11-20 18:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Brett Rudley, Franky (Zhenhui) Lin, Hante Meuleman,
	John W. Linville, linux-wireless, brcm80211-dev-list, netdev,
	LKML, kernel-janitors, Julia Lawall

On 11/20/14 16:50, SF Markus Elfring wrote:
> From: Markus Elfring<elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 16:42:51 +0100
>
> The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether
> their argument is NULL and then return immediately. Thus the test around
> the call is not needed.
>
> This issue was detected by using the Coccinelle software.

Goodo for coccinelle and you for running it.

Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Markus Elfring<elfring@users.sourceforge.net>
> ---
>   drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
>   drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
>   drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
>   drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
>   4 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> index f55f625..8ff7037 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> @@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
>   	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
>
>   	/* Clear any held glomming stuff */
> -	if (bus->glomd)
> -		brcmu_pkt_buf_free_skb(bus->glomd);
> +	brcmu_pkt_buf_free_skb(bus->glomd);
>   	brcmf_sdio_free_glom(bus);
>
>   	/* Clear rx control and wake any waiters */
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> index 8ea9f28..3a2d014 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> @@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
>
>   fail:
>   	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
> -	if (fwctx->code)
> -		release_firmware(fwctx->code);
> +	release_firmware(fwctx->code);
>   	device_release_driver(fwctx->dev);
>   	kfree(fwctx);
>   }
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> index 8f8b937..0cb00dc 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> @@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
>   		memcpy(buf, skb->data, (len<  msgbuf->ioctl_resp_ret_len) ?
>   				       len : msgbuf->ioctl_resp_ret_len);
>   	}
> -	if (skb)
> -		brcmu_pkt_buf_free_skb(skb);
> +	brcmu_pkt_buf_free_skb(skb);
>
>   	return msgbuf->ioctl_resp_status;
>   }
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
> index 1b47482..ce538a1 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
> @@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
>   		if (txh)
>   			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
>   					   sizeof(*txh));
> -		if (p)
> -			brcmu_pkt_buf_free_skb(p);
> +		brcmu_pkt_buf_free_skb(p);
>   	}
>
>   	if (dma&&  queue<  NFIFO) {


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

* RE: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-20 14:25                                   ` SF Markus Elfring
  (?)
@ 2014-11-20 18:58                                     ` Haiyang Zhang
  -1 siblings, 0 replies; 3633+ messages in thread
From: Haiyang Zhang @ 2014-11-20 18:58 UTC (permalink / raw)
  To: SF Markus Elfring, KY Srinivasan, devel, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 964 bytes --]



> -----Original Message-----
> From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
> Sent: Thursday, November 20, 2014 9:25 AM
> To: Haiyang Zhang; KY Srinivasan; devel@linuxdriverproject.org;
> netdev@vger.kernel.org
> Cc: LKML; kernel-janitors@vger.kernel.org; Julia Lawall
> Subject: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check
> before the function call "vfree"
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 15:15:21 +0100
> 
> The vfree() function performs also input parameter validation. Thus the
> test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Thanks!

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* RE: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-20 18:58                                     ` Haiyang Zhang
  0 siblings, 0 replies; 3633+ messages in thread
From: Haiyang Zhang @ 2014-11-20 18:58 UTC (permalink / raw)
  To: SF Markus Elfring, KY Srinivasan, devel, netdev
  Cc: LKML, kernel-janitors, Julia Lawall



> -----Original Message-----
> From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
> Sent: Thursday, November 20, 2014 9:25 AM
> To: Haiyang Zhang; KY Srinivasan; devel@linuxdriverproject.org;
> netdev@vger.kernel.org
> Cc: LKML; kernel-janitors@vger.kernel.org; Julia Lawall
> Subject: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check
> before the function call "vfree"
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 15:15:21 +0100
> 
> The vfree() function performs also input parameter validation. Thus the
> test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Thanks!


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

* RE: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-20 18:58                                     ` Haiyang Zhang
  0 siblings, 0 replies; 3633+ messages in thread
From: Haiyang Zhang @ 2014-11-20 18:58 UTC (permalink / raw)
  To: SF Markus Elfring, KY Srinivasan, devel, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogU0YgTWFya3VzIEVsZnJp
bmcgW21haWx0bzplbGZyaW5nQHVzZXJzLnNvdXJjZWZvcmdlLm5ldF0NCj4gU2VudDogVGh1cnNk
YXksIE5vdmVtYmVyIDIwLCAyMDE0IDk6MjUgQU0NCj4gVG86IEhhaXlhbmcgWmhhbmc7IEtZIFNy
aW5pdmFzYW47IGRldmVsQGxpbnV4ZHJpdmVycHJvamVjdC5vcmc7DQo+IG5ldGRldkB2Z2VyLmtl
cm5lbC5vcmcNCj4gQ2M6IExLTUw7IGtlcm5lbC1qYW5pdG9yc0B2Z2VyLmtlcm5lbC5vcmc7IEp1
bGlhIExhd2FsbA0KPiBTdWJqZWN0OiBbUEFUQ0ggMS8xXSBuZXQ6IEh5cGVyLVY6IERlbGV0aW9u
IG9mIGFuIHVubmVjZXNzYXJ5IGNoZWNrDQo+IGJlZm9yZSB0aGUgZnVuY3Rpb24gY2FsbCAidmZy
ZWUiDQo+IA0KPiBGcm9tOiBNYXJrdXMgRWxmcmluZyA8ZWxmcmluZ0B1c2Vycy5zb3VyY2Vmb3Jn
ZS5uZXQ+DQo+IERhdGU6IFRodSwgMjAgTm92IDIwMTQgMTU6MTU6MjEgKzAxMDANCj4gDQo+IFRo
ZSB2ZnJlZSgpIGZ1bmN0aW9uIHBlcmZvcm1zIGFsc28gaW5wdXQgcGFyYW1ldGVyIHZhbGlkYXRp
b24uIFRodXMgdGhlDQo+IHRlc3QNCj4gYXJvdW5kIHRoZSBjYWxsIGlzIG5vdCBuZWVkZWQuDQo+
IA0KPiBUaGlzIGlzc3VlIHdhcyBkZXRlY3RlZCBieSB1c2luZyB0aGUgQ29jY2luZWxsZSBzb2Z0
d2FyZS4NCj4gDQo+IFNpZ25lZC1vZmYtYnk6IE1hcmt1cyBFbGZyaW5nIDxlbGZyaW5nQHVzZXJz
LnNvdXJjZWZvcmdlLm5ldD4NCg0KU2lnbmVkLW9mZi1ieTogSGFpeWFuZyBaaGFuZyA8aGFpeWFu
Z3pAbWljcm9zb2Z0LmNvbT4NCg0KVGhhbmtzIQ0KDQo

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

* [PATCH 1/1] SCSI-libfc: Deletion of an unnecessary check before the function call "fc_fcp_ddp_done"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 19:15                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 19:15 UTC (permalink / raw)
  To: James E. J. Bottomley, Robert Love, fcoe-devel, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 20:10:19 +0100

The fc_fcp_ddp_done() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/libfc/fc_exch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 1b3a094..aad6f48 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -2120,8 +2120,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
 	spin_unlock_bh(&ep->ex_lock);
 	return sp;
 err:
-	if (fsp)
-		fc_fcp_ddp_done(fsp);
+	fc_fcp_ddp_done(fsp);
 	rc = fc_exch_done_locked(ep);
 	spin_unlock_bh(&ep->ex_lock);
 	if (!rc)
-- 
2.1.3


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

* [PATCH 1/1] SCSI-libfc: Deletion of an unnecessary check before the function call "fc_fcp_ddp_done"
@ 2014-11-20 19:15                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 19:15 UTC (permalink / raw)
  To: James E. J. Bottomley, Robert Love, fcoe-devel, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 20:10:19 +0100

The fc_fcp_ddp_done() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/libfc/fc_exch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 1b3a094..aad6f48 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -2120,8 +2120,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
 	spin_unlock_bh(&ep->ex_lock);
 	return sp;
 err:
-	if (fsp)
-		fc_fcp_ddp_done(fsp);
+	fc_fcp_ddp_done(fsp);
 	rc = fc_exch_done_locked(ep);
 	spin_unlock_bh(&ep->ex_lock);
 	if (!rc)
-- 
2.1.3


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

* [PATCH 1/1] SCSI-libfc: Deletion of an unnecessary check before the function call "fc_fcp_ddp_done"
@ 2014-11-20 19:15                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 19:15 UTC (permalink / raw)
  To: James E. J. Bottomley, Robert Love, fcoe-devel, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 20:10:19 +0100

The fc_fcp_ddp_done() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/libfc/fc_exch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 1b3a094..aad6f48 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -2120,8 +2120,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
 	spin_unlock_bh(&ep->ex_lock);
 	return sp;
 err:
-	if (fsp)
-		fc_fcp_ddp_done(fsp);
+	fc_fcp_ddp_done(fsp);
 	rc = fc_exch_done_locked(ep);
 	spin_unlock_bh(&ep->ex_lock);
 	if (!rc)
-- 
2.1.3

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

* [PATCH 1/1] SCSI-eata_pio: Deletion of an unnecessary check before the function call "pci_dev_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 19:42                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 19:42 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 20:37:30 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/eata_pio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index 8319d2b..707f64d 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -122,8 +122,7 @@ static int eata_pio_release(struct Scsi_Host *sh)
 			release_region(sh->io_port, sh->n_io_port);
 	}
 	/* At this point the PCI reference can go */
-	if (hd->pdev)
-		pci_dev_put(hd->pdev);
+	pci_dev_put(hd->pdev);
 	return 1;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] SCSI-eata_pio: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-20 19:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 19:42 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 20:37:30 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/eata_pio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index 8319d2b..707f64d 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -122,8 +122,7 @@ static int eata_pio_release(struct Scsi_Host *sh)
 			release_region(sh->io_port, sh->n_io_port);
 	}
 	/* At this point the PCI reference can go */
-	if (hd->pdev)
-		pci_dev_put(hd->pdev);
+	pci_dev_put(hd->pdev);
 	return 1;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] SCSI-eata_pio: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-20 19:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 19:42 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 20:37:30 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/eata_pio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index 8319d2b..707f64d 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -122,8 +122,7 @@ static int eata_pio_release(struct Scsi_Host *sh)
 			release_region(sh->io_port, sh->n_io_port);
 	}
 	/* At this point the PCI reference can go */
-	if (hd->pdev)
-		pci_dev_put(hd->pdev);
+	pci_dev_put(hd->pdev);
 	return 1;
 }
 
-- 
2.1.3

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

* [PATCH 1/1] SCSI-aic94xx: Deletion of an unnecessary check before the function call "kfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 22:23                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 22:23 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 23:18:56 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aic94xx/aic94xx_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index c56741f..0bfdcba 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -597,8 +597,7 @@ static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
 	if (asd_ha->hw_prof.scb_ext)
 		asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext);
 
-	if (asd_ha->hw_prof.ddb_bitmap)
-		kfree(asd_ha->hw_prof.ddb_bitmap);
+	kfree(asd_ha->hw_prof.ddb_bitmap);
 	asd_ha->hw_prof.ddb_bitmap = NULL;
 
 	for (i = 0; i < ASD_MAX_PHYS; i++) {
-- 
2.1.3


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

* [PATCH 1/1] SCSI-aic94xx: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-20 22:23                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 22:23 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 23:18:56 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aic94xx/aic94xx_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index c56741f..0bfdcba 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -597,8 +597,7 @@ static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
 	if (asd_ha->hw_prof.scb_ext)
 		asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext);
 
-	if (asd_ha->hw_prof.ddb_bitmap)
-		kfree(asd_ha->hw_prof.ddb_bitmap);
+	kfree(asd_ha->hw_prof.ddb_bitmap);
 	asd_ha->hw_prof.ddb_bitmap = NULL;
 
 	for (i = 0; i < ASD_MAX_PHYS; i++) {
-- 
2.1.3


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

* [PATCH 1/1] SCSI-aic94xx: Deletion of an unnecessary check before the function call "kfree"
@ 2014-11-20 22:23                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 22:23 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 23:18:56 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aic94xx/aic94xx_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index c56741f..0bfdcba 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -597,8 +597,7 @@ static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
 	if (asd_ha->hw_prof.scb_ext)
 		asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext);
 
-	if (asd_ha->hw_prof.ddb_bitmap)
-		kfree(asd_ha->hw_prof.ddb_bitmap);
+	kfree(asd_ha->hw_prof.ddb_bitmap);
 	asd_ha->hw_prof.ddb_bitmap = NULL;
 
 	for (i = 0; i < ASD_MAX_PHYS; i++) {
-- 
2.1.3

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

* [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-20 22:46                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 22:46 UTC (permalink / raw)
  To: Anil Gurumurthy, James E. J. Bottomley, Sudarsana Kalluru, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 23:43:17 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/bfa/bfad_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
index 8e83d04..a72170f 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -399,8 +399,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file)
 	if (!fw_debug)
 		return 0;
 
-	if (fw_debug->debug_buffer)
-		vfree(fw_debug->debug_buffer);
+	vfree(fw_debug->debug_buffer);
 
 	file->private_data = NULL;
 	kfree(fw_debug);
-- 
2.1.3


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

* [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-20 22:46                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 22:46 UTC (permalink / raw)
  To: Anil Gurumurthy, James E. J. Bottomley, Sudarsana Kalluru, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 23:43:17 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/bfa/bfad_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
index 8e83d04..a72170f 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -399,8 +399,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file)
 	if (!fw_debug)
 		return 0;
 
-	if (fw_debug->debug_buffer)
-		vfree(fw_debug->debug_buffer);
+	vfree(fw_debug->debug_buffer);
 
 	file->private_data = NULL;
 	kfree(fw_debug);
-- 
2.1.3


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

* [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-20 22:46                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-20 22:46 UTC (permalink / raw)
  To: Anil Gurumurthy, James E. J. Bottomley, Sudarsana Kalluru, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 23:43:17 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/bfa/bfad_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
index 8e83d04..a72170f 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -399,8 +399,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file)
 	if (!fw_debug)
 		return 0;
 
-	if (fw_debug->debug_buffer)
-		vfree(fw_debug->debug_buffer);
+	vfree(fw_debug->debug_buffer);
 
 	file->private_data = NULL;
 	kfree(fw_debug);
-- 
2.1.3

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

* RE: [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"
  2014-11-20 22:46                                   ` SF Markus Elfring
@ 2014-11-21  4:20                                     ` Anil Gurumurthy
  -1 siblings, 0 replies; 3633+ messages in thread
From: Anil Gurumurthy @ 2014-11-21  4:20 UTC (permalink / raw)
  To: SF Markus Elfring, James E. J. Bottomley, Sudarsana Kalluru, linux-scsi
  Cc: linux-kernel, kernel-janitors, Julia Lawall

Patch looks good. 
Thanks!
Acked-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>

-----Original Message-----
From: SF Markus Elfring [mailto:elfring@users.sourceforge.net] 
Sent: 21 November 2014 04:17
To: Anil Gurumurthy; James E. J. Bottomley; Sudarsana Kalluru; linux-scsi
Cc: linux-kernel; kernel-janitors@vger.kernel.org; Julia Lawall
Subject: [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 23:43:17 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/bfa/bfad_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c index 8e83d04..a72170f 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -399,8 +399,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file)
 	if (!fw_debug)
 		return 0;
 
-	if (fw_debug->debug_buffer)
-		vfree(fw_debug->debug_buffer);
+	vfree(fw_debug->debug_buffer);
 
 	file->private_data = NULL;
 	kfree(fw_debug);
--
2.1.3


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

* RE: [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-21  4:20                                     ` Anil Gurumurthy
  0 siblings, 0 replies; 3633+ messages in thread
From: Anil Gurumurthy @ 2014-11-21  4:20 UTC (permalink / raw)
  To: SF Markus Elfring, James E. J. Bottomley, Sudarsana Kalluru, linux-scsi
  Cc: linux-kernel, kernel-janitors, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 1355 bytes --]

Patch looks good. 
Thanks!
Acked-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>

-----Original Message-----
From: SF Markus Elfring [mailto:elfring@users.sourceforge.net] 
Sent: 21 November 2014 04:17
To: Anil Gurumurthy; James E. J. Bottomley; Sudarsana Kalluru; linux-scsi
Cc: linux-kernel; kernel-janitors@vger.kernel.org; Julia Lawall
Subject: [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 23:43:17 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/bfa/bfad_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c index 8e83d04..a72170f 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -399,8 +399,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file)
 	if (!fw_debug)
 		return 0;
 
-	if (fw_debug->debug_buffer)
-		vfree(fw_debug->debug_buffer);
+	vfree(fw_debug->debug_buffer);
 
 	file->private_data = NULL;
 	kfree(fw_debug);
--
2.1.3


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 6080 bytes --]

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

* [PATCH 1/1] SCSI-libcxgbi: Deletion of an unnecessary check before the function call "dst_release"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-21  8:20                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21  8:20 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 09:15:10 +0100

The dst_release() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/cxgbi/libcxgbi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index addd1dd..95d2654 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -798,8 +798,7 @@ void cxgbi_sock_closed(struct cxgbi_sock *csk)
 		return;
 	if (csk->saddr.sin_port)
 		sock_put_port(csk);
-	if (csk->dst)
-		dst_release(csk->dst);
+	dst_release(csk->dst);
 	csk->cdev->csk_release_offload_resources(csk);
 	cxgbi_sock_set_state(csk, CTP_CLOSED);
 	cxgbi_inform_iscsi_conn_closing(csk);
-- 
2.1.3


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

* [PATCH 1/1] SCSI-libcxgbi: Deletion of an unnecessary check before the function call "dst_release"
@ 2014-11-21  8:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21  8:20 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 09:15:10 +0100

The dst_release() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/cxgbi/libcxgbi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index addd1dd..95d2654 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -798,8 +798,7 @@ void cxgbi_sock_closed(struct cxgbi_sock *csk)
 		return;
 	if (csk->saddr.sin_port)
 		sock_put_port(csk);
-	if (csk->dst)
-		dst_release(csk->dst);
+	dst_release(csk->dst);
 	csk->cdev->csk_release_offload_resources(csk);
 	cxgbi_sock_set_state(csk, CTP_CLOSED);
 	cxgbi_inform_iscsi_conn_closing(csk);
-- 
2.1.3


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

* [PATCH 1/1] SCSI-libcxgbi: Deletion of an unnecessary check before the function call "dst_release"
@ 2014-11-21  8:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21  8:20 UTC (permalink / raw)
  To: James E. J. Bottomley, linux-scsi; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 09:15:10 +0100

The dst_release() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/cxgbi/libcxgbi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index addd1dd..95d2654 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -798,8 +798,7 @@ void cxgbi_sock_closed(struct cxgbi_sock *csk)
 		return;
 	if (csk->saddr.sin_port)
 		sock_put_port(csk);
-	if (csk->dst)
-		dst_release(csk->dst);
+	dst_release(csk->dst);
 	csk->cdev->csk_release_offload_resources(csk);
 	cxgbi_sock_set_state(csk, CTP_CLOSED);
 	cxgbi_inform_iscsi_conn_closing(csk);
-- 
2.1.3

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

* [PATCH 1/1] SCSI-fnic: Deletion of an unnecessary check before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-21  8:45                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21  8:45 UTC (permalink / raw)
  To: Brian Uchino, Hiral Patel, James E. J. Bottomley, Suma Ramars,
	linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 09:39:43 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/fnic/fnic_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index 2c613bd..ec70e6d 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -102,8 +102,7 @@ void fnic_debugfs_terminate(void)
 	debugfs_remove(fnic_trace_debugfs_root);
 	fnic_trace_debugfs_root = NULL;
 
-	if (fc_trc_flag)
-		vfree(fc_trc_flag);
+	vfree(fc_trc_flag);
 }
 
 /*
-- 
2.1.3


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

* [PATCH 1/1] SCSI-fnic: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-21  8:45                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21  8:45 UTC (permalink / raw)
  To: Brian Uchino, Hiral Patel, James E. J. Bottomley, Suma Ramars,
	linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 09:39:43 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/fnic/fnic_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index 2c613bd..ec70e6d 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -102,8 +102,7 @@ void fnic_debugfs_terminate(void)
 	debugfs_remove(fnic_trace_debugfs_root);
 	fnic_trace_debugfs_root = NULL;
 
-	if (fc_trc_flag)
-		vfree(fc_trc_flag);
+	vfree(fc_trc_flag);
 }
 
 /*
-- 
2.1.3


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

* [PATCH 1/1] SCSI-fnic: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-21  8:45                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21  8:45 UTC (permalink / raw)
  To: Brian Uchino, Hiral Patel, James E. J. Bottomley, Suma Ramars,
	linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 09:39:43 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/fnic/fnic_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index 2c613bd..ec70e6d 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -102,8 +102,7 @@ void fnic_debugfs_terminate(void)
 	debugfs_remove(fnic_trace_debugfs_root);
 	fnic_trace_debugfs_root = NULL;
 
-	if (fc_trc_flag)
-		vfree(fc_trc_flag);
+	vfree(fc_trc_flag);
 }
 
 /*
-- 
2.1.3

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

* [PATCH 1/1] target: Deletion of unnecessary checks before the function call "module_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-21  9:30                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21  9:30 UTC (permalink / raw)
  To: Nicholas A. Bellinger, target-devel, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 10:25:45 +0100

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_transport.c | 3 +--
 drivers/target/target_core_hba.c              | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_transport.c b/drivers/target/iscsi/iscsi_target_transport.c
index 882728f..08217d6 100644
--- a/drivers/target/iscsi/iscsi_target_transport.c
+++ b/drivers/target/iscsi/iscsi_target_transport.c
@@ -26,8 +26,7 @@ struct iscsit_transport *iscsit_get_transport(int type)
 
 void iscsit_put_transport(struct iscsit_transport *t)
 {
-	if (t->owner)
-		module_put(t->owner);
+	module_put(t->owner);
 }
 
 int iscsit_register_transport(struct iscsit_transport *t)
diff --git a/drivers/target/target_core_hba.c b/drivers/target/target_core_hba.c
index a25051a..e6e496f 100644
--- a/drivers/target/target_core_hba.c
+++ b/drivers/target/target_core_hba.c
@@ -137,8 +137,7 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags)
 	return hba;
 
 out_module_put:
-	if (hba->transport->owner)
-		module_put(hba->transport->owner);
+	module_put(hba->transport->owner);
 	hba->transport = NULL;
 out_free_hba:
 	kfree(hba);
@@ -159,8 +158,7 @@ core_delete_hba(struct se_hba *hba)
 	pr_debug("CORE_HBA[%d] - Detached HBA from Generic Target"
 			" Core\n", hba->hba_id);
 
-	if (hba->transport->owner)
-		module_put(hba->transport->owner);
+	module_put(hba->transport->owner);
 
 	hba->transport = NULL;
 	kfree(hba);
-- 
2.1.3


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

* [PATCH 1/1] target: Deletion of unnecessary checks before the function call "module_put"
@ 2014-11-21  9:30                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21  9:30 UTC (permalink / raw)
  To: Nicholas A. Bellinger, target-devel, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 10:25:45 +0100

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_transport.c | 3 +--
 drivers/target/target_core_hba.c              | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_transport.c b/drivers/target/iscsi/iscsi_target_transport.c
index 882728f..08217d6 100644
--- a/drivers/target/iscsi/iscsi_target_transport.c
+++ b/drivers/target/iscsi/iscsi_target_transport.c
@@ -26,8 +26,7 @@ struct iscsit_transport *iscsit_get_transport(int type)
 
 void iscsit_put_transport(struct iscsit_transport *t)
 {
-	if (t->owner)
-		module_put(t->owner);
+	module_put(t->owner);
 }
 
 int iscsit_register_transport(struct iscsit_transport *t)
diff --git a/drivers/target/target_core_hba.c b/drivers/target/target_core_hba.c
index a25051a..e6e496f 100644
--- a/drivers/target/target_core_hba.c
+++ b/drivers/target/target_core_hba.c
@@ -137,8 +137,7 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags)
 	return hba;
 
 out_module_put:
-	if (hba->transport->owner)
-		module_put(hba->transport->owner);
+	module_put(hba->transport->owner);
 	hba->transport = NULL;
 out_free_hba:
 	kfree(hba);
@@ -159,8 +158,7 @@ core_delete_hba(struct se_hba *hba)
 	pr_debug("CORE_HBA[%d] - Detached HBA from Generic Target"
 			" Core\n", hba->hba_id);
 
-	if (hba->transport->owner)
-		module_put(hba->transport->owner);
+	module_put(hba->transport->owner);
 
 	hba->transport = NULL;
 	kfree(hba);
-- 
2.1.3


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

* [PATCH 1/1] target: Deletion of unnecessary checks before the function call "module_put"
@ 2014-11-21  9:30                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21  9:30 UTC (permalink / raw)
  To: Nicholas A. Bellinger, target-devel, linux-scsi
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 10:25:45 +0100

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_transport.c | 3 +--
 drivers/target/target_core_hba.c              | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_transport.c b/drivers/target/iscsi/iscsi_target_transport.c
index 882728f..08217d6 100644
--- a/drivers/target/iscsi/iscsi_target_transport.c
+++ b/drivers/target/iscsi/iscsi_target_transport.c
@@ -26,8 +26,7 @@ struct iscsit_transport *iscsit_get_transport(int type)
 
 void iscsit_put_transport(struct iscsit_transport *t)
 {
-	if (t->owner)
-		module_put(t->owner);
+	module_put(t->owner);
 }
 
 int iscsit_register_transport(struct iscsit_transport *t)
diff --git a/drivers/target/target_core_hba.c b/drivers/target/target_core_hba.c
index a25051a..e6e496f 100644
--- a/drivers/target/target_core_hba.c
+++ b/drivers/target/target_core_hba.c
@@ -137,8 +137,7 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags)
 	return hba;
 
 out_module_put:
-	if (hba->transport->owner)
-		module_put(hba->transport->owner);
+	module_put(hba->transport->owner);
 	hba->transport = NULL;
 out_free_hba:
 	kfree(hba);
@@ -159,8 +158,7 @@ core_delete_hba(struct se_hba *hba)
 	pr_debug("CORE_HBA[%d] - Detached HBA from Generic Target"
 			" Core\n", hba->hba_id);
 
-	if (hba->transport->owner)
-		module_put(hba->transport->owner);
+	module_put(hba->transport->owner);
 
 	hba->transport = NULL;
 	kfree(hba);
-- 
2.1.3

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

* [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-21 10:12                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 10:12 UTC (permalink / raw)
  To: Eduardo Valentin, Kukjin Kim, Zhang Rui, linux-pm,
	linux-arm-kernel, linux-samsung-soc
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 11:06:33 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
test whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..1cbb9d0 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
 	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 
 	dev_info(sensor_conf->dev,
-- 
2.1.3


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

* [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 10:12                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 10:12 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 11:06:33 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
test whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..1cbb9d0 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
 	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 
 	dev_info(sensor_conf->dev,
-- 
2.1.3


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

* [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 10:12                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 10:12 UTC (permalink / raw)
  To: Eduardo Valentin, Kukjin Kim, Zhang Rui, linux-pm,
	linux-arm-kernel, linux-samsung-soc
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 11:06:33 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
test whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..1cbb9d0 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
 	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 
 	dev_info(sensor_conf->dev,
-- 
2.1.3


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

* [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 10:12                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 10:12 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 11:06:33 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
test whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..1cbb9d0 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
 	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 
 	dev_info(sensor_conf->dev,
-- 
2.1.3

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

* Re: [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls
  2014-11-21 10:12                                   ` SF Markus Elfring
  (?)
@ 2014-11-21 10:17                                     ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-21 10:17 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Eduardo Valentin, Kukjin Kim, Zhang Rui, linux-pm,
	linux-arm-kernel, linux-samsung-soc, LKML, kernel-janitors

On Fri, 21 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 11:06:33 +0100
>
> The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
> test whether their argument is NULL and then return immediately.
> Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
> index 3f5ad25..1cbb9d0 100644
> --- a/drivers/thermal/samsung/exynos_thermal_common.c
> +++ b/drivers/thermal/samsung/exynos_thermal_common.c
> @@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
>
>  	th_zone = sensor_conf->pzone_data;
>
> -	if (th_zone->therm_dev)
> -		thermal_zone_device_unregister(th_zone->therm_dev);
> +	thermal_zone_device_unregister(th_zone->therm_dev);
>
>  	for (i = 0; i < th_zone->cool_dev_size; i++) {
> -		if (th_zone->cool_dev[i])
> -			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
> +		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>  	}

Now you have unnecessary {}

julia

>
>  	dev_info(sensor_conf->dev,
> --
> 2.1.3
>
>

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

* Re: [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 10:17                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-21 10:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 21 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 11:06:33 +0100
>
> The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
> test whether their argument is NULL and then return immediately.
> Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
> index 3f5ad25..1cbb9d0 100644
> --- a/drivers/thermal/samsung/exynos_thermal_common.c
> +++ b/drivers/thermal/samsung/exynos_thermal_common.c
> @@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
>
>  	th_zone = sensor_conf->pzone_data;
>
> -	if (th_zone->therm_dev)
> -		thermal_zone_device_unregister(th_zone->therm_dev);
> +	thermal_zone_device_unregister(th_zone->therm_dev);
>
>  	for (i = 0; i < th_zone->cool_dev_size; i++) {
> -		if (th_zone->cool_dev[i])
> -			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
> +		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>  	}

Now you have unnecessary {}

julia

>
>  	dev_info(sensor_conf->dev,
> --
> 2.1.3
>
>

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

* [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 10:17                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-21 10:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 21 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 11:06:33 +0100
>
> The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
> test whether their argument is NULL and then return immediately.
> Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
> index 3f5ad25..1cbb9d0 100644
> --- a/drivers/thermal/samsung/exynos_thermal_common.c
> +++ b/drivers/thermal/samsung/exynos_thermal_common.c
> @@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
>
>  	th_zone = sensor_conf->pzone_data;
>
> -	if (th_zone->therm_dev)
> -		thermal_zone_device_unregister(th_zone->therm_dev);
> +	thermal_zone_device_unregister(th_zone->therm_dev);
>
>  	for (i = 0; i < th_zone->cool_dev_size; i++) {
> -		if (th_zone->cool_dev[i])
> -			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
> +		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>  	}

Now you have unnecessary {}

julia

>
>  	dev_info(sensor_conf->dev,
> --
> 2.1.3
>
>

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

* [PATCH 1/1] thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-21 10:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 10:40 UTC (permalink / raw)
  To: Andreas Noever; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 11:30:18 +0100

The ring_free() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thunderbolt/ctl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index 799634b..55b9bdf 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -520,10 +520,8 @@ err:
 void tb_ctl_free(struct tb_ctl *ctl)
 {
 	int i;
-	if (ctl->rx)
-		ring_free(ctl->rx);
-	if (ctl->tx)
-		ring_free(ctl->tx);
+	ring_free(ctl->rx);
+	ring_free(ctl->tx);
 
 	/* free RX packets */
 	for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
-- 
2.1.3


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

* [PATCH 1/1] thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-21 10:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 10:40 UTC (permalink / raw)
  To: Andreas Noever; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 11:30:18 +0100

The ring_free() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thunderbolt/ctl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index 799634b..55b9bdf 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -520,10 +520,8 @@ err:
 void tb_ctl_free(struct tb_ctl *ctl)
 {
 	int i;
-	if (ctl->rx)
-		ring_free(ctl->rx);
-	if (ctl->tx)
-		ring_free(ctl->tx);
+	ring_free(ctl->rx);
+	ring_free(ctl->tx);
 
 	/* free RX packets */
 	for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
-- 
2.1.3


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

* Re: [PATCH 1/1] thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-21 10:40                                   ` SF Markus Elfring
@ 2014-11-21 11:29                                     ` Andreas Noever
  -1 siblings, 0 replies; 3633+ messages in thread
From: Andreas Noever @ 2014-11-21 11:29 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

Hi Markus,

ring_free does not check for null:
http://lxr.free-electrons.com/source/drivers/thunderbolt/nhi.c#L398

Maybe your software confuses the method with:
http://lxr.free-electrons.com/source/drivers/char/tpm/xen-tpmfront.c#L268

Andreas

On Fri, Nov 21, 2014 at 11:40 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 11:30:18 +0100
>
> The ring_free() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/thunderbolt/ctl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
> index 799634b..55b9bdf 100644
> --- a/drivers/thunderbolt/ctl.c
> +++ b/drivers/thunderbolt/ctl.c
> @@ -520,10 +520,8 @@ err:
>  void tb_ctl_free(struct tb_ctl *ctl)
>  {
>         int i;
> -       if (ctl->rx)
> -               ring_free(ctl->rx);
> -       if (ctl->tx)
> -               ring_free(ctl->tx);
> +       ring_free(ctl->rx);
> +       ring_free(ctl->tx);
>
>         /* free RX packets */
>         for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
> --
> 2.1.3
>

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

* Re: [PATCH 1/1] thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-21 11:29                                     ` Andreas Noever
  0 siblings, 0 replies; 3633+ messages in thread
From: Andreas Noever @ 2014-11-21 11:29 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

Hi Markus,

ring_free does not check for null:
http://lxr.free-electrons.com/source/drivers/thunderbolt/nhi.c#L398

Maybe your software confuses the method with:
http://lxr.free-electrons.com/source/drivers/char/tpm/xen-tpmfront.c#L268

Andreas

On Fri, Nov 21, 2014 at 11:40 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 11:30:18 +0100
>
> The ring_free() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/thunderbolt/ctl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
> index 799634b..55b9bdf 100644
> --- a/drivers/thunderbolt/ctl.c
> +++ b/drivers/thunderbolt/ctl.c
> @@ -520,10 +520,8 @@ err:
>  void tb_ctl_free(struct tb_ctl *ctl)
>  {
>         int i;
> -       if (ctl->rx)
> -               ring_free(ctl->rx);
> -       if (ctl->tx)
> -               ring_free(ctl->tx);
> +       ring_free(ctl->rx);
> +       ring_free(ctl->tx);
>
>         /* free RX packets */
>         for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
> --
> 2.1.3
>

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

* [PATCH 1/1] tty-hvsi_lib: Deletion of an unnecessary check before the function call "tty_kref_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-21 11:45                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 11:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linuxppc-dev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 12:40:32 +0100

The tty_kref_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/tty/hvc/hvsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
index 7ae6c29..a270f04 100644
--- a/drivers/tty/hvc/hvsi_lib.c
+++ b/drivers/tty/hvc/hvsi_lib.c
@@ -405,8 +405,7 @@ void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp)
 		hvsi_send_close(pv);
 	}
 
-	if (pv->tty)
-		tty_kref_put(pv->tty);
+	tty_kref_put(pv->tty);
 	pv->tty = NULL;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] tty-hvsi_lib: Deletion of an unnecessary check before the function call "tty_kref_put"
@ 2014-11-21 11:45                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 11:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linuxppc-dev
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 12:40:32 +0100

The tty_kref_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/tty/hvc/hvsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
index 7ae6c29..a270f04 100644
--- a/drivers/tty/hvc/hvsi_lib.c
+++ b/drivers/tty/hvc/hvsi_lib.c
@@ -405,8 +405,7 @@ void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp)
 		hvsi_send_close(pv);
 	}
 
-	if (pv->tty)
-		tty_kref_put(pv->tty);
+	tty_kref_put(pv->tty);
 	pv->tty = NULL;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] tty-hvsi_lib: Deletion of an unnecessary check before the function call "tty_kref_put"
@ 2014-11-21 11:45                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 11:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linuxppc-dev
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 12:40:32 +0100

The tty_kref_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/tty/hvc/hvsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
index 7ae6c29..a270f04 100644
--- a/drivers/tty/hvc/hvsi_lib.c
+++ b/drivers/tty/hvc/hvsi_lib.c
@@ -405,8 +405,7 @@ void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp)
 		hvsi_send_close(pv);
 	}
 
-	if (pv->tty)
-		tty_kref_put(pv->tty);
+	tty_kref_put(pv->tty);
 	pv->tty = NULL;
 }
 
-- 
2.1.3

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

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-21 11:29                                     ` Andreas Noever
@ 2014-11-21 12:21                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 12:21 UTC (permalink / raw)
  To: Andreas Noever; +Cc: LKML, kernel-janitors, Julia Lawall

> ring_free does not check for null:
> http://lxr.free-electrons.com/source/drivers/thunderbolt/nhi.c#L398
> 
> Maybe your software confuses the method with:
> http://lxr.free-electrons.com/source/drivers/char/tpm/xen-tpmfront.c#L268

Thanks for your feedback.

I am sorry for a bit of confusion here.

1. Would it make sense that a variant for the thunderbolt ring_free()
   function will also perform input parameter validation?

2. Are any additional prefixes appropriate so that further name space
   conflicts can be better avoided?

Regards,
Markus

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

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-21 12:21                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 12:21 UTC (permalink / raw)
  To: Andreas Noever; +Cc: LKML, kernel-janitors, Julia Lawall

> ring_free does not check for null:
> http://lxr.free-electrons.com/source/drivers/thunderbolt/nhi.c#L398
> 
> Maybe your software confuses the method with:
> http://lxr.free-electrons.com/source/drivers/char/tpm/xen-tpmfront.c#L268

Thanks for your feedback.

I am sorry for a bit of confusion here.

1. Would it make sense that a variant for the thunderbolt ring_free()
   function will also perform input parameter validation?

2. Are any additional prefixes appropriate so that further name space
   conflicts can be better avoided?

Regards,
Markus

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

* [PATCH 1/1] tty: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-21 12:51                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 12:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 13:42:29 +0100

The functions put_device() and tty_kref_put() test whether their argument
is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/tty/tty_io.c   | 6 ++----
 drivers/tty/tty_port.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 848c17a..3302789 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -169,8 +169,7 @@ void free_tty_struct(struct tty_struct *tty)
 {
 	if (!tty)
 		return;
-	if (tty->dev)
-		put_device(tty->dev);
+	put_device(tty->dev);
 	kfree(tty->write_buf);
 	tty->magic = 0xDEADDEAD;
 	kfree(tty);
@@ -1612,8 +1611,7 @@ static void release_tty(struct tty_struct *tty, int idx)
 		tty->link->port->itty = NULL;
 	cancel_work_sync(&tty->port->buf.work);
 
-	if (tty->link)
-		tty_kref_put(tty->link);
+	tty_kref_put(tty->link);
 	tty_kref_put(tty);
 }
 
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 1b93357..856c064 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -193,8 +193,7 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty)
 	unsigned long flags;
 
 	spin_lock_irqsave(&port->lock, flags);
-	if (port->tty)
-		tty_kref_put(port->tty);
+	tty_kref_put(port->tty);
 	port->tty = tty_kref_get(tty);
 	spin_unlock_irqrestore(&port->lock, flags);
 }
-- 
2.1.3


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

* [PATCH 1/1] tty: Deletion of unnecessary checks before two function calls
@ 2014-11-21 12:51                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 12:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 13:42:29 +0100

The functions put_device() and tty_kref_put() test whether their argument
is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/tty/tty_io.c   | 6 ++----
 drivers/tty/tty_port.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 848c17a..3302789 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -169,8 +169,7 @@ void free_tty_struct(struct tty_struct *tty)
 {
 	if (!tty)
 		return;
-	if (tty->dev)
-		put_device(tty->dev);
+	put_device(tty->dev);
 	kfree(tty->write_buf);
 	tty->magic = 0xDEADDEAD;
 	kfree(tty);
@@ -1612,8 +1611,7 @@ static void release_tty(struct tty_struct *tty, int idx)
 		tty->link->port->itty = NULL;
 	cancel_work_sync(&tty->port->buf.work);
 
-	if (tty->link)
-		tty_kref_put(tty->link);
+	tty_kref_put(tty->link);
 	tty_kref_put(tty);
 }
 
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 1b93357..856c064 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -193,8 +193,7 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty)
 	unsigned long flags;
 
 	spin_lock_irqsave(&port->lock, flags);
-	if (port->tty)
-		tty_kref_put(port->tty);
+	tty_kref_put(port->tty);
 	port->tty = tty_kref_get(tty);
 	spin_unlock_irqrestore(&port->lock, flags);
 }
-- 
2.1.3


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

* Re: thermal: Exynos: Deletion of unnecessary checks before two function calls
  2014-11-21 10:17                                     ` Julia Lawall
  (?)
  (?)
@ 2014-11-21 13:25                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 13:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Eduardo Valentin, Kukjin Kim, Zhang Rui, linux-pm,
	linux-arm-kernel, linux-samsung-soc, LKML, kernel-janitors

>>  	for (i = 0; i < th_zone->cool_dev_size; i++) {
>> -		if (th_zone->cool_dev[i])
>> -			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>> +		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>>  	}
> 
> Now you have unnecessary {}

How are the chances that your source code transformation tool
can also consider the deletion of curly brackets in such an use case?

Can any more pretty-printing rules be integrated from a specific
coding style configuration?

Regards,
Markus


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

* Re: thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 13:25                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 13:25 UTC (permalink / raw)
  To: linux-arm-kernel

>>  	for (i = 0; i < th_zone->cool_dev_size; i++) {
>> -		if (th_zone->cool_dev[i])
>> -			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>> +		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>>  	}
> 
> Now you have unnecessary {}

How are the chances that your source code transformation tool
can also consider the deletion of curly brackets in such an use case?

Can any more pretty-printing rules be integrated from a specific
coding style configuration?

Regards,
Markus


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

* Re: thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 13:25                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 13:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Eduardo Valentin, Kukjin Kim, Zhang Rui, linux-pm,
	linux-arm-kernel, linux-samsung-soc, LKML, kernel-janitors

>>  	for (i = 0; i < th_zone->cool_dev_size; i++) {
>> -		if (th_zone->cool_dev[i])
>> -			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>> +		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>>  	}
> 
> Now you have unnecessary {}

How are the chances that your source code transformation tool
can also consider the deletion of curly brackets in such an use case?

Can any more pretty-printing rules be integrated from a specific
coding style configuration?

Regards,
Markus

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

* thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 13:25                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 13:25 UTC (permalink / raw)
  To: linux-arm-kernel

>>  	for (i = 0; i < th_zone->cool_dev_size; i++) {
>> -		if (th_zone->cool_dev[i])
>> -			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>> +		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>>  	}
> 
> Now you have unnecessary {}

How are the chances that your source code transformation tool
can also consider the deletion of curly brackets in such an use case?

Can any more pretty-printing rules be integrated from a specific
coding style configuration?

Regards,
Markus

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

* [PATCH 1/1] USB: gadget: function: Deletion of an unnecessary check before the function call "rndis_add_hdr"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-21 13:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 13:55 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 14:51:43 +0100

The rndis_add_hdr() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/gadget/function/f_rndis.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index ddb09dc..da56a5f 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -375,8 +375,7 @@ static struct sk_buff *rndis_add_header(struct gether *port,
 	struct sk_buff *skb2;
 
 	skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type));
-	if (skb2)
-		rndis_add_hdr(skb2);
+	rndis_add_hdr(skb2);
 
 	dev_kfree_skb(skb);
 	return skb2;
-- 
2.1.3


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

* [PATCH 1/1] USB: gadget: function: Deletion of an unnecessary check before the function call "rndis_
@ 2014-11-21 13:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 13:55 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 14:51:43 +0100

The rndis_add_hdr() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/gadget/function/f_rndis.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index ddb09dc..da56a5f 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -375,8 +375,7 @@ static struct sk_buff *rndis_add_header(struct gether *port,
 	struct sk_buff *skb2;
 
 	skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type));
-	if (skb2)
-		rndis_add_hdr(skb2);
+	rndis_add_hdr(skb2);
 
 	dev_kfree_skb(skb);
 	return skb2;
-- 
2.1.3


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

* [PATCH 1/1] USB: PCI-quirks: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-21 14:23                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 14:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 15:20:12 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/host/pci-quirks.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 2f3aceb..dd483c1 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -233,10 +233,8 @@ commit:
 
 		spin_unlock_irqrestore(&amd_lock, flags);
 
-		if (info.nb_dev)
-			pci_dev_put(info.nb_dev);
-		if (info.smbus_dev)
-			pci_dev_put(info.smbus_dev);
+		pci_dev_put(info.nb_dev);
+		pci_dev_put(info.smbus_dev);
 
 	} else {
 		/* no race - commit the result */
@@ -447,10 +445,8 @@ void usb_amd_dev_put(void)
 
 	spin_unlock_irqrestore(&amd_lock, flags);
 
-	if (nb)
-		pci_dev_put(nb);
-	if (smbus)
-		pci_dev_put(smbus);
+	pci_dev_put(nb);
+	pci_dev_put(smbus);
 }
 EXPORT_SYMBOL_GPL(usb_amd_dev_put);
 
-- 
2.1.3


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

* [PATCH 1/1] USB: PCI-quirks: Deletion of unnecessary checks before the function call "pci_dev_put"
@ 2014-11-21 14:23                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 14:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 15:20:12 +0100

The pci_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/host/pci-quirks.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 2f3aceb..dd483c1 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -233,10 +233,8 @@ commit:
 
 		spin_unlock_irqrestore(&amd_lock, flags);
 
-		if (info.nb_dev)
-			pci_dev_put(info.nb_dev);
-		if (info.smbus_dev)
-			pci_dev_put(info.smbus_dev);
+		pci_dev_put(info.nb_dev);
+		pci_dev_put(info.smbus_dev);
 
 	} else {
 		/* no race - commit the result */
@@ -447,10 +445,8 @@ void usb_amd_dev_put(void)
 
 	spin_unlock_irqrestore(&amd_lock, flags);
 
-	if (nb)
-		pci_dev_put(nb);
-	if (smbus)
-		pci_dev_put(smbus);
+	pci_dev_put(nb);
+	pci_dev_put(smbus);
 }
 EXPORT_SYMBOL_GPL(usb_amd_dev_put);
 
-- 
2.1.3


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

* [PATCH 1/1] USB-SIS: Deletion of an unnecessary check before the function call "usb_put_dev"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-21 14:55                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 14:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Thomas Winischhofer, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 15:50:44 +0100

The usb_put_dev() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/sisusbvga/sisusb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 633caf6..022dc00 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -2472,8 +2472,7 @@ sisusb_delete(struct kref *kref)
 	if (!sisusb)
 		return;
 
-	if (sisusb->sisusb_dev)
-		usb_put_dev(sisusb->sisusb_dev);
+	usb_put_dev(sisusb->sisusb_dev);
 
 	sisusb->sisusb_dev = NULL;
 	sisusb_free_buffers(sisusb);
-- 
2.1.3


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

* [PATCH 1/1] USB-SIS: Deletion of an unnecessary check before the function call "usb_put_dev"
@ 2014-11-21 14:55                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 14:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Thomas Winischhofer, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 15:50:44 +0100

The usb_put_dev() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/sisusbvga/sisusb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 633caf6..022dc00 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -2472,8 +2472,7 @@ sisusb_delete(struct kref *kref)
 	if (!sisusb)
 		return;
 
-	if (sisusb->sisusb_dev)
-		usb_put_dev(sisusb->sisusb_dev);
+	usb_put_dev(sisusb->sisusb_dev);
 
 	sisusb->sisusb_dev = NULL;
 	sisusb_free_buffers(sisusb);
-- 
2.1.3


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

* [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firmware"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-21 15:20                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 15:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Johan Hovold, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 16:15:34 +0100

The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/serial/mxuport.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
index ab1d690..3653ec1 100644
--- a/drivers/usb/serial/mxuport.c
+++ b/drivers/usb/serial/mxuport.c
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);
 	return err;
 }
 
-- 
2.1.3


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

* [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firmware
@ 2014-11-21 15:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 15:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Johan Hovold, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 16:15:34 +0100

The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/serial/mxuport.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
index ab1d690..3653ec1 100644
--- a/drivers/usb/serial/mxuport.c
+++ b/drivers/usb/serial/mxuport.c
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);
 	return err;
 }
 
-- 
2.1.3


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

* Re: [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firmware"
  2014-11-21 15:20                                   ` [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firmware SF Markus Elfring
@ 2014-11-21 15:26                                     ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-21 15:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, Johan Hovold, linux-usb, LKML, kernel-janitors



On Fri, 21 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 16:15:34 +0100
>
> The release_firmware() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/usb/serial/mxuport.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
> index ab1d690..3653ec1 100644
> --- a/drivers/usb/serial/mxuport.c
> +++ b/drivers/usb/serial/mxuport.c
> @@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
>  	 */
>  	usb_set_serial_data(serial, (void *)id->driver_info);
>  out:
> -	if (fw_p)
> -		release_firmware(fw_p);
> +	release_firmware(fw_p);

I think that the if should stay.  There were two cases on the allocation,
so there should be two cases on the release.

julia

>  	return err;
>  }
>
> --
> 2.1.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firm
@ 2014-11-21 15:26                                     ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-21 15:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, Johan Hovold, linux-usb, LKML, kernel-janitors



On Fri, 21 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 16:15:34 +0100
>
> The release_firmware() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/usb/serial/mxuport.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
> index ab1d690..3653ec1 100644
> --- a/drivers/usb/serial/mxuport.c
> +++ b/drivers/usb/serial/mxuport.c
> @@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
>  	 */
>  	usb_set_serial_data(serial, (void *)id->driver_info);
>  out:
> -	if (fw_p)
> -		release_firmware(fw_p);
> +	release_firmware(fw_p);

I think that the if should stay.  There were two cases on the allocation,
so there should be two cases on the release.

julia

>  	return err;
>  }
>
> --
> 2.1.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* [PATCH 1/1] USB-IP: Deletion of unnecessary checks before the function call "usb_put_dev"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-21 15:36                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 15:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Shuah Khan, Valentina Manea, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 16:33:18 +0100

The usb_put_dev() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/usbip/vhci_hcd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index c02374b..cc1b03e 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -518,8 +518,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 			dev_info(dev, "SetAddress Request (%d) to port %d\n",
 				 ctrlreq->wValue, vdev->rhport);
 
-			if (vdev->udev)
-				usb_put_dev(vdev->udev);
+			usb_put_dev(vdev->udev);
 			vdev->udev = usb_get_dev(urb->dev);
 
 			spin_lock(&vdev->ud.lock);
@@ -539,8 +538,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 				usbip_dbg_vhci_hc(
 					"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
 
-			if (vdev->udev)
-				usb_put_dev(vdev->udev);
+			usb_put_dev(vdev->udev);
 			vdev->udev = usb_get_dev(urb->dev);
 			goto out;
 
@@ -831,8 +829,7 @@ static void vhci_device_reset(struct usbip_device *ud)
 	vdev->speed  = 0;
 	vdev->devid  = 0;
 
-	if (vdev->udev)
-		usb_put_dev(vdev->udev);
+	usb_put_dev(vdev->udev);
 	vdev->udev = NULL;
 
 	if (ud->tcp_socket) {
-- 
2.1.3


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

* [PATCH 1/1] USB-IP: Deletion of unnecessary checks before the function call "usb_put_dev"
@ 2014-11-21 15:36                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 15:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Shuah Khan, Valentina Manea, linux-usb
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 16:33:18 +0100

The usb_put_dev() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/usbip/vhci_hcd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index c02374b..cc1b03e 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -518,8 +518,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 			dev_info(dev, "SetAddress Request (%d) to port %d\n",
 				 ctrlreq->wValue, vdev->rhport);
 
-			if (vdev->udev)
-				usb_put_dev(vdev->udev);
+			usb_put_dev(vdev->udev);
 			vdev->udev = usb_get_dev(urb->dev);
 
 			spin_lock(&vdev->ud.lock);
@@ -539,8 +538,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 				usbip_dbg_vhci_hc(
 					"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
 
-			if (vdev->udev)
-				usb_put_dev(vdev->udev);
+			usb_put_dev(vdev->udev);
 			vdev->udev = usb_get_dev(urb->dev);
 			goto out;
 
@@ -831,8 +829,7 @@ static void vhci_device_reset(struct usbip_device *ud)
 	vdev->speed  = 0;
 	vdev->devid  = 0;
 
-	if (vdev->udev)
-		usb_put_dev(vdev->udev);
+	usb_put_dev(vdev->udev);
 	vdev->udev = NULL;
 
 	if (ud->tcp_socket) {
-- 
2.1.3


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

* Re: USB: serial: Deletion of an unnecessary check before the function call "release_firmware"
  2014-11-21 15:26                                     ` [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firm Julia Lawall
@ 2014-11-21 15:48                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 15:48 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Greg Kroah-Hartman, Johan Hovold, linux-usb, LKML, kernel-janitors

>> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
>> index ab1d690..3653ec1 100644
>> --- a/drivers/usb/serial/mxuport.c
>> +++ b/drivers/usb/serial/mxuport.c
>> @@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
>>  	 */
>>  	usb_set_serial_data(serial, (void *)id->driver_info);
>>  out:
>> -	if (fw_p)
>> -		release_firmware(fw_p);
>> +	release_firmware(fw_p);
> 
> I think that the if should stay.

I have got an other opinion.


> There were two cases on the allocation, so there should be two cases
> on the release.

I find that this implementation detail does not really matter for the
necessity of a null pointer check directly before such a function call.

Regards,
Markus

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

* Re: USB: serial: Deletion of an unnecessary check before the function call "release_firmware"
@ 2014-11-21 15:48                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 15:48 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Greg Kroah-Hartman, Johan Hovold, linux-usb, LKML, kernel-janitors

>> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
>> index ab1d690..3653ec1 100644
>> --- a/drivers/usb/serial/mxuport.c
>> +++ b/drivers/usb/serial/mxuport.c
>> @@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
>>  	 */
>>  	usb_set_serial_data(serial, (void *)id->driver_info);
>>  out:
>> -	if (fw_p)
>> -		release_firmware(fw_p);
>> +	release_firmware(fw_p);
> 
> I think that the if should stay.

I have got an other opinion.


> There were two cases on the allocation, so there should be two cases
> on the release.

I find that this implementation detail does not really matter for the
necessity of a null pointer check directly before such a function call.

Regards,
Markus

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

* [PATCH v2] thermal: Exynos: Deletion of unnecessary checks before two function calls
  2014-11-21 10:17                                     ` Julia Lawall
  (?)
  (?)
@ 2014-11-21 16:17                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 16:17 UTC (permalink / raw)
  To: Eduardo Valentin, Kukjin Kim, Zhang Rui, linux-pm,
	linux-arm-kernel, linux-samsung-soc
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 17:11:49 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
test whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..b6be572 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,13 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
-	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-	}
+	for (i = 0; i < th_zone->cool_dev_size; ++i)
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 
 	dev_info(sensor_conf->dev,
 		"Exynos: Kernel Thermal management unregistered\n");
-- 
2.1.3


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

* [PATCH v2] thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 16:17                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 16:17 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 17:11:49 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
test whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..b6be572 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,13 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
-	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-	}
+	for (i = 0; i < th_zone->cool_dev_size; ++i)
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 
 	dev_info(sensor_conf->dev,
 		"Exynos: Kernel Thermal management unregistered\n");
-- 
2.1.3


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

* [PATCH v2] thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 16:17                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 16:17 UTC (permalink / raw)
  To: Eduardo Valentin, Kukjin Kim, Zhang Rui, linux-pm,
	linux-arm-kernel, linux-samsung-soc
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 17:11:49 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
test whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..b6be572 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,13 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
-	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-	}
+	for (i = 0; i < th_zone->cool_dev_size; ++i)
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 
 	dev_info(sensor_conf->dev,
 		"Exynos: Kernel Thermal management unregistered\n");
-- 
2.1.3


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

* [PATCH v2] thermal: Exynos: Deletion of unnecessary checks before two function calls
@ 2014-11-21 16:17                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 16:17 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 17:11:49 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
test whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..b6be572 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,13 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
-	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-	}
+	for (i = 0; i < th_zone->cool_dev_size; ++i)
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 
 	dev_info(sensor_conf->dev,
 		"Exynos: Kernel Thermal management unregistered\n");
-- 
2.1.3

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

* [PATCH 1/1] ALSA: core: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-21 17:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 17:40 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 18:34:48 +0100

The functions snd_seq_oss_timer_delete() and vunmap() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/core/seq/oss/seq_oss_init.c | 9 +++------
 sound/core/sgbuf.c                | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index b9184d2..b0e32e1 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -403,14 +403,11 @@ free_devinfo(void *private)
 {
 	struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private;
 
-	if (dp->timer)
-		snd_seq_oss_timer_delete(dp->timer);
+	snd_seq_oss_timer_delete(dp->timer);
 		
-	if (dp->writeq)
-		snd_seq_oss_writeq_delete(dp->writeq);
+	snd_seq_oss_writeq_delete(dp->writeq);
 
-	if (dp->readq)
-		snd_seq_oss_readq_delete(dp->readq);
+	snd_seq_oss_readq_delete(dp->readq);
 	
 	kfree(dp);
 }
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
index 0a41850..84fffab 100644
--- a/sound/core/sgbuf.c
+++ b/sound/core/sgbuf.c
@@ -39,8 +39,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
 	if (! sgbuf)
 		return -EINVAL;
 
-	if (dmab->area)
-		vunmap(dmab->area);
+	vunmap(dmab->area);
 	dmab->area = NULL;
 
 	tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
-- 
2.1.3


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

* [PATCH 1/1] ALSA: core: Deletion of unnecessary checks before two function calls
@ 2014-11-21 17:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 17:40 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 18:34:48 +0100

The functions snd_seq_oss_timer_delete() and vunmap() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/core/seq/oss/seq_oss_init.c | 9 +++------
 sound/core/sgbuf.c                | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index b9184d2..b0e32e1 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -403,14 +403,11 @@ free_devinfo(void *private)
 {
 	struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private;
 
-	if (dp->timer)
-		snd_seq_oss_timer_delete(dp->timer);
+	snd_seq_oss_timer_delete(dp->timer);
 		
-	if (dp->writeq)
-		snd_seq_oss_writeq_delete(dp->writeq);
+	snd_seq_oss_writeq_delete(dp->writeq);
 
-	if (dp->readq)
-		snd_seq_oss_readq_delete(dp->readq);
+	snd_seq_oss_readq_delete(dp->readq);
 	
 	kfree(dp);
 }
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
index 0a41850..84fffab 100644
--- a/sound/core/sgbuf.c
+++ b/sound/core/sgbuf.c
@@ -39,8 +39,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
 	if (! sgbuf)
 		return -EINVAL;
 
-	if (dmab->area)
-		vunmap(dmab->area);
+	vunmap(dmab->area);
 	dmab->area = NULL;
 
 	tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
-- 
2.1.3


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

* [PATCH 1/1] ALSA: core: Deletion of unnecessary checks before two function calls
@ 2014-11-21 17:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 17:40 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 18:34:48 +0100

The functions snd_seq_oss_timer_delete() and vunmap() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/core/seq/oss/seq_oss_init.c | 9 +++------
 sound/core/sgbuf.c                | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index b9184d2..b0e32e1 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -403,14 +403,11 @@ free_devinfo(void *private)
 {
 	struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private;
 
-	if (dp->timer)
-		snd_seq_oss_timer_delete(dp->timer);
+	snd_seq_oss_timer_delete(dp->timer);
 		
-	if (dp->writeq)
-		snd_seq_oss_writeq_delete(dp->writeq);
+	snd_seq_oss_writeq_delete(dp->writeq);
 
-	if (dp->readq)
-		snd_seq_oss_readq_delete(dp->readq);
+	snd_seq_oss_readq_delete(dp->readq);
 	
 	kfree(dp);
 }
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
index 0a41850..84fffab 100644
--- a/sound/core/sgbuf.c
+++ b/sound/core/sgbuf.c
@@ -39,8 +39,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
 	if (! sgbuf)
 		return -EINVAL;
 
-	if (dmab->area)
-		vunmap(dmab->area);
+	vunmap(dmab->area);
 	dmab->area = NULL;
 
 	tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
-- 
2.1.3

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

* Re: [PATCH 1/1] USB-IP: Deletion of unnecessary checks before the function call "usb_put_dev"
  2014-11-21 15:36                                   ` SF Markus Elfring
@ 2014-11-21 17:44                                     ` Valentina Manea
  -1 siblings, 0 replies; 3633+ messages in thread
From: Valentina Manea @ 2014-11-21 17:44 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, Shuah Khan, linux-usb, LKML, kernel-janitors,
	Julia Lawall

On Fri, Nov 21, 2014 at 5:36 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 16:33:18 +0100
>
> The usb_put_dev() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/usb/usbip/vhci_hcd.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
> index c02374b..cc1b03e 100644
> --- a/drivers/usb/usbip/vhci_hcd.c
> +++ b/drivers/usb/usbip/vhci_hcd.c
> @@ -518,8 +518,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
>                         dev_info(dev, "SetAddress Request (%d) to port %d\n",
>                                  ctrlreq->wValue, vdev->rhport);
>
> -                       if (vdev->udev)
> -                               usb_put_dev(vdev->udev);
> +                       usb_put_dev(vdev->udev);
>                         vdev->udev = usb_get_dev(urb->dev);
>
>                         spin_lock(&vdev->ud.lock);
> @@ -539,8 +538,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
>                                 usbip_dbg_vhci_hc(
>                                         "Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
>
> -                       if (vdev->udev)
> -                               usb_put_dev(vdev->udev);
> +                       usb_put_dev(vdev->udev);
>                         vdev->udev = usb_get_dev(urb->dev);
>                         goto out;
>
> @@ -831,8 +829,7 @@ static void vhci_device_reset(struct usbip_device *ud)
>         vdev->speed  = 0;
>         vdev->devid  = 0;
>
> -       if (vdev->udev)
> -               usb_put_dev(vdev->udev);
> +       usb_put_dev(vdev->udev);
>         vdev->udev = NULL;
>
>         if (ud->tcp_socket) {
> --
> 2.1.3
>

Acked-by: Valentina Manea <valentina.manea.m@gmail.com>

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

* Re: [PATCH 1/1] USB-IP: Deletion of unnecessary checks before the function call "usb_put_dev"
@ 2014-11-21 17:44                                     ` Valentina Manea
  0 siblings, 0 replies; 3633+ messages in thread
From: Valentina Manea @ 2014-11-21 17:44 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Greg Kroah-Hartman, Shuah Khan, linux-usb, LKML, kernel-janitors,
	Julia Lawall

On Fri, Nov 21, 2014 at 5:36 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 16:33:18 +0100
>
> The usb_put_dev() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/usb/usbip/vhci_hcd.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
> index c02374b..cc1b03e 100644
> --- a/drivers/usb/usbip/vhci_hcd.c
> +++ b/drivers/usb/usbip/vhci_hcd.c
> @@ -518,8 +518,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
>                         dev_info(dev, "SetAddress Request (%d) to port %d\n",
>                                  ctrlreq->wValue, vdev->rhport);
>
> -                       if (vdev->udev)
> -                               usb_put_dev(vdev->udev);
> +                       usb_put_dev(vdev->udev);
>                         vdev->udev = usb_get_dev(urb->dev);
>
>                         spin_lock(&vdev->ud.lock);
> @@ -539,8 +538,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
>                                 usbip_dbg_vhci_hc(
>                                         "Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
>
> -                       if (vdev->udev)
> -                               usb_put_dev(vdev->udev);
> +                       usb_put_dev(vdev->udev);
>                         vdev->udev = usb_get_dev(urb->dev);
>                         goto out;
>
> @@ -831,8 +829,7 @@ static void vhci_device_reset(struct usbip_device *ud)
>         vdev->speed  = 0;
>         vdev->devid  = 0;
>
> -       if (vdev->udev)
> -               usb_put_dev(vdev->udev);
> +       usb_put_dev(vdev->udev);
>         vdev->udev = NULL;
>
>         if (ud->tcp_socket) {
> --
> 2.1.3
>

Acked-by: Valentina Manea <valentina.manea.m@gmail.com>

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

* Re: USB: serial: Deletion of an unnecessary check before the function call "release_firmware"
  2014-11-21 15:48                                       ` SF Markus Elfring
@ 2014-11-21 17:59                                         ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-21 17:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, Greg Kroah-Hartman, Johan Hovold, linux-usb, LKML,
	kernel-janitors



On Fri, 21 Nov 2014, SF Markus Elfring wrote:

> >> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
> >> index ab1d690..3653ec1 100644
> >> --- a/drivers/usb/serial/mxuport.c
> >> +++ b/drivers/usb/serial/mxuport.c
> >> @@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
> >>  	 */
> >>  	usb_set_serial_data(serial, (void *)id->driver_info);
> >>  out:
> >> -	if (fw_p)
> >> -		release_firmware(fw_p);
> >> +	release_firmware(fw_p);
> >
> > I think that the if should stay.
>
> I have got an other opinion.
>
>
> > There were two cases on the allocation, so there should be two cases
> > on the release.
>
> I find that this implementation detail does not really matter for the
> necessity of a null pointer check directly before such a function call.

Conceptually, if it is clear 10 lines above that nothing was allocated,
and there is a fallback to existing data (according to the comment above)
it is strange to be releasing something.

julia

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

* Re: USB: serial: Deletion of an unnecessary check before the function call "release_firmware"
@ 2014-11-21 17:59                                         ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-21 17:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, Greg Kroah-Hartman, Johan Hovold, linux-usb, LKML,
	kernel-janitors



On Fri, 21 Nov 2014, SF Markus Elfring wrote:

> >> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
> >> index ab1d690..3653ec1 100644
> >> --- a/drivers/usb/serial/mxuport.c
> >> +++ b/drivers/usb/serial/mxuport.c
> >> @@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
> >>  	 */
> >>  	usb_set_serial_data(serial, (void *)id->driver_info);
> >>  out:
> >> -	if (fw_p)
> >> -		release_firmware(fw_p);
> >> +	release_firmware(fw_p);
> >
> > I think that the if should stay.
>
> I have got an other opinion.
>
>
> > There were two cases on the allocation, so there should be two cases
> > on the release.
>
> I find that this implementation detail does not really matter for the
> necessity of a null pointer check directly before such a function call.

Conceptually, if it is clear 10 lines above that nothing was allocated,
and there is a fallback to existing data (according to the comment above)
it is strange to be releasing something.

julia

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

* [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and_free_resource"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-21 18:11                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 18:11 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 19:05:50 +0100

The release_and_free_resource() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/isa/es1688/es1688_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index b3b4f15..fb259491 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -614,8 +614,7 @@ static int snd_es1688_free(struct snd_es1688 *chip)
 {
 	if (chip->hardware != ES1688_HW_UNDEF)
 		snd_es1688_init(chip, 0);
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 	if (chip->dma8 >= 0) {
-- 
2.1.3


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

* [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and
@ 2014-11-21 18:11                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 18:11 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 19:05:50 +0100

The release_and_free_resource() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/isa/es1688/es1688_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index b3b4f15..fb259491 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -614,8 +614,7 @@ static int snd_es1688_free(struct snd_es1688 *chip)
 {
 	if (chip->hardware != ES1688_HW_UNDEF)
 		snd_es1688_init(chip, 0);
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 	if (chip->dma8 >= 0) {
-- 
2.1.3


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

* [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and_free_resource"
@ 2014-11-21 18:11                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 18:11 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 19:05:50 +0100

The release_and_free_resource() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/isa/es1688/es1688_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index b3b4f15..fb259491 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -614,8 +614,7 @@ static int snd_es1688_free(struct snd_es1688 *chip)
 {
 	if (chip->hardware != ES1688_HW_UNDEF)
 		snd_es1688_init(chip, 0);
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 	if (chip->dma8 >= 0) {
-- 
2.1.3

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

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-21 12:21                                       ` SF Markus Elfring
@ 2014-11-21 18:14                                         ` Joe Perches
  -1 siblings, 0 replies; 3633+ messages in thread
From: Joe Perches @ 2014-11-21 18:14 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Andreas Noever, LKML, kernel-janitors, Julia Lawall

On Fri, 2014-11-21 at 13:21 +0100, SF Markus Elfring wrote:
> 2. Are any additional prefixes appropriate so that further name space
>    conflicts can be better avoided?

To avoid possible external naming conflicts, add tb_ prefix to
various ring_<foo> structs and functions.

Other miscellanea:

o typo/spelling fixes (releated/related, loose/lose)
o argument alignment
o comment formatting

---
Perhaps something like this?

unsigned/compiled/untested

 drivers/thunderbolt/ctl.c      |  41 ++++++-------
 drivers/thunderbolt/nhi.c      | 133 +++++++++++++++++++++--------------------
 drivers/thunderbolt/nhi.h      |  47 ++++++++-------
 drivers/thunderbolt/nhi_regs.h |  16 ++---
 4 files changed, 121 insertions(+), 116 deletions(-)

diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index 799634b..52783e0 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -17,7 +17,7 @@
 struct ctl_pkg {
 	struct tb_ctl *ctl;
 	void *buffer;
-	struct ring_frame frame;
+	struct tb_ring_frame frame;
 };
 
 #define TB_CTL_RX_PKG_COUNT 10
@@ -319,8 +319,8 @@ static struct ctl_pkg *tb_ctl_pkg_alloc(struct tb_ctl *ctl)
 
 /* RX/TX handling */
 
-static void tb_ctl_tx_callback(struct tb_ring *ring, struct ring_frame *frame,
-			       bool canceled)
+static void tb_ctl_tx_callback(struct tb_ring *ring,
+			       struct tb_ring_frame *frame, bool canceled)
 {
 	struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame);
 	tb_ctl_pkg_free(pkg);
@@ -357,7 +357,7 @@ static int tb_ctl_tx(struct tb_ctl *ctl, void *data, size_t len,
 	cpu_to_be32_array(pkg->buffer, data, len / 4);
 	*(__be32 *) (pkg->buffer + len) = tb_crc(pkg->buffer, len);
 
-	res = ring_tx(ctl->tx, &pkg->frame);
+	res = tb_ring_tx(ctl->tx, &pkg->frame);
 	if (res) /* ring is stopped */
 		tb_ctl_pkg_free(pkg);
 	return res;
@@ -386,16 +386,16 @@ static void tb_ctl_handle_plug_event(struct tb_ctl *ctl,
 
 static void tb_ctl_rx_submit(struct ctl_pkg *pkg)
 {
-	ring_rx(pkg->ctl->rx, &pkg->frame); /*
-					     * We ignore failures during stop.
-					     * All rx packets are referenced
-					     * from ctl->rx_packets, so we do
-					     * not loose them.
-					     */
+	tb_ring_rx(pkg->ctl->rx, &pkg->frame);
+	/*
+	 * We ignore failures during stop.
+	 * All rx packets are referenced from ctl->rx_packets,
+	 * so we do not lose them.
+	 */
 }
 
-static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame,
-			       bool canceled)
+static void tb_ctl_rx_callback(struct tb_ring *ring,
+			       struct tb_ring_frame *frame, bool canceled)
 {
 	struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame);
 
@@ -488,11 +488,11 @@ struct tb_ctl *tb_ctl_alloc(struct tb_nhi *nhi, hotplug_cb cb, void *cb_data)
 	if (!ctl->frame_pool)
 		goto err;
 
-	ctl->tx = ring_alloc_tx(nhi, 0, 10);
+	ctl->tx = tb_ring_alloc_tx(nhi, 0, 10);
 	if (!ctl->tx)
 		goto err;
 
-	ctl->rx = ring_alloc_rx(nhi, 0, 10);
+	ctl->rx = tb_ring_alloc_rx(nhi, 0, 10);
 	if (!ctl->rx)
 		goto err;
 
@@ -521,9 +521,9 @@ void tb_ctl_free(struct tb_ctl *ctl)
 {
 	int i;
 	if (ctl->rx)
-		ring_free(ctl->rx);
+		tb_ring_free(ctl->rx);
 	if (ctl->tx)
-		ring_free(ctl->tx);
+		tb_ring_free(ctl->tx);
 
 	/* free RX packets */
 	for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
@@ -542,8 +542,9 @@ void tb_ctl_start(struct tb_ctl *ctl)
 {
 	int i;
 	tb_ctl_info(ctl, "control channel starting...\n");
-	ring_start(ctl->tx); /* is used to ack hotplug packets, start first */
-	ring_start(ctl->rx);
+	/* is used to ack hotplug packets, start first */
+	tb_ring_start(ctl->tx);
+	tb_ring_start(ctl->rx);
 	for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
 		tb_ctl_rx_submit(ctl->rx_packets[i]);
 }
@@ -558,8 +559,8 @@ void tb_ctl_start(struct tb_ctl *ctl)
  */
 void tb_ctl_stop(struct tb_ctl *ctl)
 {
-	ring_stop(ctl->rx);
-	ring_stop(ctl->tx);
+	tb_ring_stop(ctl->rx);
+	tb_ring_stop(ctl->tx);
 
 	if (!kfifo_is_empty(&ctl->response_fifo))
 		tb_ctl_WARN(ctl, "dangling response in response_fifo\n");
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index c68fe12..552683f 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -22,7 +22,7 @@
 #define RING_TYPE(ring) ((ring)->is_tx ? "TX ring" : "RX ring")
 
 
-static int ring_interrupt_index(struct tb_ring *ring)
+static int tb_ring_interrupt_index(struct tb_ring *ring)
 {
 	int bit = ring->hop;
 	if (!ring->is_tx)
@@ -31,14 +31,14 @@ static int ring_interrupt_index(struct tb_ring *ring)
 }
 
 /**
- * ring_interrupt_active() - activate/deactivate interrupts for a single ring
+ * tb_ring_interrupt_active() - activate/deactivate interrupts for a single ring
  *
  * ring->nhi->lock must be held.
  */
-static void ring_interrupt_active(struct tb_ring *ring, bool active)
+static void tb_ring_interrupt_active(struct tb_ring *ring, bool active)
 {
-	int reg = REG_RING_INTERRUPT_BASE + ring_interrupt_index(ring) / 32;
-	int bit = ring_interrupt_index(ring) & 31;
+	int reg = REG_RING_INTERRUPT_BASE + tb_ring_interrupt_index(ring) / 32;
+	int bit = tb_ring_interrupt_index(ring) & 31;
 	int mask = 1 << bit;
 	u32 old, new;
 	old = ioread32(ring->nhi->iobase + reg);
@@ -78,7 +78,7 @@ static void nhi_disable_interrupts(struct tb_nhi *nhi)
 
 /* ring helper methods */
 
-static void __iomem *ring_desc_base(struct tb_ring *ring)
+static void __iomem *tb_ring_desc_base(struct tb_ring *ring)
 {
 	void __iomem *io = ring->nhi->iobase;
 	io += ring->is_tx ? REG_TX_RING_BASE : REG_RX_RING_BASE;
@@ -86,7 +86,7 @@ static void __iomem *ring_desc_base(struct tb_ring *ring)
 	return io;
 }
 
-static void __iomem *ring_options_base(struct tb_ring *ring)
+static void __iomem *tb_ring_options_base(struct tb_ring *ring)
 {
 	void __iomem *io = ring->nhi->iobase;
 	io += ring->is_tx ? REG_TX_OPTIONS_BASE : REG_RX_OPTIONS_BASE;
@@ -94,48 +94,49 @@ static void __iomem *ring_options_base(struct tb_ring *ring)
 	return io;
 }
 
-static void ring_iowrite16desc(struct tb_ring *ring, u32 value, u32 offset)
+static void tb_ring_iowrite16desc(struct tb_ring *ring, u32 value, u32 offset)
 {
-	iowrite16(value, ring_desc_base(ring) + offset);
+	iowrite16(value, tb_ring_desc_base(ring) + offset);
 }
 
-static void ring_iowrite32desc(struct tb_ring *ring, u32 value, u32 offset)
+static void tb_ring_iowrite32desc(struct tb_ring *ring, u32 value, u32 offset)
 {
-	iowrite32(value, ring_desc_base(ring) + offset);
+	iowrite32(value, tb_ring_desc_base(ring) + offset);
 }
 
-static void ring_iowrite64desc(struct tb_ring *ring, u64 value, u32 offset)
+static void tb_ring_iowrite64desc(struct tb_ring *ring, u64 value, u32 offset)
 {
-	iowrite32(value, ring_desc_base(ring) + offset);
-	iowrite32(value >> 32, ring_desc_base(ring) + offset + 4);
+	iowrite32(value, tb_ring_desc_base(ring) + offset);
+	iowrite32(value >> 32, tb_ring_desc_base(ring) + offset + 4);
 }
 
-static void ring_iowrite32options(struct tb_ring *ring, u32 value, u32 offset)
+static void tb_ring_iowrite32options(struct tb_ring *ring, u32 value,
+				     u32 offset)
 {
-	iowrite32(value, ring_options_base(ring) + offset);
+	iowrite32(value, tb_ring_options_base(ring) + offset);
 }
 
-static bool ring_full(struct tb_ring *ring)
+static bool tb_ring_full(struct tb_ring *ring)
 {
 	return ((ring->head + 1) % ring->size) == ring->tail;
 }
 
-static bool ring_empty(struct tb_ring *ring)
+static bool tb_ring_empty(struct tb_ring *ring)
 {
 	return ring->head == ring->tail;
 }
 
 /**
- * ring_write_descriptors() - post frames from ring->queue to the controller
+ * tb_ring_write_descriptors() - post frames from ring->queue to the controller
  *
  * ring->lock is held.
  */
-static void ring_write_descriptors(struct tb_ring *ring)
+static void tb_ring_write_descriptors(struct tb_ring *ring)
 {
-	struct ring_frame *frame, *n;
-	struct ring_desc *descriptor;
+	struct tb_ring_frame *frame, *n;
+	struct tb_ring_desc *descriptor;
 	list_for_each_entry_safe(frame, n, &ring->queue, list) {
-		if (ring_full(ring))
+		if (tb_ring_full(ring))
 			break;
 		list_move_tail(&frame->list, &ring->in_flight);
 		descriptor = &ring->descriptors[ring->head];
@@ -148,12 +149,12 @@ static void ring_write_descriptors(struct tb_ring *ring)
 			descriptor->sof = frame->sof;
 		}
 		ring->head = (ring->head + 1) % ring->size;
-		ring_iowrite16desc(ring, ring->head, ring->is_tx ? 10 : 8);
+		tb_ring_iowrite16desc(ring, ring->head, ring->is_tx ? 10 : 8);
 	}
 }
 
 /**
- * ring_work() - progress completed frames
+ * tb_ring_work() - progress completed frames
  *
  * If the ring is shutting down then all frames are marked as canceled and
  * their callbacks are invoked.
@@ -161,10 +162,10 @@ static void ring_write_descriptors(struct tb_ring *ring)
  * Otherwise we collect all completed frame from the ring buffer, write new
  * frame to the ring buffer and invoke the callbacks for the completed frames.
  */
-static void ring_work(struct work_struct *work)
+static void tb_ring_work(struct work_struct *work)
 {
 	struct tb_ring *ring = container_of(work, typeof(*ring), work);
-	struct ring_frame *frame;
+	struct tb_ring_frame *frame;
 	bool canceled = false;
 	LIST_HEAD(done);
 	mutex_lock(&ring->lock);
@@ -177,7 +178,7 @@ static void ring_work(struct work_struct *work)
 		goto invoke_callback;
 	}
 
-	while (!ring_empty(ring)) {
+	while (!tb_ring_empty(ring)) {
 		if (!(ring->descriptors[ring->tail].flags
 				& RING_DESC_COMPLETED))
 			break;
@@ -209,7 +210,7 @@ static void ring_work(struct work_struct *work)
 		}
 		ring->tail = (ring->tail + 1) % ring->size;
 	}
-	ring_write_descriptors(ring);
+	tb_ring_write_descriptors(ring);
 
 invoke_callback:
 	mutex_unlock(&ring->lock); /* allow callbacks to schedule new work */
@@ -224,13 +225,13 @@ invoke_callback:
 	}
 }
 
-int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame)
+int __tb_ring_enqueue(struct tb_ring *ring, struct tb_ring_frame *frame)
 {
 	int ret = 0;
 	mutex_lock(&ring->lock);
 	if (ring->running) {
 		list_add_tail(&frame->list, &ring->queue);
-		ring_write_descriptors(ring);
+		tb_ring_write_descriptors(ring);
 	} else {
 		ret = -ESHUTDOWN;
 	}
@@ -238,8 +239,8 @@ int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame)
 	return ret;
 }
 
-static struct tb_ring *ring_alloc(struct tb_nhi *nhi, u32 hop, int size,
-				  bool transmit)
+static struct tb_ring *tb_ring_alloc(struct tb_nhi *nhi, u32 hop, int size,
+				     bool transmit)
 {
 	struct tb_ring *ring = NULL;
 	dev_info(&nhi->pdev->dev, "allocating %s ring %d of size %d\n",
@@ -264,7 +265,7 @@ static struct tb_ring *ring_alloc(struct tb_nhi *nhi, u32 hop, int size,
 	mutex_init(&ring->lock);
 	INIT_LIST_HEAD(&ring->queue);
 	INIT_LIST_HEAD(&ring->in_flight);
-	INIT_WORK(&ring->work, ring_work);
+	INIT_WORK(&ring->work, tb_ring_work);
 
 	ring->nhi = nhi;
 	ring->hop = hop;
@@ -294,22 +295,22 @@ err:
 	return NULL;
 }
 
-struct tb_ring *ring_alloc_tx(struct tb_nhi *nhi, int hop, int size)
+struct tb_ring *tb_ring_alloc_tx(struct tb_nhi *nhi, int hop, int size)
 {
-	return ring_alloc(nhi, hop, size, true);
+	return tb_ring_alloc(nhi, hop, size, true);
 }
 
-struct tb_ring *ring_alloc_rx(struct tb_nhi *nhi, int hop, int size)
+struct tb_ring *tb_ring_alloc_rx(struct tb_nhi *nhi, int hop, int size)
 {
-	return ring_alloc(nhi, hop, size, false);
+	return tb_ring_alloc(nhi, hop, size, false);
 }
 
 /**
- * ring_start() - enable a ring
+ * tb_ring_start() - enable a ring
  *
- * Must not be invoked in parallel with ring_stop().
+ * Must not be invoked in parallel with tb_ring_stop().
  */
-void ring_start(struct tb_ring *ring)
+void tb_ring_start(struct tb_ring *ring)
 {
 	mutex_lock(&ring->nhi->lock);
 	mutex_lock(&ring->lock);
@@ -320,20 +321,21 @@ void ring_start(struct tb_ring *ring)
 	dev_info(&ring->nhi->pdev->dev, "starting %s %d\n",
 		 RING_TYPE(ring), ring->hop);
 
-	ring_iowrite64desc(ring, ring->descriptors_dma, 0);
+	tb_ring_iowrite64desc(ring, ring->descriptors_dma, 0);
 	if (ring->is_tx) {
-		ring_iowrite32desc(ring, ring->size, 12);
-		ring_iowrite32options(ring, 0, 4); /* time releated ? */
-		ring_iowrite32options(ring,
-				      RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
+		tb_ring_iowrite32desc(ring, ring->size, 12);
+		tb_ring_iowrite32options(ring, 0, 4); /* time related ? */
+		tb_ring_iowrite32options(ring,
+					 RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
 	} else {
-		ring_iowrite32desc(ring,
-				   (TB_FRAME_SIZE << 16) | ring->size, 12);
-		ring_iowrite32options(ring, 0xffffffff, 4); /* SOF EOF mask */
-		ring_iowrite32options(ring,
-				      RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
+		tb_ring_iowrite32desc(ring,
+				      (TB_FRAME_SIZE << 16) | ring->size, 12);
+		/* SOF EOF mask */
+		tb_ring_iowrite32options(ring, 0xffffffff, 4);
+		tb_ring_iowrite32options(ring,
+					 RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
 	}
-	ring_interrupt_active(ring, true);
+	tb_ring_interrupt_active(ring, true);
 	ring->running = true;
 err:
 	mutex_unlock(&ring->lock);
@@ -342,18 +344,19 @@ err:
 
 
 /**
- * ring_stop() - shutdown a ring
+ * tb_ring_stop() - shutdown a ring
  *
  * Must not be invoked from a callback.
  *
- * This method will disable the ring. Further calls to ring_tx/ring_rx will
- * return -ESHUTDOWN until ring_stop has been called.
+ * This method will disable the ring.
+ * Further calls to tb_ring_tx/tb_ring_rx will return -ESHUTDOWN
+ * until tb_ring_stop has been called.
  *
  * All enqueued frames will be canceled and their callbacks will be executed
  * with frame->canceled set to true (on the callback thread). This method
  * returns only after all callback invocations have finished.
  */
-void ring_stop(struct tb_ring *ring)
+void tb_ring_stop(struct tb_ring *ring)
 {
 	mutex_lock(&ring->nhi->lock);
 	mutex_lock(&ring->lock);
@@ -364,12 +367,12 @@ void ring_stop(struct tb_ring *ring)
 			 RING_TYPE(ring), ring->hop);
 		goto err;
 	}
-	ring_interrupt_active(ring, false);
+	tb_ring_interrupt_active(ring, false);
 
-	ring_iowrite32options(ring, 0, 0);
-	ring_iowrite64desc(ring, 0, 0);
-	ring_iowrite16desc(ring, 0, ring->is_tx ? 10 : 8);
-	ring_iowrite32desc(ring, 0, 12);
+	tb_ring_iowrite32options(ring, 0, 0);
+	tb_ring_iowrite64desc(ring, 0, 0);
+	tb_ring_iowrite16desc(ring, 0, ring->is_tx ? 10 : 8);
+	tb_ring_iowrite32desc(ring, 0, 12);
 	ring->head = 0;
 	ring->tail = 0;
 	ring->running = false;
@@ -386,16 +389,16 @@ err:
 }
 
 /*
- * ring_free() - free ring
+ * tb_ring_free() - free ring
  *
  * When this method returns all invocations of ring->callback will have
  * finished.
  *
  * Ring must be stopped.
  *
- * Must NOT be called from ring_frame->callback!
+ * Must NOT be called from tb_ring_frame->callback!
  */
-void ring_free(struct tb_ring *ring)
+void tb_ring_free(struct tb_ring *ring)
 {
 	mutex_lock(&ring->nhi->lock);
 	/*
@@ -428,7 +431,7 @@ void ring_free(struct tb_ring *ring)
 	mutex_unlock(&ring->nhi->lock);
 	/**
 	 * ring->work can no longer be scheduled (it is scheduled only by
-	 * nhi_interrupt_work and ring_stop). Wait for it to finish before
+	 * nhi_interrupt_work and tb_ring_stop). Wait for it to finish before
 	 * freeing the ring.
 	 */
 	flush_work(&ring->work);
diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h
index 3172429..98f57d5 100644
--- a/drivers/thunderbolt/nhi.h
+++ b/drivers/thunderbolt/nhi.h
@@ -37,7 +37,7 @@ struct tb_ring {
 	int hop;
 	int head; /* write next descriptor here */
 	int tail; /* complete next descriptor here */
-	struct ring_desc *descriptors;
+	struct tb_ring_desc *descriptors;
 	dma_addr_t descriptors_dma;
 	struct list_head queue;
 	struct list_head in_flight;
@@ -46,15 +46,16 @@ struct tb_ring {
 	bool running:1;
 };
 
-struct ring_frame;
-typedef void (*ring_cb)(struct tb_ring*, struct ring_frame*, bool canceled);
+struct tb_ring_frame;
+typedef void (*tb_ring_cb)(struct tb_ring *ring, struct tb_ring_frame *frame,
+			   bool canceled);
 
 /**
- * struct ring_frame - for use with ring_rx/ring_tx
+ * struct tb_ring_frame - for use with tb_ring_rx/tb_ring_tx
  */
-struct ring_frame {
+struct tb_ring_frame {
 	dma_addr_t buffer_phy;
-	ring_cb callback;
+	tb_ring_cb callback;
 	struct list_head list;
 	u32 size:12; /* TX: in, RX: out*/
 	u32 flags:12; /* RX: out */
@@ -62,18 +63,18 @@ struct ring_frame {
 	u32 sof:4; /* TX:in, RX: out */
 };
 
-#define TB_FRAME_SIZE 0x100    /* minimum size for ring_rx */
+#define TB_FRAME_SIZE 0x100    /* minimum size for tb_ring_rx */
 
-struct tb_ring *ring_alloc_tx(struct tb_nhi *nhi, int hop, int size);
-struct tb_ring *ring_alloc_rx(struct tb_nhi *nhi, int hop, int size);
-void ring_start(struct tb_ring *ring);
-void ring_stop(struct tb_ring *ring);
-void ring_free(struct tb_ring *ring);
+struct tb_ring *tb_ring_alloc_tx(struct tb_nhi *nhi, int hop, int size);
+struct tb_ring *tb_ring_alloc_rx(struct tb_nhi *nhi, int hop, int size);
+void tb_ring_start(struct tb_ring *ring);
+void tb_ring_stop(struct tb_ring *ring);
+void tb_ring_free(struct tb_ring *ring);
 
-int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame);
+int __tb_ring_enqueue(struct tb_ring *ring, struct tb_ring_frame *frame);
 
 /**
- * ring_rx() - enqueue a frame on an RX ring
+ * tb_ring_rx() - enqueue a frame on an RX ring
  *
  * frame->buffer, frame->buffer_phy and frame->callback have to be set. The
  * buffer must contain at least TB_FRAME_SIZE bytes.
@@ -81,34 +82,34 @@ int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame);
  * frame->callback will be invoked with frame->size, frame->flags, frame->eof,
  * frame->sof set once the frame has been received.
  *
- * If ring_stop is called after the packet has been enqueued frame->callback
+ * If tb_ring_stop is called after the packet has been enqueued frame->callback
  * will be called with canceled set to true.
  *
- * Return: Returns ESHUTDOWN if ring_stop has been called. Zero otherwise.
+ * Return: Returns ESHUTDOWN if tb_ring_stop has been called. Zero otherwise.
  */
-static inline int ring_rx(struct tb_ring *ring, struct ring_frame *frame)
+static inline int tb_ring_rx(struct tb_ring *ring, struct tb_ring_frame *frame)
 {
 	WARN_ON(ring->is_tx);
-	return __ring_enqueue(ring, frame);
+	return __tb_ring_enqueue(ring, frame);
 }
 
 /**
- * ring_tx() - enqueue a frame on an TX ring
+ * tb_ring_tx() - enqueue a frame on an TX ring
  *
  * frame->buffer, frame->buffer_phy, frame->callback, frame->size, frame->eof
  * and frame->sof have to be set.
  *
  * frame->callback will be invoked with once the frame has been transmitted.
  *
- * If ring_stop is called after the packet has been enqueued frame->callback
+ * If tb_ring_stop is called after the packet has been enqueued frame->callback
  * will be called with canceled set to true.
  *
- * Return: Returns ESHUTDOWN if ring_stop has been called. Zero otherwise.
+ * Return: Returns ESHUTDOWN if tb_ring_stop has been called. Zero otherwise.
  */
-static inline int ring_tx(struct tb_ring *ring, struct ring_frame *frame)
+static inline int tb_ring_tx(struct tb_ring *ring, struct tb_ring_frame *frame)
 {
 	WARN_ON(!ring->is_tx);
-	return __ring_enqueue(ring, frame);
+	return __tb_ring_enqueue(ring, frame);
 }
 
 #endif
diff --git a/drivers/thunderbolt/nhi_regs.h b/drivers/thunderbolt/nhi_regs.h
index 86b996c..23b7059 100644
--- a/drivers/thunderbolt/nhi_regs.h
+++ b/drivers/thunderbolt/nhi_regs.h
@@ -9,7 +9,7 @@
 
 #include <linux/types.h>
 
-enum ring_flags {
+enum tb_ring_flags {
 	RING_FLAG_ISOCH_ENABLE = 1 << 27, /* TX only? */
 	RING_FLAG_E2E_FLOW_CONTROL = 1 << 28,
 	RING_FLAG_PCI_NO_SNOOP = 1 << 29,
@@ -17,7 +17,7 @@ enum ring_flags {
 	RING_FLAG_ENABLE = 1 << 31,
 };
 
-enum ring_desc_flags {
+enum tb_ring_desc_flags {
 	RING_DESC_ISOCH = 0x1, /* TX only? */
 	RING_DESC_COMPLETED = 0x2, /* set by NHI */
 	RING_DESC_POSTED = 0x4, /* always set this */
@@ -25,17 +25,17 @@ enum ring_desc_flags {
 };
 
 /**
- * struct ring_desc - TX/RX ring entry
+ * struct tb_ring_desc - TX/RX ring entry
  *
  * For TX set length/eof/sof.
  * For RX length/eof/sof are set by the NHI.
  */
-struct ring_desc {
+struct tb_ring_desc {
 	u64 phys;
 	u32 length:12;
 	u32 eof:4;
 	u32 sof:4;
-	enum ring_desc_flags flags:12;
+	enum tb_ring_desc_flags flags:12;
 	u32 time; /* write zero */
 } __packed;
 
@@ -43,7 +43,7 @@ struct ring_desc {
 
 /*
  * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
- * 00: physical pointer to an array of struct ring_desc
+ * 00: physical pointer to an array of struct tb_ring_desc
  * 08: ring tail (set by NHI)
  * 10: ring head (index of first non posted descriptor)
  * 12: descriptor count
@@ -52,7 +52,7 @@ struct ring_desc {
 
 /*
  * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
- * 00: physical pointer to an array of struct ring_desc
+ * 00: physical pointer to an array of struct tb_ring_desc
  * 08: ring head (index of first not posted descriptor)
  * 10: ring tail (set by NHI)
  * 12: descriptor count
@@ -70,7 +70,7 @@ struct ring_desc {
 
 /*
  * 32 bytes per entry, one entry for every hop (REG_HOP_COUNT)
- * 00: enum ring_flags
+ * 00: enum tb_ring_flags
  *     If RING_FLAG_E2E_FLOW_CONTROL is set then bits 13-23 must be set to
  *     the corresponding TX hop id.
  * 04: EOF/SOF mask (ignored for RING_FLAG_RAW rings)



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

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-21 18:14                                         ` Joe Perches
  0 siblings, 0 replies; 3633+ messages in thread
From: Joe Perches @ 2014-11-21 18:14 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Andreas Noever, LKML, kernel-janitors, Julia Lawall

On Fri, 2014-11-21 at 13:21 +0100, SF Markus Elfring wrote:
> 2. Are any additional prefixes appropriate so that further name space
>    conflicts can be better avoided?

To avoid possible external naming conflicts, add tb_ prefix to
various ring_<foo> structs and functions.

Other miscellanea:

o typo/spelling fixes (releated/related, loose/lose)
o argument alignment
o comment formatting

---
Perhaps something like this?

unsigned/compiled/untested

 drivers/thunderbolt/ctl.c      |  41 ++++++-------
 drivers/thunderbolt/nhi.c      | 133 +++++++++++++++++++++--------------------
 drivers/thunderbolt/nhi.h      |  47 ++++++++-------
 drivers/thunderbolt/nhi_regs.h |  16 ++---
 4 files changed, 121 insertions(+), 116 deletions(-)

diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index 799634b..52783e0 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -17,7 +17,7 @@
 struct ctl_pkg {
 	struct tb_ctl *ctl;
 	void *buffer;
-	struct ring_frame frame;
+	struct tb_ring_frame frame;
 };
 
 #define TB_CTL_RX_PKG_COUNT 10
@@ -319,8 +319,8 @@ static struct ctl_pkg *tb_ctl_pkg_alloc(struct tb_ctl *ctl)
 
 /* RX/TX handling */
 
-static void tb_ctl_tx_callback(struct tb_ring *ring, struct ring_frame *frame,
-			       bool canceled)
+static void tb_ctl_tx_callback(struct tb_ring *ring,
+			       struct tb_ring_frame *frame, bool canceled)
 {
 	struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame);
 	tb_ctl_pkg_free(pkg);
@@ -357,7 +357,7 @@ static int tb_ctl_tx(struct tb_ctl *ctl, void *data, size_t len,
 	cpu_to_be32_array(pkg->buffer, data, len / 4);
 	*(__be32 *) (pkg->buffer + len) = tb_crc(pkg->buffer, len);
 
-	res = ring_tx(ctl->tx, &pkg->frame);
+	res = tb_ring_tx(ctl->tx, &pkg->frame);
 	if (res) /* ring is stopped */
 		tb_ctl_pkg_free(pkg);
 	return res;
@@ -386,16 +386,16 @@ static void tb_ctl_handle_plug_event(struct tb_ctl *ctl,
 
 static void tb_ctl_rx_submit(struct ctl_pkg *pkg)
 {
-	ring_rx(pkg->ctl->rx, &pkg->frame); /*
-					     * We ignore failures during stop.
-					     * All rx packets are referenced
-					     * from ctl->rx_packets, so we do
-					     * not loose them.
-					     */
+	tb_ring_rx(pkg->ctl->rx, &pkg->frame);
+	/*
+	 * We ignore failures during stop.
+	 * All rx packets are referenced from ctl->rx_packets,
+	 * so we do not lose them.
+	 */
 }
 
-static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame,
-			       bool canceled)
+static void tb_ctl_rx_callback(struct tb_ring *ring,
+			       struct tb_ring_frame *frame, bool canceled)
 {
 	struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame);
 
@@ -488,11 +488,11 @@ struct tb_ctl *tb_ctl_alloc(struct tb_nhi *nhi, hotplug_cb cb, void *cb_data)
 	if (!ctl->frame_pool)
 		goto err;
 
-	ctl->tx = ring_alloc_tx(nhi, 0, 10);
+	ctl->tx = tb_ring_alloc_tx(nhi, 0, 10);
 	if (!ctl->tx)
 		goto err;
 
-	ctl->rx = ring_alloc_rx(nhi, 0, 10);
+	ctl->rx = tb_ring_alloc_rx(nhi, 0, 10);
 	if (!ctl->rx)
 		goto err;
 
@@ -521,9 +521,9 @@ void tb_ctl_free(struct tb_ctl *ctl)
 {
 	int i;
 	if (ctl->rx)
-		ring_free(ctl->rx);
+		tb_ring_free(ctl->rx);
 	if (ctl->tx)
-		ring_free(ctl->tx);
+		tb_ring_free(ctl->tx);
 
 	/* free RX packets */
 	for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
@@ -542,8 +542,9 @@ void tb_ctl_start(struct tb_ctl *ctl)
 {
 	int i;
 	tb_ctl_info(ctl, "control channel starting...\n");
-	ring_start(ctl->tx); /* is used to ack hotplug packets, start first */
-	ring_start(ctl->rx);
+	/* is used to ack hotplug packets, start first */
+	tb_ring_start(ctl->tx);
+	tb_ring_start(ctl->rx);
 	for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
 		tb_ctl_rx_submit(ctl->rx_packets[i]);
 }
@@ -558,8 +559,8 @@ void tb_ctl_start(struct tb_ctl *ctl)
  */
 void tb_ctl_stop(struct tb_ctl *ctl)
 {
-	ring_stop(ctl->rx);
-	ring_stop(ctl->tx);
+	tb_ring_stop(ctl->rx);
+	tb_ring_stop(ctl->tx);
 
 	if (!kfifo_is_empty(&ctl->response_fifo))
 		tb_ctl_WARN(ctl, "dangling response in response_fifo\n");
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index c68fe12..552683f 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -22,7 +22,7 @@
 #define RING_TYPE(ring) ((ring)->is_tx ? "TX ring" : "RX ring")
 
 
-static int ring_interrupt_index(struct tb_ring *ring)
+static int tb_ring_interrupt_index(struct tb_ring *ring)
 {
 	int bit = ring->hop;
 	if (!ring->is_tx)
@@ -31,14 +31,14 @@ static int ring_interrupt_index(struct tb_ring *ring)
 }
 
 /**
- * ring_interrupt_active() - activate/deactivate interrupts for a single ring
+ * tb_ring_interrupt_active() - activate/deactivate interrupts for a single ring
  *
  * ring->nhi->lock must be held.
  */
-static void ring_interrupt_active(struct tb_ring *ring, bool active)
+static void tb_ring_interrupt_active(struct tb_ring *ring, bool active)
 {
-	int reg = REG_RING_INTERRUPT_BASE + ring_interrupt_index(ring) / 32;
-	int bit = ring_interrupt_index(ring) & 31;
+	int reg = REG_RING_INTERRUPT_BASE + tb_ring_interrupt_index(ring) / 32;
+	int bit = tb_ring_interrupt_index(ring) & 31;
 	int mask = 1 << bit;
 	u32 old, new;
 	old = ioread32(ring->nhi->iobase + reg);
@@ -78,7 +78,7 @@ static void nhi_disable_interrupts(struct tb_nhi *nhi)
 
 /* ring helper methods */
 
-static void __iomem *ring_desc_base(struct tb_ring *ring)
+static void __iomem *tb_ring_desc_base(struct tb_ring *ring)
 {
 	void __iomem *io = ring->nhi->iobase;
 	io += ring->is_tx ? REG_TX_RING_BASE : REG_RX_RING_BASE;
@@ -86,7 +86,7 @@ static void __iomem *ring_desc_base(struct tb_ring *ring)
 	return io;
 }
 
-static void __iomem *ring_options_base(struct tb_ring *ring)
+static void __iomem *tb_ring_options_base(struct tb_ring *ring)
 {
 	void __iomem *io = ring->nhi->iobase;
 	io += ring->is_tx ? REG_TX_OPTIONS_BASE : REG_RX_OPTIONS_BASE;
@@ -94,48 +94,49 @@ static void __iomem *ring_options_base(struct tb_ring *ring)
 	return io;
 }
 
-static void ring_iowrite16desc(struct tb_ring *ring, u32 value, u32 offset)
+static void tb_ring_iowrite16desc(struct tb_ring *ring, u32 value, u32 offset)
 {
-	iowrite16(value, ring_desc_base(ring) + offset);
+	iowrite16(value, tb_ring_desc_base(ring) + offset);
 }
 
-static void ring_iowrite32desc(struct tb_ring *ring, u32 value, u32 offset)
+static void tb_ring_iowrite32desc(struct tb_ring *ring, u32 value, u32 offset)
 {
-	iowrite32(value, ring_desc_base(ring) + offset);
+	iowrite32(value, tb_ring_desc_base(ring) + offset);
 }
 
-static void ring_iowrite64desc(struct tb_ring *ring, u64 value, u32 offset)
+static void tb_ring_iowrite64desc(struct tb_ring *ring, u64 value, u32 offset)
 {
-	iowrite32(value, ring_desc_base(ring) + offset);
-	iowrite32(value >> 32, ring_desc_base(ring) + offset + 4);
+	iowrite32(value, tb_ring_desc_base(ring) + offset);
+	iowrite32(value >> 32, tb_ring_desc_base(ring) + offset + 4);
 }
 
-static void ring_iowrite32options(struct tb_ring *ring, u32 value, u32 offset)
+static void tb_ring_iowrite32options(struct tb_ring *ring, u32 value,
+				     u32 offset)
 {
-	iowrite32(value, ring_options_base(ring) + offset);
+	iowrite32(value, tb_ring_options_base(ring) + offset);
 }
 
-static bool ring_full(struct tb_ring *ring)
+static bool tb_ring_full(struct tb_ring *ring)
 {
 	return ((ring->head + 1) % ring->size) = ring->tail;
 }
 
-static bool ring_empty(struct tb_ring *ring)
+static bool tb_ring_empty(struct tb_ring *ring)
 {
 	return ring->head = ring->tail;
 }
 
 /**
- * ring_write_descriptors() - post frames from ring->queue to the controller
+ * tb_ring_write_descriptors() - post frames from ring->queue to the controller
  *
  * ring->lock is held.
  */
-static void ring_write_descriptors(struct tb_ring *ring)
+static void tb_ring_write_descriptors(struct tb_ring *ring)
 {
-	struct ring_frame *frame, *n;
-	struct ring_desc *descriptor;
+	struct tb_ring_frame *frame, *n;
+	struct tb_ring_desc *descriptor;
 	list_for_each_entry_safe(frame, n, &ring->queue, list) {
-		if (ring_full(ring))
+		if (tb_ring_full(ring))
 			break;
 		list_move_tail(&frame->list, &ring->in_flight);
 		descriptor = &ring->descriptors[ring->head];
@@ -148,12 +149,12 @@ static void ring_write_descriptors(struct tb_ring *ring)
 			descriptor->sof = frame->sof;
 		}
 		ring->head = (ring->head + 1) % ring->size;
-		ring_iowrite16desc(ring, ring->head, ring->is_tx ? 10 : 8);
+		tb_ring_iowrite16desc(ring, ring->head, ring->is_tx ? 10 : 8);
 	}
 }
 
 /**
- * ring_work() - progress completed frames
+ * tb_ring_work() - progress completed frames
  *
  * If the ring is shutting down then all frames are marked as canceled and
  * their callbacks are invoked.
@@ -161,10 +162,10 @@ static void ring_write_descriptors(struct tb_ring *ring)
  * Otherwise we collect all completed frame from the ring buffer, write new
  * frame to the ring buffer and invoke the callbacks for the completed frames.
  */
-static void ring_work(struct work_struct *work)
+static void tb_ring_work(struct work_struct *work)
 {
 	struct tb_ring *ring = container_of(work, typeof(*ring), work);
-	struct ring_frame *frame;
+	struct tb_ring_frame *frame;
 	bool canceled = false;
 	LIST_HEAD(done);
 	mutex_lock(&ring->lock);
@@ -177,7 +178,7 @@ static void ring_work(struct work_struct *work)
 		goto invoke_callback;
 	}
 
-	while (!ring_empty(ring)) {
+	while (!tb_ring_empty(ring)) {
 		if (!(ring->descriptors[ring->tail].flags
 				& RING_DESC_COMPLETED))
 			break;
@@ -209,7 +210,7 @@ static void ring_work(struct work_struct *work)
 		}
 		ring->tail = (ring->tail + 1) % ring->size;
 	}
-	ring_write_descriptors(ring);
+	tb_ring_write_descriptors(ring);
 
 invoke_callback:
 	mutex_unlock(&ring->lock); /* allow callbacks to schedule new work */
@@ -224,13 +225,13 @@ invoke_callback:
 	}
 }
 
-int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame)
+int __tb_ring_enqueue(struct tb_ring *ring, struct tb_ring_frame *frame)
 {
 	int ret = 0;
 	mutex_lock(&ring->lock);
 	if (ring->running) {
 		list_add_tail(&frame->list, &ring->queue);
-		ring_write_descriptors(ring);
+		tb_ring_write_descriptors(ring);
 	} else {
 		ret = -ESHUTDOWN;
 	}
@@ -238,8 +239,8 @@ int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame)
 	return ret;
 }
 
-static struct tb_ring *ring_alloc(struct tb_nhi *nhi, u32 hop, int size,
-				  bool transmit)
+static struct tb_ring *tb_ring_alloc(struct tb_nhi *nhi, u32 hop, int size,
+				     bool transmit)
 {
 	struct tb_ring *ring = NULL;
 	dev_info(&nhi->pdev->dev, "allocating %s ring %d of size %d\n",
@@ -264,7 +265,7 @@ static struct tb_ring *ring_alloc(struct tb_nhi *nhi, u32 hop, int size,
 	mutex_init(&ring->lock);
 	INIT_LIST_HEAD(&ring->queue);
 	INIT_LIST_HEAD(&ring->in_flight);
-	INIT_WORK(&ring->work, ring_work);
+	INIT_WORK(&ring->work, tb_ring_work);
 
 	ring->nhi = nhi;
 	ring->hop = hop;
@@ -294,22 +295,22 @@ err:
 	return NULL;
 }
 
-struct tb_ring *ring_alloc_tx(struct tb_nhi *nhi, int hop, int size)
+struct tb_ring *tb_ring_alloc_tx(struct tb_nhi *nhi, int hop, int size)
 {
-	return ring_alloc(nhi, hop, size, true);
+	return tb_ring_alloc(nhi, hop, size, true);
 }
 
-struct tb_ring *ring_alloc_rx(struct tb_nhi *nhi, int hop, int size)
+struct tb_ring *tb_ring_alloc_rx(struct tb_nhi *nhi, int hop, int size)
 {
-	return ring_alloc(nhi, hop, size, false);
+	return tb_ring_alloc(nhi, hop, size, false);
 }
 
 /**
- * ring_start() - enable a ring
+ * tb_ring_start() - enable a ring
  *
- * Must not be invoked in parallel with ring_stop().
+ * Must not be invoked in parallel with tb_ring_stop().
  */
-void ring_start(struct tb_ring *ring)
+void tb_ring_start(struct tb_ring *ring)
 {
 	mutex_lock(&ring->nhi->lock);
 	mutex_lock(&ring->lock);
@@ -320,20 +321,21 @@ void ring_start(struct tb_ring *ring)
 	dev_info(&ring->nhi->pdev->dev, "starting %s %d\n",
 		 RING_TYPE(ring), ring->hop);
 
-	ring_iowrite64desc(ring, ring->descriptors_dma, 0);
+	tb_ring_iowrite64desc(ring, ring->descriptors_dma, 0);
 	if (ring->is_tx) {
-		ring_iowrite32desc(ring, ring->size, 12);
-		ring_iowrite32options(ring, 0, 4); /* time releated ? */
-		ring_iowrite32options(ring,
-				      RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
+		tb_ring_iowrite32desc(ring, ring->size, 12);
+		tb_ring_iowrite32options(ring, 0, 4); /* time related ? */
+		tb_ring_iowrite32options(ring,
+					 RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
 	} else {
-		ring_iowrite32desc(ring,
-				   (TB_FRAME_SIZE << 16) | ring->size, 12);
-		ring_iowrite32options(ring, 0xffffffff, 4); /* SOF EOF mask */
-		ring_iowrite32options(ring,
-				      RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
+		tb_ring_iowrite32desc(ring,
+				      (TB_FRAME_SIZE << 16) | ring->size, 12);
+		/* SOF EOF mask */
+		tb_ring_iowrite32options(ring, 0xffffffff, 4);
+		tb_ring_iowrite32options(ring,
+					 RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
 	}
-	ring_interrupt_active(ring, true);
+	tb_ring_interrupt_active(ring, true);
 	ring->running = true;
 err:
 	mutex_unlock(&ring->lock);
@@ -342,18 +344,19 @@ err:
 
 
 /**
- * ring_stop() - shutdown a ring
+ * tb_ring_stop() - shutdown a ring
  *
  * Must not be invoked from a callback.
  *
- * This method will disable the ring. Further calls to ring_tx/ring_rx will
- * return -ESHUTDOWN until ring_stop has been called.
+ * This method will disable the ring.
+ * Further calls to tb_ring_tx/tb_ring_rx will return -ESHUTDOWN
+ * until tb_ring_stop has been called.
  *
  * All enqueued frames will be canceled and their callbacks will be executed
  * with frame->canceled set to true (on the callback thread). This method
  * returns only after all callback invocations have finished.
  */
-void ring_stop(struct tb_ring *ring)
+void tb_ring_stop(struct tb_ring *ring)
 {
 	mutex_lock(&ring->nhi->lock);
 	mutex_lock(&ring->lock);
@@ -364,12 +367,12 @@ void ring_stop(struct tb_ring *ring)
 			 RING_TYPE(ring), ring->hop);
 		goto err;
 	}
-	ring_interrupt_active(ring, false);
+	tb_ring_interrupt_active(ring, false);
 
-	ring_iowrite32options(ring, 0, 0);
-	ring_iowrite64desc(ring, 0, 0);
-	ring_iowrite16desc(ring, 0, ring->is_tx ? 10 : 8);
-	ring_iowrite32desc(ring, 0, 12);
+	tb_ring_iowrite32options(ring, 0, 0);
+	tb_ring_iowrite64desc(ring, 0, 0);
+	tb_ring_iowrite16desc(ring, 0, ring->is_tx ? 10 : 8);
+	tb_ring_iowrite32desc(ring, 0, 12);
 	ring->head = 0;
 	ring->tail = 0;
 	ring->running = false;
@@ -386,16 +389,16 @@ err:
 }
 
 /*
- * ring_free() - free ring
+ * tb_ring_free() - free ring
  *
  * When this method returns all invocations of ring->callback will have
  * finished.
  *
  * Ring must be stopped.
  *
- * Must NOT be called from ring_frame->callback!
+ * Must NOT be called from tb_ring_frame->callback!
  */
-void ring_free(struct tb_ring *ring)
+void tb_ring_free(struct tb_ring *ring)
 {
 	mutex_lock(&ring->nhi->lock);
 	/*
@@ -428,7 +431,7 @@ void ring_free(struct tb_ring *ring)
 	mutex_unlock(&ring->nhi->lock);
 	/**
 	 * ring->work can no longer be scheduled (it is scheduled only by
-	 * nhi_interrupt_work and ring_stop). Wait for it to finish before
+	 * nhi_interrupt_work and tb_ring_stop). Wait for it to finish before
 	 * freeing the ring.
 	 */
 	flush_work(&ring->work);
diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h
index 3172429..98f57d5 100644
--- a/drivers/thunderbolt/nhi.h
+++ b/drivers/thunderbolt/nhi.h
@@ -37,7 +37,7 @@ struct tb_ring {
 	int hop;
 	int head; /* write next descriptor here */
 	int tail; /* complete next descriptor here */
-	struct ring_desc *descriptors;
+	struct tb_ring_desc *descriptors;
 	dma_addr_t descriptors_dma;
 	struct list_head queue;
 	struct list_head in_flight;
@@ -46,15 +46,16 @@ struct tb_ring {
 	bool running:1;
 };
 
-struct ring_frame;
-typedef void (*ring_cb)(struct tb_ring*, struct ring_frame*, bool canceled);
+struct tb_ring_frame;
+typedef void (*tb_ring_cb)(struct tb_ring *ring, struct tb_ring_frame *frame,
+			   bool canceled);
 
 /**
- * struct ring_frame - for use with ring_rx/ring_tx
+ * struct tb_ring_frame - for use with tb_ring_rx/tb_ring_tx
  */
-struct ring_frame {
+struct tb_ring_frame {
 	dma_addr_t buffer_phy;
-	ring_cb callback;
+	tb_ring_cb callback;
 	struct list_head list;
 	u32 size:12; /* TX: in, RX: out*/
 	u32 flags:12; /* RX: out */
@@ -62,18 +63,18 @@ struct ring_frame {
 	u32 sof:4; /* TX:in, RX: out */
 };
 
-#define TB_FRAME_SIZE 0x100    /* minimum size for ring_rx */
+#define TB_FRAME_SIZE 0x100    /* minimum size for tb_ring_rx */
 
-struct tb_ring *ring_alloc_tx(struct tb_nhi *nhi, int hop, int size);
-struct tb_ring *ring_alloc_rx(struct tb_nhi *nhi, int hop, int size);
-void ring_start(struct tb_ring *ring);
-void ring_stop(struct tb_ring *ring);
-void ring_free(struct tb_ring *ring);
+struct tb_ring *tb_ring_alloc_tx(struct tb_nhi *nhi, int hop, int size);
+struct tb_ring *tb_ring_alloc_rx(struct tb_nhi *nhi, int hop, int size);
+void tb_ring_start(struct tb_ring *ring);
+void tb_ring_stop(struct tb_ring *ring);
+void tb_ring_free(struct tb_ring *ring);
 
-int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame);
+int __tb_ring_enqueue(struct tb_ring *ring, struct tb_ring_frame *frame);
 
 /**
- * ring_rx() - enqueue a frame on an RX ring
+ * tb_ring_rx() - enqueue a frame on an RX ring
  *
  * frame->buffer, frame->buffer_phy and frame->callback have to be set. The
  * buffer must contain at least TB_FRAME_SIZE bytes.
@@ -81,34 +82,34 @@ int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame);
  * frame->callback will be invoked with frame->size, frame->flags, frame->eof,
  * frame->sof set once the frame has been received.
  *
- * If ring_stop is called after the packet has been enqueued frame->callback
+ * If tb_ring_stop is called after the packet has been enqueued frame->callback
  * will be called with canceled set to true.
  *
- * Return: Returns ESHUTDOWN if ring_stop has been called. Zero otherwise.
+ * Return: Returns ESHUTDOWN if tb_ring_stop has been called. Zero otherwise.
  */
-static inline int ring_rx(struct tb_ring *ring, struct ring_frame *frame)
+static inline int tb_ring_rx(struct tb_ring *ring, struct tb_ring_frame *frame)
 {
 	WARN_ON(ring->is_tx);
-	return __ring_enqueue(ring, frame);
+	return __tb_ring_enqueue(ring, frame);
 }
 
 /**
- * ring_tx() - enqueue a frame on an TX ring
+ * tb_ring_tx() - enqueue a frame on an TX ring
  *
  * frame->buffer, frame->buffer_phy, frame->callback, frame->size, frame->eof
  * and frame->sof have to be set.
  *
  * frame->callback will be invoked with once the frame has been transmitted.
  *
- * If ring_stop is called after the packet has been enqueued frame->callback
+ * If tb_ring_stop is called after the packet has been enqueued frame->callback
  * will be called with canceled set to true.
  *
- * Return: Returns ESHUTDOWN if ring_stop has been called. Zero otherwise.
+ * Return: Returns ESHUTDOWN if tb_ring_stop has been called. Zero otherwise.
  */
-static inline int ring_tx(struct tb_ring *ring, struct ring_frame *frame)
+static inline int tb_ring_tx(struct tb_ring *ring, struct tb_ring_frame *frame)
 {
 	WARN_ON(!ring->is_tx);
-	return __ring_enqueue(ring, frame);
+	return __tb_ring_enqueue(ring, frame);
 }
 
 #endif
diff --git a/drivers/thunderbolt/nhi_regs.h b/drivers/thunderbolt/nhi_regs.h
index 86b996c..23b7059 100644
--- a/drivers/thunderbolt/nhi_regs.h
+++ b/drivers/thunderbolt/nhi_regs.h
@@ -9,7 +9,7 @@
 
 #include <linux/types.h>
 
-enum ring_flags {
+enum tb_ring_flags {
 	RING_FLAG_ISOCH_ENABLE = 1 << 27, /* TX only? */
 	RING_FLAG_E2E_FLOW_CONTROL = 1 << 28,
 	RING_FLAG_PCI_NO_SNOOP = 1 << 29,
@@ -17,7 +17,7 @@ enum ring_flags {
 	RING_FLAG_ENABLE = 1 << 31,
 };
 
-enum ring_desc_flags {
+enum tb_ring_desc_flags {
 	RING_DESC_ISOCH = 0x1, /* TX only? */
 	RING_DESC_COMPLETED = 0x2, /* set by NHI */
 	RING_DESC_POSTED = 0x4, /* always set this */
@@ -25,17 +25,17 @@ enum ring_desc_flags {
 };
 
 /**
- * struct ring_desc - TX/RX ring entry
+ * struct tb_ring_desc - TX/RX ring entry
  *
  * For TX set length/eof/sof.
  * For RX length/eof/sof are set by the NHI.
  */
-struct ring_desc {
+struct tb_ring_desc {
 	u64 phys;
 	u32 length:12;
 	u32 eof:4;
 	u32 sof:4;
-	enum ring_desc_flags flags:12;
+	enum tb_ring_desc_flags flags:12;
 	u32 time; /* write zero */
 } __packed;
 
@@ -43,7 +43,7 @@ struct ring_desc {
 
 /*
  * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
- * 00: physical pointer to an array of struct ring_desc
+ * 00: physical pointer to an array of struct tb_ring_desc
  * 08: ring tail (set by NHI)
  * 10: ring head (index of first non posted descriptor)
  * 12: descriptor count
@@ -52,7 +52,7 @@ struct ring_desc {
 
 /*
  * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
- * 00: physical pointer to an array of struct ring_desc
+ * 00: physical pointer to an array of struct tb_ring_desc
  * 08: ring head (index of first not posted descriptor)
  * 10: ring tail (set by NHI)
  * 12: descriptor count
@@ -70,7 +70,7 @@ struct ring_desc {
 
 /*
  * 32 bytes per entry, one entry for every hop (REG_HOP_COUNT)
- * 00: enum ring_flags
+ * 00: enum tb_ring_flags
  *     If RING_FLAG_E2E_FLOW_CONTROL is set then bits 13-23 must be set to
  *     the corresponding TX hop id.
  * 04: EOF/SOF mask (ignored for RING_FLAG_RAW rings)



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

* [PATCH 1/1] ALSA: sb: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-21 18:35                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 18:35 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 19:32:02 +0100

The functions release_and_free_resource() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/isa/sb/emu8000_synth.c | 3 +--
 sound/isa/sb/sb_common.c     | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c
index 4e3fcfb..95b39be 100644
--- a/sound/isa/sb/emu8000_synth.c
+++ b/sound/isa/sb/emu8000_synth.c
@@ -105,8 +105,7 @@ static int snd_emu8000_delete_device(struct snd_seq_device *dev)
 		snd_device_free(dev->card, hw->pcm);
 	if (hw->emu)
 		snd_emux_free(hw->emu);
-	if (hw->memhdr)
-		snd_util_memhdr_free(hw->memhdr);
+	snd_util_memhdr_free(hw->memhdr);
 	hw->emu = NULL;
 	hw->memhdr = NULL;
 	return 0;
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
index 3ef9906..f22b448 100644
--- a/sound/isa/sb/sb_common.c
+++ b/sound/isa/sb/sb_common.c
@@ -184,8 +184,7 @@ static int snd_sbdsp_probe(struct snd_sb * chip)
 
 static int snd_sbdsp_free(struct snd_sb *chip)
 {
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 #ifdef CONFIG_ISA
-- 
2.1.3


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

* [PATCH 1/1] ALSA: sb: Deletion of unnecessary checks before two function calls
@ 2014-11-21 18:35                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 18:35 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 19:32:02 +0100

The functions release_and_free_resource() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/isa/sb/emu8000_synth.c | 3 +--
 sound/isa/sb/sb_common.c     | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c
index 4e3fcfb..95b39be 100644
--- a/sound/isa/sb/emu8000_synth.c
+++ b/sound/isa/sb/emu8000_synth.c
@@ -105,8 +105,7 @@ static int snd_emu8000_delete_device(struct snd_seq_device *dev)
 		snd_device_free(dev->card, hw->pcm);
 	if (hw->emu)
 		snd_emux_free(hw->emu);
-	if (hw->memhdr)
-		snd_util_memhdr_free(hw->memhdr);
+	snd_util_memhdr_free(hw->memhdr);
 	hw->emu = NULL;
 	hw->memhdr = NULL;
 	return 0;
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
index 3ef9906..f22b448 100644
--- a/sound/isa/sb/sb_common.c
+++ b/sound/isa/sb/sb_common.c
@@ -184,8 +184,7 @@ static int snd_sbdsp_probe(struct snd_sb * chip)
 
 static int snd_sbdsp_free(struct snd_sb *chip)
 {
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 #ifdef CONFIG_ISA
-- 
2.1.3


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

* [PATCH 1/1] ALSA: sb: Deletion of unnecessary checks before two function calls
@ 2014-11-21 18:35                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 18:35 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 19:32:02 +0100

The functions release_and_free_resource() and snd_util_memhdr_free() test
whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/isa/sb/emu8000_synth.c | 3 +--
 sound/isa/sb/sb_common.c     | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c
index 4e3fcfb..95b39be 100644
--- a/sound/isa/sb/emu8000_synth.c
+++ b/sound/isa/sb/emu8000_synth.c
@@ -105,8 +105,7 @@ static int snd_emu8000_delete_device(struct snd_seq_device *dev)
 		snd_device_free(dev->card, hw->pcm);
 	if (hw->emu)
 		snd_emux_free(hw->emu);
-	if (hw->memhdr)
-		snd_util_memhdr_free(hw->memhdr);
+	snd_util_memhdr_free(hw->memhdr);
 	hw->emu = NULL;
 	hw->memhdr = NULL;
 	return 0;
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
index 3ef9906..f22b448 100644
--- a/sound/isa/sb/sb_common.c
+++ b/sound/isa/sb/sb_common.c
@@ -184,8 +184,7 @@ static int snd_sbdsp_probe(struct snd_sb * chip)
 
 static int snd_sbdsp_free(struct snd_sb *chip)
 {
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 #ifdef CONFIG_ISA
-- 
2.1.3

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

* Re: [PATCH 1/1] ALSA: core: Deletion of unnecessary checks before two function calls
  2014-11-21 17:40                                   ` SF Markus Elfring
@ 2014-11-21 19:07                                     ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-21 19:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Julia Lawall

At Fri, 21 Nov 2014 18:40:49 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 18:34:48 +0100
> 
> The functions snd_seq_oss_timer_delete() and vunmap() perform also input
> parameter validation. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/core/seq/oss/seq_oss_init.c | 9 +++------
>  sound/core/sgbuf.c                | 3 +--
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
> index b9184d2..b0e32e1 100644
> --- a/sound/core/seq/oss/seq_oss_init.c
> +++ b/sound/core/seq/oss/seq_oss_init.c
> @@ -403,14 +403,11 @@ free_devinfo(void *private)
>  {
>  	struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private;
>  
> -	if (dp->timer)
> -		snd_seq_oss_timer_delete(dp->timer);
> +	snd_seq_oss_timer_delete(dp->timer);
>  		
> -	if (dp->writeq)
> -		snd_seq_oss_writeq_delete(dp->writeq);
> +	snd_seq_oss_writeq_delete(dp->writeq);
>  
> -	if (dp->readq)
> -		snd_seq_oss_readq_delete(dp->readq);
> +	snd_seq_oss_readq_delete(dp->readq);
>  	
>  	kfree(dp);
>  }
> diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
> index 0a41850..84fffab 100644
> --- a/sound/core/sgbuf.c
> +++ b/sound/core/sgbuf.c
> @@ -39,8 +39,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
>  	if (! sgbuf)
>  		return -EINVAL;
>  
> -	if (dmab->area)
> -		vunmap(dmab->area);
> +	vunmap(dmab->area);
>  	dmab->area = NULL;
>  
>  	tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
> -- 
> 2.1.3
> 

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

* Re: [PATCH 1/1] ALSA: core: Deletion of unnecessary checks before two function calls
@ 2014-11-21 19:07                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-21 19:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Julia Lawall

At Fri, 21 Nov 2014 18:40:49 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 18:34:48 +0100
> 
> The functions snd_seq_oss_timer_delete() and vunmap() perform also input
> parameter validation. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/core/seq/oss/seq_oss_init.c | 9 +++------
>  sound/core/sgbuf.c                | 3 +--
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
> index b9184d2..b0e32e1 100644
> --- a/sound/core/seq/oss/seq_oss_init.c
> +++ b/sound/core/seq/oss/seq_oss_init.c
> @@ -403,14 +403,11 @@ free_devinfo(void *private)
>  {
>  	struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private;
>  
> -	if (dp->timer)
> -		snd_seq_oss_timer_delete(dp->timer);
> +	snd_seq_oss_timer_delete(dp->timer);
>  		
> -	if (dp->writeq)
> -		snd_seq_oss_writeq_delete(dp->writeq);
> +	snd_seq_oss_writeq_delete(dp->writeq);
>  
> -	if (dp->readq)
> -		snd_seq_oss_readq_delete(dp->readq);
> +	snd_seq_oss_readq_delete(dp->readq);
>  	
>  	kfree(dp);
>  }
> diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
> index 0a41850..84fffab 100644
> --- a/sound/core/sgbuf.c
> +++ b/sound/core/sgbuf.c
> @@ -39,8 +39,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
>  	if (! sgbuf)
>  		return -EINVAL;
>  
> -	if (dmab->area)
> -		vunmap(dmab->area);
> +	vunmap(dmab->area);
>  	dmab->area = NULL;
>  
>  	tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
> -- 
> 2.1.3
> 

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

* Re: [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and_free_resource"
  2014-11-21 18:11                                   ` [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and SF Markus Elfring
@ 2014-11-21 19:08                                     ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-21 19:08 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Julia Lawall

At Fri, 21 Nov 2014 19:11:47 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 19:05:50 +0100
> 
> The release_and_free_resource() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/isa/es1688/es1688_lib.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
> index b3b4f15..fb259491 100644
> --- a/sound/isa/es1688/es1688_lib.c
> +++ b/sound/isa/es1688/es1688_lib.c
> @@ -614,8 +614,7 @@ static int snd_es1688_free(struct snd_es1688 *chip)
>  {
>  	if (chip->hardware != ES1688_HW_UNDEF)
>  		snd_es1688_init(chip, 0);
> -	if (chip->res_port)
> -		release_and_free_resource(chip->res_port);
> +	release_and_free_resource(chip->res_port);
>  	if (chip->irq >= 0)
>  		free_irq(chip->irq, (void *) chip);
>  	if (chip->dma8 >= 0) {
> -- 
> 2.1.3
> 

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

* Re: [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release
@ 2014-11-21 19:08                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-21 19:08 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Julia Lawall

At Fri, 21 Nov 2014 19:11:47 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 19:05:50 +0100
> 
> The release_and_free_resource() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/isa/es1688/es1688_lib.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
> index b3b4f15..fb259491 100644
> --- a/sound/isa/es1688/es1688_lib.c
> +++ b/sound/isa/es1688/es1688_lib.c
> @@ -614,8 +614,7 @@ static int snd_es1688_free(struct snd_es1688 *chip)
>  {
>  	if (chip->hardware != ES1688_HW_UNDEF)
>  		snd_es1688_init(chip, 0);
> -	if (chip->res_port)
> -		release_and_free_resource(chip->res_port);
> +	release_and_free_resource(chip->res_port);
>  	if (chip->irq >= 0)
>  		free_irq(chip->irq, (void *) chip);
>  	if (chip->dma8 >= 0) {
> -- 
> 2.1.3
> 

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

* Re: [PATCH 1/1] ALSA: sb: Deletion of unnecessary checks before two function calls
  2014-11-21 18:35                                   ` SF Markus Elfring
@ 2014-11-21 19:08                                     ` Takashi Iwai
  -1 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-21 19:08 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Julia Lawall

At Fri, 21 Nov 2014 19:35:18 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 19:32:02 +0100
> 
> The functions release_and_free_resource() and snd_util_memhdr_free() test
> whether their argument is NULL and then return immediately.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/isa/sb/emu8000_synth.c | 3 +--
>  sound/isa/sb/sb_common.c     | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c
> index 4e3fcfb..95b39be 100644
> --- a/sound/isa/sb/emu8000_synth.c
> +++ b/sound/isa/sb/emu8000_synth.c
> @@ -105,8 +105,7 @@ static int snd_emu8000_delete_device(struct snd_seq_device *dev)
>  		snd_device_free(dev->card, hw->pcm);
>  	if (hw->emu)
>  		snd_emux_free(hw->emu);
> -	if (hw->memhdr)
> -		snd_util_memhdr_free(hw->memhdr);
> +	snd_util_memhdr_free(hw->memhdr);
>  	hw->emu = NULL;
>  	hw->memhdr = NULL;
>  	return 0;
> diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
> index 3ef9906..f22b448 100644
> --- a/sound/isa/sb/sb_common.c
> +++ b/sound/isa/sb/sb_common.c
> @@ -184,8 +184,7 @@ static int snd_sbdsp_probe(struct snd_sb * chip)
>  
>  static int snd_sbdsp_free(struct snd_sb *chip)
>  {
> -	if (chip->res_port)
> -		release_and_free_resource(chip->res_port);
> +	release_and_free_resource(chip->res_port);
>  	if (chip->irq >= 0)
>  		free_irq(chip->irq, (void *) chip);
>  #ifdef CONFIG_ISA
> -- 
> 2.1.3
> 

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

* Re: [PATCH 1/1] ALSA: sb: Deletion of unnecessary checks before two function calls
@ 2014-11-21 19:08                                     ` Takashi Iwai
  0 siblings, 0 replies; 3633+ messages in thread
From: Takashi Iwai @ 2014-11-21 19:08 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jaroslav Kysela, alsa-devel, LKML, kernel-janitors, Julia Lawall

At Fri, 21 Nov 2014 19:35:18 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 19:32:02 +0100
> 
> The functions release_and_free_resource() and snd_util_memhdr_free() test
> whether their argument is NULL and then return immediately.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

> ---
>  sound/isa/sb/emu8000_synth.c | 3 +--
>  sound/isa/sb/sb_common.c     | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c
> index 4e3fcfb..95b39be 100644
> --- a/sound/isa/sb/emu8000_synth.c
> +++ b/sound/isa/sb/emu8000_synth.c
> @@ -105,8 +105,7 @@ static int snd_emu8000_delete_device(struct snd_seq_device *dev)
>  		snd_device_free(dev->card, hw->pcm);
>  	if (hw->emu)
>  		snd_emux_free(hw->emu);
> -	if (hw->memhdr)
> -		snd_util_memhdr_free(hw->memhdr);
> +	snd_util_memhdr_free(hw->memhdr);
>  	hw->emu = NULL;
>  	hw->memhdr = NULL;
>  	return 0;
> diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
> index 3ef9906..f22b448 100644
> --- a/sound/isa/sb/sb_common.c
> +++ b/sound/isa/sb/sb_common.c
> @@ -184,8 +184,7 @@ static int snd_sbdsp_probe(struct snd_sb * chip)
>  
>  static int snd_sbdsp_free(struct snd_sb *chip)
>  {
> -	if (chip->res_port)
> -		release_and_free_resource(chip->res_port);
> +	release_and_free_resource(chip->res_port);
>  	if (chip->irq >= 0)
>  		free_irq(chip->irq, (void *) chip);
>  #ifdef CONFIG_ISA
> -- 
> 2.1.3
> 

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] IDE: Deletion of an unnecessary check before the function call "module_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-21 19:26                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 19:26 UTC (permalink / raw)
  To: David S. Miller, linux-ide; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 20:22:32 +0100

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/ide/ide.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 2ce6268..e29b02c 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -101,8 +101,7 @@ void ide_device_put(ide_drive_t *drive)
 	struct device *host_dev = drive->hwif->host->dev[0];
 	struct module *module = host_dev ? host_dev->driver->owner : NULL;
 
-	if (module)
-		module_put(module);
+	module_put(module);
 #endif
 	put_device(&drive->gendev);
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] IDE: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-21 19:26                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 19:26 UTC (permalink / raw)
  To: David S. Miller, linux-ide; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 20:22:32 +0100

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/ide/ide.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 2ce6268..e29b02c 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -101,8 +101,7 @@ void ide_device_put(ide_drive_t *drive)
 	struct device *host_dev = drive->hwif->host->dev[0];
 	struct module *module = host_dev ? host_dev->driver->owner : NULL;
 
-	if (module)
-		module_put(module);
+	module_put(module);
 #endif
 	put_device(&drive->gendev);
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] IDE: Deletion of an unnecessary check before the function call "module_put"
@ 2014-11-21 19:26                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 19:26 UTC (permalink / raw)
  To: David S. Miller, linux-ide; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 20:22:32 +0100

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/ide/ide.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 2ce6268..e29b02c 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -101,8 +101,7 @@ void ide_device_put(ide_drive_t *drive)
 	struct device *host_dev = drive->hwif->host->dev[0];
 	struct module *module = host_dev ? host_dev->driver->owner : NULL;
 
-	if (module)
-		module_put(module);
+	module_put(module);
 #endif
 	put_device(&drive->gendev);
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put"
  2014-11-20 13:28                                   ` SF Markus Elfring
@ 2014-11-21 20:14                                     ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:14 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:28:25 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:22:47 +0100
> 
> The of_dev_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put"
@ 2014-11-21 20:14                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:14 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:28:25 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:22:47 +0100
> 
> The of_dev_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
  2014-11-20 13:50                                   ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-21 20:14                                     ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:14 UTC (permalink / raw)
  To: elfring
  Cc: michal.simek, netdev, linux-arm-kernel, linux-kernel,
	kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:50:26 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
@ 2014-11-21 20:14                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:14 UTC (permalink / raw)
  To: elfring
  Cc: netdev, kernel-janitors, michal.simek, linux-kernel,
	julia.lawall, linux-arm-kernel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:50:26 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
@ 2014-11-21 20:14                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:50:26 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
@ 2014-11-21 20:14                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:50:26 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-20 14:25                                   ` SF Markus Elfring
  (?)
@ 2014-11-21 20:15                                     ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:15 UTC (permalink / raw)
  To: elfring
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 15:25:27 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 15:15:21 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

This does not apply to the net-next tree, please respin.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-21 20:15                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:15 UTC (permalink / raw)
  To: elfring
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall, devel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 15:25:27 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 15:15:21 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

This does not apply to the net-next tree, please respin.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-21 20:15                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:15 UTC (permalink / raw)
  To: elfring
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 15:25:27 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 15:15:21 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

This does not apply to the net-next tree, please respin.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree"
  2014-11-20 15:16                                   ` SF Markus Elfring
@ 2014-11-21 20:16                                     ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:16 UTC (permalink / raw)
  To: elfring
  Cc: j.dumon, linux-usb, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:16:16 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 16:11:56 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree"
@ 2014-11-21 20:16                                     ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 20:16 UTC (permalink / raw)
  To: elfring
  Cc: j.dumon, linux-usb, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:16:16 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 16:11:56 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] target: Deletion of unnecessary checks before the function call "module_put"
  2014-11-21  9:30                                   ` SF Markus Elfring
@ 2014-11-21 21:57                                     ` Nicholas A. Bellinger
  -1 siblings, 0 replies; 3633+ messages in thread
From: Nicholas A. Bellinger @ 2014-11-21 21:57 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: target-devel, linux-scsi, LKML, kernel-janitors, Julia Lawall

On Fri, 2014-11-21 at 10:30 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 10:25:45 +0100
> 
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/target/iscsi/iscsi_target_transport.c | 3 +--
>  drivers/target/target_core_hba.c              | 6 ++----
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 

Applied to target-pending/for-next.

Thanks Markus!

--nab


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] target: Deletion of unnecessary checks before the function call "module_put"
@ 2014-11-21 21:57                                     ` Nicholas A. Bellinger
  0 siblings, 0 replies; 3633+ messages in thread
From: Nicholas A. Bellinger @ 2014-11-21 21:57 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: target-devel, linux-scsi, LKML, kernel-janitors, Julia Lawall

On Fri, 2014-11-21 at 10:30 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 10:25:45 +0100
> 
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/target/iscsi/iscsi_target_transport.c | 3 +--
>  drivers/target/target_core_hba.c              | 6 ++----
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 

Applied to target-pending/for-next.

Thanks Markus!

--nab


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-21 20:15                                     ` David Miller
  (?)
@ 2014-11-21 22:15                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 22:15 UTC (permalink / raw)
  To: David Miller
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

> This does not apply to the net-next tree, please respin.

Thanks for your reply.

How do you think about to try out the scripts which I published
in March to get more constructive feedback?
Will they run faster for another analysis on current
Linux source files with your test systems (than my computer)?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-21 22:15                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 22:15 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall, devel

> This does not apply to the net-next tree, please respin.

Thanks for your reply.

How do you think about to try out the scripts which I published
in March to get more constructive feedback?
Will they run faster for another analysis on current
Linux source files with your test systems (than my computer)?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-21 22:15                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 22:15 UTC (permalink / raw)
  To: David Miller
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

> This does not apply to the net-next tree, please respin.

Thanks for your reply.

How do you think about to try out the scripts which I published
in March to get more constructive feedback?
Will they run faster for another analysis on current
Linux source files with your test systems (than my computer)?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-21 22:15                                       ` SF Markus Elfring
  (?)
@ 2014-11-21 22:27                                         ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 22:27 UTC (permalink / raw)
  To: elfring
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 23:15:42 +0100

>> This does not apply to the net-next tree, please respin.
> 
> Thanks for your reply.
> 
> How do you think about to try out the scripts which I published
> in March to get more constructive feedback?

This has nothing to do with me asking you to frame your patches
against the correct tree.

If I had time to investigate automation of changes using such
tools, I would participate in such discussions, but I don't.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-21 22:27                                         ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 22:27 UTC (permalink / raw)
  To: elfring
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall, devel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 23:15:42 +0100

>> This does not apply to the net-next tree, please respin.
> 
> Thanks for your reply.
> 
> How do you think about to try out the scripts which I published
> in March to get more constructive feedback?

This has nothing to do with me asking you to frame your patches
against the correct tree.

If I had time to investigate automation of changes using such
tools, I would participate in such discussions, but I don't.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-21 22:27                                         ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-21 22:27 UTC (permalink / raw)
  To: elfring
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 23:15:42 +0100

>> This does not apply to the net-next tree, please respin.
> 
> Thanks for your reply.
> 
> How do you think about to try out the scripts which I published
> in March to get more constructive feedback?

This has nothing to do with me asking you to frame your patches
against the correct tree.

If I had time to investigate automation of changes using such
tools, I would participate in such discussions, but I don't.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] [IA64] Deletion of unnecessary checks before the function call "unw_remove_unwind_table"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-21 23:01                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 23:01 UTC (permalink / raw)
  To: Fenghua Yu, Tony Luck, linux-ia64; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 23:57:28 +0100

The unw_remove_unwind_table() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/ia64/kernel/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 24603be..30ff27d 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -946,8 +946,6 @@ module_finalize (const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *mo
 void
 module_arch_cleanup (struct module *mod)
 {
-	if (mod->arch.init_unw_table)
-		unw_remove_unwind_table(mod->arch.init_unw_table);
-	if (mod->arch.core_unw_table)
-		unw_remove_unwind_table(mod->arch.core_unw_table);
+	unw_remove_unwind_table(mod->arch.init_unw_table);
+	unw_remove_unwind_table(mod->arch.core_unw_table);
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] [IA64] Deletion of unnecessary checks before the function call "unw_remove_unwind_table"
@ 2014-11-21 23:01                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-21 23:01 UTC (permalink / raw)
  To: Fenghua Yu, Tony Luck, linux-ia64; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 23:57:28 +0100

The unw_remove_unwind_table() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/ia64/kernel/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 24603be..30ff27d 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -946,8 +946,6 @@ module_finalize (const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *mo
 void
 module_arch_cleanup (struct module *mod)
 {
-	if (mod->arch.init_unw_table)
-		unw_remove_unwind_table(mod->arch.init_unw_table);
-	if (mod->arch.core_unw_table)
-		unw_remove_unwind_table(mod->arch.core_unw_table);
+	unw_remove_unwind_table(mod->arch.init_unw_table);
+	unw_remove_unwind_table(mod->arch.core_unw_table);
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-22 10:00                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 10:00 UTC (permalink / raw)
  To: Benoît Cousson, Paul Walmsley, Russell King, Tony Lindgren,
	linux-arm-kernel, linux-omap
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 10:50:33 +0100

The functions clk_disable(), of_node_put() and omap_device_delete() test
whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 3 +--
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index d22c30d..5108859 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -199,8 +199,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 9e91a4e..e2406c4 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -917,8 +917,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
 
-	if (oh->_clk)
-		clk_disable(oh->_clk);
+	clk_disable(oh->_clk);
 
 	p = oh->slave_ports.next;
 
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 43d03fb..5b428a0 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -205,8 +205,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three function calls
@ 2014-11-22 10:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 10:00 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 10:50:33 +0100

The functions clk_disable(), of_node_put() and omap_device_delete() test
whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 3 +--
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index d22c30d..5108859 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -199,8 +199,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 9e91a4e..e2406c4 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -917,8 +917,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
 
-	if (oh->_clk)
-		clk_disable(oh->_clk);
+	clk_disable(oh->_clk);
 
 	p = oh->slave_ports.next;
 
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 43d03fb..5b428a0 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -205,8 +205,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three function calls
@ 2014-11-22 10:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 10:00 UTC (permalink / raw)
  To: Benoît Cousson, Paul Walmsley, Russell King, Tony Lindgren,
	linux-arm-kernel, linux-omap
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 10:50:33 +0100

The functions clk_disable(), of_node_put() and omap_device_delete() test
whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 3 +--
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index d22c30d..5108859 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -199,8 +199,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 9e91a4e..e2406c4 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -917,8 +917,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
 
-	if (oh->_clk)
-		clk_disable(oh->_clk);
+	clk_disable(oh->_clk);
 
 	p = oh->slave_ports.next;
 
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 43d03fb..5b428a0 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -205,8 +205,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three function calls
@ 2014-11-22 10:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 10:00 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 10:50:33 +0100

The functions clk_disable(), of_node_put() and omap_device_delete() test
whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 3 +--
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index d22c30d..5108859 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -199,8 +199,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 9e91a4e..e2406c4 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -917,8 +917,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
 
-	if (oh->_clk)
-		clk_disable(oh->_clk);
+	clk_disable(oh->_clk);
 
 	p = oh->slave_ports.next;
 
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 43d03fb..5b428a0 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -205,8 +205,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] ARM-kernel: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-22 10:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 10:40 UTC (permalink / raw)
  To: Russell King, linux-arm-kernel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 11:33:16 +0100

The functions smp_set_ops() and unwind_table_del() test whether their argument
is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/kernel/module.c | 3 +--
 arch/arm/kernel/setup.c  | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 6a4dffe..3dffad1 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -350,7 +350,6 @@ module_arch_cleanup(struct module *mod)
 	int i;
 
 	for (i = 0; i < ARM_SEC_MAX; i++)
-		if (mod->arch.unwind[i])
-			unwind_table_del(mod->arch.unwind[i]);
+		unwind_table_del(mod->arch.unwind[i]);
 #endif
 }
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 84db893d..a7018a2 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -929,7 +929,7 @@ void __init setup_arch(char **cmdline_p)
 		if (!mdesc->smp_init || !mdesc->smp_init()) {
 			if (psci_smp_available())
 				smp_set_ops(&psci_smp_ops);
-			else if (mdesc->smp)
+			else
 				smp_set_ops(mdesc->smp);
 		}
 		smp_init_cpus();
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] ARM-kernel: Deletion of unnecessary checks before two function calls
@ 2014-11-22 10:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 10:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 11:33:16 +0100

The functions smp_set_ops() and unwind_table_del() test whether their argument
is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/kernel/module.c | 3 +--
 arch/arm/kernel/setup.c  | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 6a4dffe..3dffad1 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -350,7 +350,6 @@ module_arch_cleanup(struct module *mod)
 	int i;
 
 	for (i = 0; i < ARM_SEC_MAX; i++)
-		if (mod->arch.unwind[i])
-			unwind_table_del(mod->arch.unwind[i]);
+		unwind_table_del(mod->arch.unwind[i]);
 #endif
 }
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 84db893d..a7018a2 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -929,7 +929,7 @@ void __init setup_arch(char **cmdline_p)
 		if (!mdesc->smp_init || !mdesc->smp_init()) {
 			if (psci_smp_available())
 				smp_set_ops(&psci_smp_ops);
-			else if (mdesc->smp)
+			else
 				smp_set_ops(mdesc->smp);
 		}
 		smp_init_cpus();
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] ARM-kernel: Deletion of unnecessary checks before two function calls
@ 2014-11-22 10:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 10:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 11:33:16 +0100

The functions smp_set_ops() and unwind_table_del() test whether their argument
is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/kernel/module.c | 3 +--
 arch/arm/kernel/setup.c  | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 6a4dffe..3dffad1 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -350,7 +350,6 @@ module_arch_cleanup(struct module *mod)
 	int i;
 
 	for (i = 0; i < ARM_SEC_MAX; i++)
-		if (mod->arch.unwind[i])
-			unwind_table_del(mod->arch.unwind[i]);
+		unwind_table_del(mod->arch.unwind[i]);
 #endif
 }
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 84db893d..a7018a2 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -929,7 +929,7 @@ void __init setup_arch(char **cmdline_p)
 		if (!mdesc->smp_init || !mdesc->smp_init()) {
 			if (psci_smp_available())
 				smp_set_ops(&psci_smp_ops);
-			else if (mdesc->smp)
+			else
 				smp_set_ops(mdesc->smp);
 		}
 		smp_init_cpus();
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_table"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-22 12:00                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 12:00 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Jon D. Mason, Muli Ben-Yehuda,
	Thomas Gleixner, x86, discuss
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 12:55:28 +0100

The free_tce_table() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/kernel/pci-calgary_64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 0497f71..d22a386 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -1476,8 +1476,7 @@ cleanup:
 	for (--bus; bus >= 0; --bus) {
 		struct calgary_bus_info *info = &bus_info[bus];
 
-		if (info->tce_space)
-			free_tce_table(info->tce_space);
+		free_tce_table(info->tce_space);
 	}
 	return -ENOMEM;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_ta
@ 2014-11-22 12:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 12:00 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Jon D. Mason, Muli Ben-Yehuda,
	Thomas Gleixner, x86, discuss
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 12:55:28 +0100

The free_tce_table() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/kernel/pci-calgary_64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 0497f71..d22a386 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -1476,8 +1476,7 @@ cleanup:
 	for (--bus; bus >= 0; --bus) {
 		struct calgary_bus_info *info = &bus_info[bus];
 
-		if (info->tce_space)
-			free_tce_table(info->tce_space);
+		free_tce_table(info->tce_space);
 	}
 	return -ENOMEM;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] x86: AMD-perf_event: Deletion of unnecessary checks before the function call "free_percpu"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-22 13:10                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 13:10 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, H. Peter Anvin, Ingo Molnar,
	Paul Mackerras, Peter Zijlstra, Thomas Gleixner, x86
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 14:01:27 +0100

The free_percpu() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/kernel/cpu/perf_event_amd_uncore.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_amd_uncore.c b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
index 30790d7..4856232 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
@@ -592,11 +592,9 @@ fail_online:
 fail_l2:
 	if (cpu_has_perfctr_nb)
 		perf_pmu_unregister(&amd_nb_pmu);
-	if (amd_uncore_l2)
-		free_percpu(amd_uncore_l2);
+	free_percpu(amd_uncore_l2);
 fail_nb:
-	if (amd_uncore_nb)
-		free_percpu(amd_uncore_nb);
+	free_percpu(amd_uncore_nb);
 
 fail_nodev:
 	return ret;
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] x86: AMD-perf_event: Deletion of unnecessary checks before the function call "free_percp
@ 2014-11-22 13:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 13:10 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, H. Peter Anvin, Ingo Molnar,
	Paul Mackerras, Peter Zijlstra, Thomas Gleixner, x86
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 14:01:27 +0100

The free_percpu() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/kernel/cpu/perf_event_amd_uncore.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_amd_uncore.c b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
index 30790d7..4856232 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
@@ -592,11 +592,9 @@ fail_online:
 fail_l2:
 	if (cpu_has_perfctr_nb)
 		perf_pmu_unregister(&amd_nb_pmu);
-	if (amd_uncore_l2)
-		free_percpu(amd_uncore_l2);
+	free_percpu(amd_uncore_l2);
 fail_nb:
-	if (amd_uncore_nb)
-		free_percpu(amd_uncore_nb);
+	free_percpu(amd_uncore_nb);
 
 fail_nodev:
 	return ret;
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] s390/pci: Deletion of unnecessary checks before the function call "debug_unregister"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-22 14:05                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 14:05 UTC (permalink / raw)
  To: Heiko Carstens, Gerald Schaefer, Martin Schwidefsky,
	Sebastian Ott, linux390, linux-s390
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 15:00:55 +0100

The debug_unregister() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/pci/pci_debug.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c
index eec598c..18403a7 100644
--- a/arch/s390/pci/pci_debug.c
+++ b/arch/s390/pci/pci_debug.c
@@ -158,10 +158,8 @@ int __init zpci_debug_init(void)
 
 void zpci_debug_exit(void)
 {
-	if (pci_debug_msg_id)
-		debug_unregister(pci_debug_msg_id);
-	if (pci_debug_err_id)
-		debug_unregister(pci_debug_err_id);
+	debug_unregister(pci_debug_msg_id);
+	debug_unregister(pci_debug_err_id);
 
 	debugfs_remove(debugfs_root);
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] s390/pci: Deletion of unnecessary checks before the function call "debug_unregister"
@ 2014-11-22 14:05                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 14:05 UTC (permalink / raw)
  To: Heiko Carstens, Gerald Schaefer, Martin Schwidefsky,
	Sebastian Ott, linux390, linux-s390
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 15:00:55 +0100

The debug_unregister() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/pci/pci_debug.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c
index eec598c..18403a7 100644
--- a/arch/s390/pci/pci_debug.c
+++ b/arch/s390/pci/pci_debug.c
@@ -158,10 +158,8 @@ int __init zpci_debug_init(void)
 
 void zpci_debug_exit(void)
 {
-	if (pci_debug_msg_id)
-		debug_unregister(pci_debug_msg_id);
-	if (pci_debug_err_id)
-		debug_unregister(pci_debug_err_id);
+	debug_unregister(pci_debug_msg_id);
+	debug_unregister(pci_debug_err_id);
 
 	debugfs_remove(debugfs_root);
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] PowerPC-83xx: Deletion of an unnecessary check before the function call "of_node_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-22 15:26                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 15:26 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Kumar Gala, Michael Ellerman,
	Paul Mackerras, Scott Wood, linuxppc-dev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 16:18:20 +0100

The of_node_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/83xx/usb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
index 1ad748b..5c31d82 100644
--- a/arch/powerpc/platforms/83xx/usb.c
+++ b/arch/powerpc/platforms/83xx/usb.c
@@ -162,8 +162,7 @@ int mpc831x_usb_cfg(void)
 
 	iounmap(immap);
 
-	if (immr_node)
-		of_node_put(immr_node);
+	of_node_put(immr_node);
 
 	/* Map USB SOC space */
 	ret = of_address_to_resource(np, 0, &res);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] PowerPC-83xx: Deletion of an unnecessary check before the function call "of_node_put"
@ 2014-11-22 15:26                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 15:26 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Kumar Gala, Michael Ellerman,
	Paul Mackerras, Scott Wood, linuxppc-dev
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 16:18:20 +0100

The of_node_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/83xx/usb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
index 1ad748b..5c31d82 100644
--- a/arch/powerpc/platforms/83xx/usb.c
+++ b/arch/powerpc/platforms/83xx/usb.c
@@ -162,8 +162,7 @@ int mpc831x_usb_cfg(void)
 
 	iounmap(immap);
 
-	if (immr_node)
-		of_node_put(immr_node);
+	of_node_put(immr_node);
 
 	/* Map USB SOC space */
 	ret = of_address_to_resource(np, 0, &res);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] PowerPC-83xx: Deletion of an unnecessary check before the function call "of_node_put"
@ 2014-11-22 15:26                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 15:26 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Kumar Gala, Michael Ellerman,
	Paul Mackerras, Scott Wood, linuxppc-dev
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 16:18:20 +0100

The of_node_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/83xx/usb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
index 1ad748b..5c31d82 100644
--- a/arch/powerpc/platforms/83xx/usb.c
+++ b/arch/powerpc/platforms/83xx/usb.c
@@ -162,8 +162,7 @@ int mpc831x_usb_cfg(void)
 
 	iounmap(immap);
 
-	if (immr_node)
-		of_node_put(immr_node);
+	of_node_put(immr_node);
 
 	/* Map USB SOC space */
 	ret = of_address_to_resource(np, 0, &res);
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-LCDC: Deletion of an unnecessary check before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-22 16:00                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 16:00 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 16:51:31 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/sh_mobile_lcdcfb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
index 2bcc84a..cfde21d 100644
--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
@@ -2181,8 +2181,7 @@ sh_mobile_lcdc_channel_fb_cleanup(struct sh_mobile_lcdc_chan *ch)
 	if (!info || !info->device)
 		return;
 
-	if (ch->sglist)
-		vfree(ch->sglist);
+	vfree(ch->sglist);
 
 	fb_dealloc_cmap(&info->cmap);
 	framebuffer_release(info);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-LCDC: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-22 16:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-22 16:00 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 16:51:31 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/sh_mobile_lcdcfb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
index 2bcc84a..cfde21d 100644
--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
@@ -2181,8 +2181,7 @@ sh_mobile_lcdc_channel_fb_cleanup(struct sh_mobile_lcdc_chan *ch)
 	if (!info || !info->device)
 		return;
 
-	if (ch->sglist)
-		vfree(ch->sglist);
+	vfree(ch->sglist);
 
 	fb_dealloc_cmap(&info->cmap);
 	framebuffer_release(info);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] [IA64] Deletion of unnecessary checks before the function call "unw_remove_unwind_table"
  2014-11-21 23:01                                   ` SF Markus Elfring
@ 2014-11-22 21:09                                     ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-22 21:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Fenghua Yu, Tony Luck, linux-ia64, LKML, kernel-janitors, Julia Lawall

This one is buggy.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] [IA64] Deletion of unnecessary checks before the function call "unw_remove_unwind_ta
@ 2014-11-22 21:09                                     ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-22 21:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Fenghua Yu, Tony Luck, linux-ia64, LKML, kernel-janitors, Julia Lawall

This one is buggy.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-21 22:27                                         ` David Miller
  (?)
@ 2014-11-23  0:51                                           ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23  0:51 UTC (permalink / raw)
  To: David Miller
  Cc: Haiyang Zhang, K. Y. Srinivasan, devel, netdev, linux-kernel,
	kernel-janitors, Julia Lawall

> This has nothing to do with me asking you to frame your patches
> against the correct tree.

I imagine than someone other can also pick up this update suggestion
(a simple change of two lines) quicker before I might try another
software build again from a different commit as a base.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23  0:51                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23  0:51 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Haiyang Zhang, kernel-janitors, linux-kernel,
	Julia Lawall, devel

> This has nothing to do with me asking you to frame your patches
> against the correct tree.

I imagine than someone other can also pick up this update suggestion
(a simple change of two lines) quicker before I might try another
software build again from a different commit as a base.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23  0:51                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23  0:51 UTC (permalink / raw)
  To: David Miller
  Cc: Haiyang Zhang, K. Y. Srinivasan, devel, netdev, linux-kernel,
	kernel-janitors, Julia Lawall

> This has nothing to do with me asking you to frame your patches
> against the correct tree.

I imagine than someone other can also pick up this update suggestion
(a simple change of two lines) quicker before I might try another
software build again from a different commit as a base.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  0:51                                           ` SF Markus Elfring
  (?)
@ 2014-11-23  1:27                                             ` Eric Dumazet
  -1 siblings, 0 replies; 3633+ messages in thread
From: Eric Dumazet @ 2014-11-23  1:27 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David Miller, Haiyang Zhang, K. Y. Srinivasan, devel, netdev,
	linux-kernel, kernel-janitors, Julia Lawall

On Sun, 2014-11-23 at 01:51 +0100, SF Markus Elfring wrote:
> > This has nothing to do with me asking you to frame your patches
> > against the correct tree.
> 
> I imagine than someone other can also pick up this update suggestion
> (a simple change of two lines) quicker before I might try another
> software build again from a different commit as a base.

I have no idea why someone would do that.

If you don't bother resubmit, nobody will.



^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23  1:27                                             ` Eric Dumazet
  0 siblings, 0 replies; 3633+ messages in thread
From: Eric Dumazet @ 2014-11-23  1:27 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, Haiyang Zhang, kernel-janitors, linux-kernel,
	Julia Lawall, devel, David Miller

On Sun, 2014-11-23 at 01:51 +0100, SF Markus Elfring wrote:
> > This has nothing to do with me asking you to frame your patches
> > against the correct tree.
> 
> I imagine than someone other can also pick up this update suggestion
> (a simple change of two lines) quicker before I might try another
> software build again from a different commit as a base.

I have no idea why someone would do that.

If you don't bother resubmit, nobody will.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23  1:27                                             ` Eric Dumazet
  0 siblings, 0 replies; 3633+ messages in thread
From: Eric Dumazet @ 2014-11-23  1:27 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David Miller, Haiyang Zhang, K. Y. Srinivasan, devel, netdev,
	linux-kernel, kernel-janitors, Julia Lawall

On Sun, 2014-11-23 at 01:51 +0100, SF Markus Elfring wrote:
> > This has nothing to do with me asking you to frame your patches
> > against the correct tree.
> 
> I imagine than someone other can also pick up this update suggestion
> (a simple change of two lines) quicker before I might try another
> software build again from a different commit as a base.

I have no idea why someone would do that.

If you don't bother resubmit, nobody will.



^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  0:51                                           ` SF Markus Elfring
@ 2014-11-23  4:36                                             ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-23  4:36 UTC (permalink / raw)
  To: elfring
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 01:51:24 +0100

>> This has nothing to do with me asking you to frame your patches
>> against the correct tree.
> 
> I imagine than someone other can also pick up this update suggestion
> (a simple change of two lines) quicker before I might try another
> software build again from a different commit as a base.

Whereas if you learn how to base your changes cleanly on the correct
base now, all of your future submissions will go quickly and smoothly
into my tree.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23  4:36                                             ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-23  4:36 UTC (permalink / raw)
  To: elfring
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 01:51:24 +0100

>> This has nothing to do with me asking you to frame your patches
>> against the correct tree.
> 
> I imagine than someone other can also pick up this update suggestion
> (a simple change of two lines) quicker before I might try another
> software build again from a different commit as a base.

Whereas if you learn how to base your changes cleanly on the correct
base now, all of your future submissions will go quickly and smoothly
into my tree.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  1:27                                             ` Eric Dumazet
  (?)
@ 2014-11-23  7:01                                               ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23  7:01 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David Miller, Haiyang Zhang, K. Y. Srinivasan, devel, netdev,
	linux-kernel, kernel-janitors, Julia Lawall

>> I imagine than someone other can also pick up this update suggestion
>> (a simple change of two lines) quicker before I might try another
>> software build again from a different commit as a base.
> 
> I have no idea why someone would do that.

I imagine that other software users (besides me) like developers
and testers might also become curious to try the proposed changes out.

How much will they eventually help to run Linux components a bit faster?


> If you don't bother resubmit, nobody will.

I hope that there are more possibilities for anticipation and acceptance
of source code improvement potentials.
Would you also like to contribute a bit more fine-tuning for the affected
software versions?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23  7:01                                               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23  7:01 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: netdev, Haiyang Zhang, kernel-janitors, linux-kernel,
	Julia Lawall, devel, David Miller

>> I imagine than someone other can also pick up this update suggestion
>> (a simple change of two lines) quicker before I might try another
>> software build again from a different commit as a base.
> 
> I have no idea why someone would do that.

I imagine that other software users (besides me) like developers
and testers might also become curious to try the proposed changes out.

How much will they eventually help to run Linux components a bit faster?


> If you don't bother resubmit, nobody will.

I hope that there are more possibilities for anticipation and acceptance
of source code improvement potentials.
Would you also like to contribute a bit more fine-tuning for the affected
software versions?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23  7:01                                               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23  7:01 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David Miller, Haiyang Zhang, K. Y. Srinivasan, devel, netdev,
	linux-kernel, kernel-janitors, Julia Lawall

>> I imagine than someone other can also pick up this update suggestion
>> (a simple change of two lines) quicker before I might try another
>> software build again from a different commit as a base.
> 
> I have no idea why someone would do that.

I imagine that other software users (besides me) like developers
and testers might also become curious to try the proposed changes out.

How much will they eventually help to run Linux components a bit faster?


> If you don't bother resubmit, nobody will.

I hope that there are more possibilities for anticipation and acceptance
of source code improvement potentials.
Would you also like to contribute a bit more fine-tuning for the affected
software versions?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  4:36                                             ` David Miller
@ 2014-11-23  7:18                                               ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23  7:18 UTC (permalink / raw)
  To: David Miller
  Cc: Haiyang Zhang, K. Y. Srinivasan, devel, netdev, linux-kernel,
	kernel-janitors, Julia Lawall

> Whereas if you learn how to base your changes cleanly on the correct
> base now, all of your future submissions will go quickly and smoothly
> into my tree.

My reluctance to work with more Linux repositories will evolve
over time. The faster affected software versions can be rebuilt
the more it will become interesting to try even more source
code improvements out, won't it?

I find it nice that you could accept update suggestions for
a few other Linux components already.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23  7:18                                               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23  7:18 UTC (permalink / raw)
  To: David Miller
  Cc: Haiyang Zhang, K. Y. Srinivasan, devel, netdev, linux-kernel,
	kernel-janitors, Julia Lawall

> Whereas if you learn how to base your changes cleanly on the correct
> base now, all of your future submissions will go quickly and smoothly
> into my tree.

My reluctance to work with more Linux repositories will evolve
over time. The faster affected software versions can be rebuilt
the more it will become interesting to try even more source
code improvements out, won't it?

I find it nice that you could accept update suggestions for
a few other Linux components already.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: uvesafb: Deletion of an unnecessary check before the function call "uvesafb_free"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-23 10:11                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 10:11 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Michal Januszewski,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 11:00:26 +0100

The uvesafb_free() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/uvesafb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index 509d452..f718627 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -1219,8 +1219,7 @@ static int uvesafb_release(struct fb_info *info, int user)
 	uvesafb_vbe_state_restore(par, par->vbe_state_orig);
 out:
 	atomic_dec(&par->ref_count);
-	if (task)
-		uvesafb_free(task);
+	uvesafb_free(task);
 	return 0;
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: uvesafb: Deletion of an unnecessary check before the function call "uvesafb_free"
@ 2014-11-23 10:11                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 10:11 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Michal Januszewski,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 11:00:26 +0100

The uvesafb_free() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/uvesafb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index 509d452..f718627 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -1219,8 +1219,7 @@ static int uvesafb_release(struct fb_info *info, int user)
 	uvesafb_vbe_state_restore(par, par->vbe_state_orig);
 out:
 	atomic_dec(&par->ref_count);
-	if (task)
-		uvesafb_free(task);
+	uvesafb_free(task);
 	return 0;
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: udlfb: Deletion of unnecessary checks before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-23 10:44                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 10:44 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 11:40:47 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/udlfb.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index 77b890e..01fff0c 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -922,8 +922,7 @@ static void dlfb_free(struct kref *kref)
 {
 	struct dlfb_data *dev = container_of(kref, struct dlfb_data, kref);
 
-	if (dev->backing_buffer)
-		vfree(dev->backing_buffer);
+	vfree(dev->backing_buffer);
 
 	kfree(dev->edid);
 
@@ -953,8 +952,7 @@ static void dlfb_free_framebuffer(struct dlfb_data *dev)
 			fb_dealloc_cmap(&info->cmap);
 		if (info->monspecs.modedb)
 			fb_destroy_modedb(info->monspecs.modedb);
-		if (info->screen_base)
-			vfree(info->screen_base);
+		vfree(info->screen_base);
 
 		fb_destroy_modelist(&info->modelist);
 
@@ -1203,8 +1201,7 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dev, struct fb_info *info)
 		if (!new_back)
 			pr_info("No shadow/backing buffer allocated\n");
 		else {
-			if (dev->backing_buffer)
-				vfree(dev->backing_buffer);
+			vfree(dev->backing_buffer);
 			dev->backing_buffer = new_back;
 		}
 	}
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: udlfb: Deletion of unnecessary checks before the function call "vfree"
@ 2014-11-23 10:44                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 10:44 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 11:40:47 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/udlfb.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index 77b890e..01fff0c 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -922,8 +922,7 @@ static void dlfb_free(struct kref *kref)
 {
 	struct dlfb_data *dev = container_of(kref, struct dlfb_data, kref);
 
-	if (dev->backing_buffer)
-		vfree(dev->backing_buffer);
+	vfree(dev->backing_buffer);
 
 	kfree(dev->edid);
 
@@ -953,8 +952,7 @@ static void dlfb_free_framebuffer(struct dlfb_data *dev)
 			fb_dealloc_cmap(&info->cmap);
 		if (info->monspecs.modedb)
 			fb_destroy_modedb(info->monspecs.modedb);
-		if (info->screen_base)
-			vfree(info->screen_base);
+		vfree(info->screen_base);
 
 		fb_destroy_modelist(&info->modelist);
 
@@ -1203,8 +1201,7 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dev, struct fb_info *info)
 		if (!new_back)
 			pr_info("No shadow/backing buffer allocated\n");
 		else {
-			if (dev->backing_buffer)
-				vfree(dev->backing_buffer);
+			vfree(dev->backing_buffer);
 			dev->backing_buffer = new_back;
 		}
 	}
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: smscufx: Deletion of unnecessary checks before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-23 11:33                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 11:33 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Steve Glendinning,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 12:30:33 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index d513ed6..9279e5f 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1142,8 +1142,7 @@ static void ufx_free_framebuffer_work(struct work_struct *work)
 		fb_dealloc_cmap(&info->cmap);
 	if (info->monspecs.modedb)
 		fb_destroy_modedb(info->monspecs.modedb);
-	if (info->screen_base)
-		vfree(info->screen_base);
+	vfree(info->screen_base);
 
 	fb_destroy_modelist(&info->modelist);
 
@@ -1743,8 +1742,7 @@ error:
 				fb_dealloc_cmap(&info->cmap);
 			if (info->monspecs.modedb)
 				fb_destroy_modedb(info->monspecs.modedb);
-			if (info->screen_base)
-				vfree(info->screen_base);
+			vfree(info->screen_base);
 
 			fb_destroy_modelist(&info->modelist);
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: smscufx: Deletion of unnecessary checks before the function call "vfree"
@ 2014-11-23 11:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 11:33 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Steve Glendinning,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 12:30:33 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index d513ed6..9279e5f 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1142,8 +1142,7 @@ static void ufx_free_framebuffer_work(struct work_struct *work)
 		fb_dealloc_cmap(&info->cmap);
 	if (info->monspecs.modedb)
 		fb_destroy_modedb(info->monspecs.modedb);
-	if (info->screen_base)
-		vfree(info->screen_base);
+	vfree(info->screen_base);
 
 	fb_destroy_modelist(&info->modelist);
 
@@ -1743,8 +1742,7 @@ error:
 				fb_dealloc_cmap(&info->cmap);
 			if (info->monspecs.modedb)
 				fb_destroy_modedb(info->monspecs.modedb);
-			if (info->screen_base)
-				vfree(info->screen_base);
+			vfree(info->screen_base);
 
 			fb_destroy_modelist(&info->modelist);
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-17  8:56                                             ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e SF Markus Elfring
  (?)
@ 2014-11-23 11:51                                               ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-23 11:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, trivial, kernel-janitors, linux-kernel,
	Eric Paris, Coccinelle

> > No, it's not.  You should just try to write the most readable software
> > you can instead of removing if statements because you can.
> 
> Additional safety checks have also got an effect on source code readability, haven't they?

Normally, tests only hurt readability if they cannot be false or cannot be 
true.  Making a choice apparent when there really is a choice would seem 
to aid understanding.  Program analysis tools can also potentially exploit 
this information, which you are so systmatically removing.

julia

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "aud
@ 2014-11-23 11:51                                               ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-23 11:51 UTC (permalink / raw)
  To: cocci

> > No, it's not.  You should just try to write the most readable software
> > you can instead of removing if statements because you can.
> 
> Additional safety checks have also got an effect on source code readability, haven't they?

Normally, tests only hurt readability if they cannot be false or cannot be 
true.  Making a choice apparent when there really is a choice would seem 
to aid understanding.  Program analysis tools can also potentially exploit 
this information, which you are so systmatically removing.

julia

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-23 11:51                                               ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-23 11:51 UTC (permalink / raw)
  To: cocci

> > No, it's not.  You should just try to write the most readable software
> > you can instead of removing if statements because you can.
> 
> Additional safety checks have also got an effect on source code readability, haven't they?

Normally, tests only hurt readability if they cannot be false or cannot be 
true.  Making a choice apparent when there really is a choice would seem 
to aid understanding.  Program analysis tools can also potentially exploit 
this information, which you are so systmatically removing.

julia

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-SIS: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-23 12:00                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 12:00 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Thomas Winischhofer,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 12:55:25 +0100

The pci_dev_put() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/sis/sis_main.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/video/fbdev/sis/sis_main.c b/drivers/video/fbdev/sis/sis_main.c
index 3f12a2d..6548a3e 100644
--- a/drivers/video/fbdev/sis/sis_main.c
+++ b/drivers/video/fbdev/sis/sis_main.c
@@ -5989,7 +5989,7 @@ static int sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(!ivideo->sisvga_enabled) {
 		if(pci_enable_device(pdev)) {
-			if(ivideo->nbridge) pci_dev_put(ivideo->nbridge);
+			pci_dev_put(ivideo->nbridge);
 			framebuffer_release(sis_fb_info);
 			return -EIO;
 		}
@@ -6202,10 +6202,8 @@ error_0:	iounmap(ivideo->video_vbase);
 error_1:	release_mem_region(ivideo->video_base, ivideo->video_size);
 error_2:	release_mem_region(ivideo->mmio_base, ivideo->mmio_size);
 error_3:	vfree(ivideo->bios_abase);
-		if(ivideo->lpcdev)
-			pci_dev_put(ivideo->lpcdev);
-		if(ivideo->nbridge)
-			pci_dev_put(ivideo->nbridge);
+		pci_dev_put(ivideo->lpcdev);
+		pci_dev_put(ivideo->nbridge);
 		if(!ivideo->sisvga_enabled)
 			pci_disable_device(pdev);
 		framebuffer_release(sis_fb_info);
@@ -6505,11 +6503,9 @@ static void sisfb_remove(struct pci_dev *pdev)
 
 	vfree(ivideo->bios_abase);
 
-	if(ivideo->lpcdev)
-		pci_dev_put(ivideo->lpcdev);
+	pci_dev_put(ivideo->lpcdev);
 
-	if(ivideo->nbridge)
-		pci_dev_put(ivideo->nbridge);
+	pci_dev_put(ivideo->nbridge);
 
 #ifdef CONFIG_MTRR
 	/* Release MTRR region */
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-SIS: Deletion of unnecessary checks before the function call "pci_dev_put"
@ 2014-11-23 12:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 12:00 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Thomas Winischhofer,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 12:55:25 +0100

The pci_dev_put() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/sis/sis_main.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/video/fbdev/sis/sis_main.c b/drivers/video/fbdev/sis/sis_main.c
index 3f12a2d..6548a3e 100644
--- a/drivers/video/fbdev/sis/sis_main.c
+++ b/drivers/video/fbdev/sis/sis_main.c
@@ -5989,7 +5989,7 @@ static int sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(!ivideo->sisvga_enabled) {
 		if(pci_enable_device(pdev)) {
-			if(ivideo->nbridge) pci_dev_put(ivideo->nbridge);
+			pci_dev_put(ivideo->nbridge);
 			framebuffer_release(sis_fb_info);
 			return -EIO;
 		}
@@ -6202,10 +6202,8 @@ error_0:	iounmap(ivideo->video_vbase);
 error_1:	release_mem_region(ivideo->video_base, ivideo->video_size);
 error_2:	release_mem_region(ivideo->mmio_base, ivideo->mmio_size);
 error_3:	vfree(ivideo->bios_abase);
-		if(ivideo->lpcdev)
-			pci_dev_put(ivideo->lpcdev);
-		if(ivideo->nbridge)
-			pci_dev_put(ivideo->nbridge);
+		pci_dev_put(ivideo->lpcdev);
+		pci_dev_put(ivideo->nbridge);
 		if(!ivideo->sisvga_enabled)
 			pci_disable_device(pdev);
 		framebuffer_release(sis_fb_info);
@@ -6505,11 +6503,9 @@ static void sisfb_remove(struct pci_dev *pdev)
 
 	vfree(ivideo->bios_abase);
 
-	if(ivideo->lpcdev)
-		pci_dev_put(ivideo->lpcdev);
+	pci_dev_put(ivideo->lpcdev);
 
-	if(ivideo->nbridge)
-		pci_dev_put(ivideo->nbridge);
+	pci_dev_put(ivideo->nbridge);
 
 #ifdef CONFIG_MTRR
 	/* Release MTRR region */
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-OMAP2: Deletion of unnecessary checks before the function call "i2c_put_adapter"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-23 13:14                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 13:14 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-omap,
	linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 14:07:22 +0100

The i2c_put_adapter() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/omap2/displays-new/connector-dvi.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
index 74de2bc..196c61a 100644
--- a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
+++ b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
@@ -262,8 +262,7 @@ static int dvic_probe_pdata(struct platform_device *pdev)
 
 	in = omap_dss_find_output(pdata->source);
 	if (in == NULL) {
-		if (ddata->i2c_adapter)
-			i2c_put_adapter(ddata->i2c_adapter);
+		i2c_put_adapter(ddata->i2c_adapter);
 
 		dev_err(&pdev->dev, "Failed to find video source\n");
 		return -EPROBE_DEFER;
@@ -352,8 +351,7 @@ static int dvic_probe(struct platform_device *pdev)
 err_reg:
 	omap_dss_put_device(ddata->in);
 
-	if (ddata->i2c_adapter)
-		i2c_put_adapter(ddata->i2c_adapter);
+	i2c_put_adapter(ddata->i2c_adapter);
 
 	return r;
 }
@@ -371,8 +369,7 @@ static int __exit dvic_remove(struct platform_device *pdev)
 
 	omap_dss_put_device(in);
 
-	if (ddata->i2c_adapter)
-		i2c_put_adapter(ddata->i2c_adapter);
+	i2c_put_adapter(ddata->i2c_adapter);
 
 	return 0;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-OMAP2: Deletion of unnecessary checks before the function call "i2c_put_ada
@ 2014-11-23 13:14                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 13:14 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-omap,
	linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 14:07:22 +0100

The i2c_put_adapter() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/omap2/displays-new/connector-dvi.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
index 74de2bc..196c61a 100644
--- a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
+++ b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
@@ -262,8 +262,7 @@ static int dvic_probe_pdata(struct platform_device *pdev)
 
 	in = omap_dss_find_output(pdata->source);
 	if (in = NULL) {
-		if (ddata->i2c_adapter)
-			i2c_put_adapter(ddata->i2c_adapter);
+		i2c_put_adapter(ddata->i2c_adapter);
 
 		dev_err(&pdev->dev, "Failed to find video source\n");
 		return -EPROBE_DEFER;
@@ -352,8 +351,7 @@ static int dvic_probe(struct platform_device *pdev)
 err_reg:
 	omap_dss_put_device(ddata->in);
 
-	if (ddata->i2c_adapter)
-		i2c_put_adapter(ddata->i2c_adapter);
+	i2c_put_adapter(ddata->i2c_adapter);
 
 	return r;
 }
@@ -371,8 +369,7 @@ static int __exit dvic_remove(struct platform_device *pdev)
 
 	omap_dss_put_device(in);
 
-	if (ddata->i2c_adapter)
-		i2c_put_adapter(ddata->i2c_adapter);
+	i2c_put_adapter(ddata->i2c_adapter);
 
 	return 0;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-OMAP2: Deletion of unnecessary checks before the function call "i2c_put_adapter"
@ 2014-11-23 13:14                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 13:14 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-omap,
	linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 14:07:22 +0100

The i2c_put_adapter() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/omap2/displays-new/connector-dvi.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
index 74de2bc..196c61a 100644
--- a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
+++ b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
@@ -262,8 +262,7 @@ static int dvic_probe_pdata(struct platform_device *pdev)
 
 	in = omap_dss_find_output(pdata->source);
 	if (in == NULL) {
-		if (ddata->i2c_adapter)
-			i2c_put_adapter(ddata->i2c_adapter);
+		i2c_put_adapter(ddata->i2c_adapter);
 
 		dev_err(&pdev->dev, "Failed to find video source\n");
 		return -EPROBE_DEFER;
@@ -352,8 +351,7 @@ static int dvic_probe(struct platform_device *pdev)
 err_reg:
 	omap_dss_put_device(ddata->in);
 
-	if (ddata->i2c_adapter)
-		i2c_put_adapter(ddata->i2c_adapter);
+	i2c_put_adapter(ddata->i2c_adapter);
 
 	return r;
 }
@@ -371,8 +369,7 @@ static int __exit dvic_remove(struct platform_device *pdev)
 
 	omap_dss_put_device(in);
 
-	if (ddata->i2c_adapter)
-		i2c_put_adapter(ddata->i2c_adapter);
+	i2c_put_adapter(ddata->i2c_adapter);
 
 	return 0;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-23 11:51                                               ` [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "aud Julia Lawall
  (?)
@ 2014-11-23 13:24                                                 ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 13:24 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Dan Carpenter, trivial, kernel-janitors, linux-kernel,
	Eric Paris, Coccinelle

> Normally, tests only hurt readability if they cannot be false or cannot be true. 
> Making a choice apparent when there really is a choice would seem 
> to aid understanding.

I agree also to such facts.


> Program analysis tools can also potentially exploit this information,

The published semantic patch scripts correspond to this desire.


> which you are so systmatically removing.

I try to delete redundant checks in various function implementations as much
as possible.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-23 13:24                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 13:24 UTC (permalink / raw)
  To: cocci

> Normally, tests only hurt readability if they cannot be false or cannot be true. 
> Making a choice apparent when there really is a choice would seem 
> to aid understanding.

I agree also to such facts.


> Program analysis tools can also potentially exploit this information,

The published semantic patch scripts correspond to this desire.


> which you are so systmatically removing.

I try to delete redundant checks in various function implementations as much
as possible.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [Cocci] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-23 13:24                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 13:24 UTC (permalink / raw)
  To: cocci

> Normally, tests only hurt readability if they cannot be false or cannot be true. 
> Making a choice apparent when there really is a choice would seem 
> to aid understanding.

I agree also to such facts.


> Program analysis tools can also potentially exploit this information,

The published semantic patch scripts correspond to this desire.


> which you are so systmatically removing.

I try to delete redundant checks in various function implementations as much
as possible.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-21 18:14                                         ` Joe Perches
@ 2014-11-23 14:14                                           ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 14:14 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andreas Noever, LKML, kernel-janitors, Julia Lawall

>> 2. Are any additional prefixes appropriate so that further name space
>>    conflicts can be better avoided?
> 
> To avoid possible external naming conflicts, add tb_ prefix to
> various ring_<foo> structs and functions.

Do you imagine that any XEN software developers need also to reconsider
this implementation detail?
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?id=fc14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-23 14:14                                           ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 14:14 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andreas Noever, LKML, kernel-janitors, Julia Lawall

>> 2. Are any additional prefixes appropriate so that further name space
>>    conflicts can be better avoided?
> 
> To avoid possible external naming conflicts, add tb_ prefix to
> various ring_<foo> structs and functions.

Do you imagine that any XEN software developers need also to reconsider
this implementation detail?
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: mx3fb: Deletion of an unnecessary check before the function call "backlight_device_unregister"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-23 14:20                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 14:20 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 15:15:29 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/mx3fb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/mx3fb.c b/drivers/video/fbdev/mx3fb.c
index c645a0a..b2d2151 100644
--- a/drivers/video/fbdev/mx3fb.c
+++ b/drivers/video/fbdev/mx3fb.c
@@ -334,8 +334,7 @@ static void mx3fb_init_backlight(struct mx3fb_data *fbd)
 
 static void mx3fb_exit_backlight(struct mx3fb_data *fbd)
 {
-	if (fbd->bl)
-		backlight_device_unregister(fbd->bl);
+	backlight_device_unregister(fbd->bl);
 }
 
 static void mx3fb_dma_done(void *);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: mx3fb: Deletion of an unnecessary check before the function call "backlight_devic
@ 2014-11-23 14:20                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 14:20 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 15:15:29 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/mx3fb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/mx3fb.c b/drivers/video/fbdev/mx3fb.c
index c645a0a..b2d2151 100644
--- a/drivers/video/fbdev/mx3fb.c
+++ b/drivers/video/fbdev/mx3fb.c
@@ -334,8 +334,7 @@ static void mx3fb_init_backlight(struct mx3fb_data *fbd)
 
 static void mx3fb_exit_backlight(struct mx3fb_data *fbd)
 {
-	if (fbd->bl)
-		backlight_device_unregister(fbd->bl);
+	backlight_device_unregister(fbd->bl);
 }
 
 static void mx3fb_dma_done(void *);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-MMP: Deletion of an unnecessary check before the function call "mmp_unregister_path"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-23 15:00                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 15:00 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 15:45:03 +0100

The mmp_unregister_path() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/mmp/hw/mmp_ctrl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c
index 8621a9f..3c12bd8 100644
--- a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c
+++ b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c
@@ -441,8 +441,7 @@ static void path_deinit(struct mmphw_path_plat *path_plat)
 	if (!path_plat)
 		return;
 
-	if (path_plat->path)
-		mmp_unregister_path(path_plat->path);
+	mmp_unregister_path(path_plat->path);
 }
 
 static int mmphw_probe(struct platform_device *pdev)
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-MMP: Deletion of an unnecessary check before the function call "mmp_unregis
@ 2014-11-23 15:00                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 15:00 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 15:45:03 +0100

The mmp_unregister_path() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/mmp/hw/mmp_ctrl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c
index 8621a9f..3c12bd8 100644
--- a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c
+++ b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c
@@ -441,8 +441,7 @@ static void path_deinit(struct mmphw_path_plat *path_plat)
 	if (!path_plat)
 		return;
 
-	if (path_plat->path)
-		mmp_unregister_path(path_plat->path);
+	mmp_unregister_path(path_plat->path);
 }
 
 static int mmphw_probe(struct platform_device *pdev)
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-23 14:14                                           ` SF Markus Elfring
@ 2014-11-23 15:20                                             ` Joe Perches
  -1 siblings, 0 replies; 3633+ messages in thread
From: Joe Perches @ 2014-11-23 15:20 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Andreas Noever, LKML, kernel-janitors, Julia Lawall

On Sun, 2014-11-23 at 15:14 +0100, SF Markus Elfring wrote:
> >> 2. Are any additional prefixes appropriate so that further name space
> >>    conflicts can be better avoided?
> > 
> > To avoid possible external naming conflicts, add tb_ prefix to
> > various ring_<foo> structs and functions.
> 
> Do you imagine that any XEN software developers need also to reconsider
> this implementation detail?
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?id=fc14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

I think static functions can be named whatever
the developer chooses.



^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-23 15:20                                             ` Joe Perches
  0 siblings, 0 replies; 3633+ messages in thread
From: Joe Perches @ 2014-11-23 15:20 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Andreas Noever, LKML, kernel-janitors, Julia Lawall

On Sun, 2014-11-23 at 15:14 +0100, SF Markus Elfring wrote:
> >> 2. Are any additional prefixes appropriate so that further name space
> >>    conflicts can be better avoided?
> > 
> > To avoid possible external naming conflicts, add tb_ prefix to
> > various ring_<foo> structs and functions.
> 
> Do you imagine that any XEN software developers need also to reconsider
> this implementation detail?
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

I think static functions can be named whatever
the developer chooses.


--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-VIA: Deletion of an unnecessary check before the function call "framebuffer_release"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-23 15:33                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 15:33 UTC (permalink / raw)
  To: Florian Tobias Schandinat, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 16:30:05 +0100

The framebuffer_release() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/via/viafbdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c
index 325c43c..f9718f0 100644
--- a/drivers/video/fbdev/via/viafbdev.c
+++ b/drivers/video/fbdev/via/viafbdev.c
@@ -1937,8 +1937,7 @@ out_fb1_unreg_lcd_cle266:
 out_dealloc_cmap:
 	fb_dealloc_cmap(&viafbinfo->cmap);
 out_fb1_release:
-	if (viafbinfo1)
-		framebuffer_release(viafbinfo1);
+	framebuffer_release(viafbinfo1);
 out_fb_release:
 	i2c_bus_free(viaparinfo->shared);
 	framebuffer_release(viafbinfo);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: fbdev-VIA: Deletion of an unnecessary check before the function call "framebuffer
@ 2014-11-23 15:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 15:33 UTC (permalink / raw)
  To: Florian Tobias Schandinat, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 16:30:05 +0100

The framebuffer_release() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/via/viafbdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c
index 325c43c..f9718f0 100644
--- a/drivers/video/fbdev/via/viafbdev.c
+++ b/drivers/video/fbdev/via/viafbdev.c
@@ -1937,8 +1937,7 @@ out_fb1_unreg_lcd_cle266:
 out_dealloc_cmap:
 	fb_dealloc_cmap(&viafbinfo->cmap);
 out_fb1_release:
-	if (viafbinfo1)
-		framebuffer_release(viafbinfo1);
+	framebuffer_release(viafbinfo1);
 out_fb_release:
 	i2c_bus_free(viaparinfo->shared);
 	framebuffer_release(viafbinfo);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-23 15:20                                             ` Joe Perches
@ 2014-11-23 15:42                                               ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 15:42 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andreas Noever, LKML, kernel-janitors, Julia Lawall

>> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?id=fc14f9c1272f62c3e8d01300f52467c0d9af50f9#n268
> 
> I think static functions can be named whatever
> the developer chooses.

I agree also that this implementation detail is correct in principle.

Is a renaming of such identifiers feasible so that the probability of
other name clashes can be reduced and corresponding static source
code analysis might become a bit easier?

How do you prefer to handle name space issues?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-23 15:42                                               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 15:42 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andreas Noever, LKML, kernel-janitors, Julia Lawall

>> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268
> 
> I think static functions can be named whatever
> the developer chooses.

I agree also that this implementation detail is correct in principle.

Is a renaming of such identifiers feasible so that the probability of
other name clashes can be reduced and corresponding static source
code analysis might become a bit easier?

How do you prefer to handle name space issues?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-23 15:20                                             ` Joe Perches
@ 2014-11-23 15:45                                               ` Andreas Noever
  -1 siblings, 0 replies; 3633+ messages in thread
From: Andreas Noever @ 2014-11-23 15:45 UTC (permalink / raw)
  To: Joe Perches; +Cc: SF Markus Elfring, LKML, kernel-janitors, Julia Lawall

On Sun, Nov 23, 2014 at 4:20 PM, Joe Perches <joe@perches.com> wrote:
> On Sun, 2014-11-23 at 15:14 +0100, SF Markus Elfring wrote:
>> >> 2. Are any additional prefixes appropriate so that further name space
>> >>    conflicts can be better avoided?
>> >
>> > To avoid possible external naming conflicts, add tb_ prefix to
>> > various ring_<foo> structs and functions.
>>
>> Do you imagine that any XEN software developers need also to reconsider
>> this implementation detail?
>> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?id=fc14f9c1272f62c3e8d01300f52467c0d9af50f9#n268
>
> I think static functions can be named whatever
> the developer chooses.
Do symbols which are not exported (no EXPORT_SYMBOL_(GPL)) cause
conflicts? I was under the impression that those are module private.
If they are indeed private then I would prefer to not rename them.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-23 15:45                                               ` Andreas Noever
  0 siblings, 0 replies; 3633+ messages in thread
From: Andreas Noever @ 2014-11-23 15:45 UTC (permalink / raw)
  To: Joe Perches; +Cc: SF Markus Elfring, LKML, kernel-janitors, Julia Lawall

On Sun, Nov 23, 2014 at 4:20 PM, Joe Perches <joe@perches.com> wrote:
> On Sun, 2014-11-23 at 15:14 +0100, SF Markus Elfring wrote:
>> >> 2. Are any additional prefixes appropriate so that further name space
>> >>    conflicts can be better avoided?
>> >
>> > To avoid possible external naming conflicts, add tb_ prefix to
>> > various ring_<foo> structs and functions.
>>
>> Do you imagine that any XEN software developers need also to reconsider
>> this implementation detail?
>> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268
>
> I think static functions can be named whatever
> the developer chooses.
Do symbols which are not exported (no EXPORT_SYMBOL_(GPL)) cause
conflicts? I was under the impression that those are module private.
If they are indeed private then I would prefer to not rename them.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-23 15:42                                               ` SF Markus Elfring
@ 2014-11-23 15:51                                                 ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-23 15:51 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Joe Perches, Andreas Noever, LKML, kernel-janitors



On Sun, 23 Nov 2014, SF Markus Elfring wrote:

> >> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?id=fc14f9c1272f62c3e8d01300f52467c0d9af50f9#n268
> > 
> > I think static functions can be named whatever
> > the developer chooses.
> 
> I agree also that this implementation detail is correct in principle.
> 
> Is a renaming of such identifiers feasible so that the probability of
> other name clashes can be reduced and corresponding static source
> code analysis might become a bit easier?

Why not just make the static source code analysis aware of the problem?  
You can treat static functions differently that non-static ones.  There is 
no need to change the code.

julia

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-23 15:51                                                 ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-23 15:51 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Joe Perches, Andreas Noever, LKML, kernel-janitors



On Sun, 23 Nov 2014, SF Markus Elfring wrote:

> >> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268
> > 
> > I think static functions can be named whatever
> > the developer chooses.
> 
> I agree also that this implementation detail is correct in principle.
> 
> Is a renaming of such identifiers feasible so that the probability of
> other name clashes can be reduced and corresponding static source
> code analysis might become a bit easier?

Why not just make the static source code analysis aware of the problem?  
You can treat static functions differently that non-static ones.  There is 
no need to change the code.

julia
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-23 15:45                                               ` Andreas Noever
@ 2014-11-23 15:56                                                 ` Joe Perches
  -1 siblings, 0 replies; 3633+ messages in thread
From: Joe Perches @ 2014-11-23 15:56 UTC (permalink / raw)
  To: Andreas Noever; +Cc: SF Markus Elfring, LKML, kernel-janitors, Julia Lawall

On Sun, 2014-11-23 at 16:45 +0100, Andreas Noever wrote:
> On Sun, Nov 23, 2014 at 4:20 PM, Joe Perches <joe@perches.com> wrote:
> > On Sun, 2014-11-23 at 15:14 +0100, SF Markus Elfring wrote:
> >> >> 2. Are any additional prefixes appropriate so that further name space
> >> >>    conflicts can be better avoided?
> >> >
> >> > To avoid possible external naming conflicts, add tb_ prefix to
> >> > various ring_<foo> structs and functions.
> >>
> >> Do you imagine that any XEN software developers need also to reconsider
> >> this implementation detail?
> >> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?id=fc14f9c1272f62c3e8d01300f52467c0d9af50f9#n268
> >
> > I think static functions can be named whatever
> > the developer chooses.
> Do symbols which are not exported (no EXPORT_SYMBOL_(GPL)) cause
> conflicts?

If the symbol is not static, yes.

eg: the static uses of "debug" as a control
variable vs the non-static uses of <prefix>debug
when shared among multiple objects in a single
driver.



^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-23 15:56                                                 ` Joe Perches
  0 siblings, 0 replies; 3633+ messages in thread
From: Joe Perches @ 2014-11-23 15:56 UTC (permalink / raw)
  To: Andreas Noever; +Cc: SF Markus Elfring, LKML, kernel-janitors, Julia Lawall

On Sun, 2014-11-23 at 16:45 +0100, Andreas Noever wrote:
> On Sun, Nov 23, 2014 at 4:20 PM, Joe Perches <joe@perches.com> wrote:
> > On Sun, 2014-11-23 at 15:14 +0100, SF Markus Elfring wrote:
> >> >> 2. Are any additional prefixes appropriate so that further name space
> >> >>    conflicts can be better avoided?
> >> >
> >> > To avoid possible external naming conflicts, add tb_ prefix to
> >> > various ring_<foo> structs and functions.
> >>
> >> Do you imagine that any XEN software developers need also to reconsider
> >> this implementation detail?
> >> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268
> >
> > I think static functions can be named whatever
> > the developer chooses.
> Do symbols which are not exported (no EXPORT_SYMBOL_(GPL)) cause
> conflicts?

If the symbol is not static, yes.

eg: the static uses of "debug" as a control
variable vs the non-static uses of <prefix>debug
when shared among multiple objects in a single
driver.


--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: uvesafb: Deletion of an unnecessary check before the function call "platform_device_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-23 16:10                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 16:10 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Michal Januszewski,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 17:05:18 +0100

The platform_device_put() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/uvesafb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index 509d452..17b2e8c 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -1923,8 +1923,7 @@ static int uvesafb_init(void)
 			err = -ENOMEM;
 
 		if (err) {
-			if (uvesafb_device)
-				platform_device_put(uvesafb_device);
+			platform_device_put(uvesafb_device);
 			platform_driver_unregister(&uvesafb_driver);
 			cn_del_callback(&uvesafb_cn_id);
 			return err;
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] video: uvesafb: Deletion of an unnecessary check before the function call "platform_devi
@ 2014-11-23 16:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 16:10 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Michal Januszewski,
	Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 17:05:18 +0100

The platform_device_put() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/uvesafb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index 509d452..17b2e8c 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -1923,8 +1923,7 @@ static int uvesafb_init(void)
 			err = -ENOMEM;
 
 		if (err) {
-			if (uvesafb_device)
-				platform_device_put(uvesafb_device);
+			platform_device_put(uvesafb_device);
 			platform_driver_unregister(&uvesafb_driver);
 			cn_del_callback(&uvesafb_cn_id);
 			return err;
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_device_unregister"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-23 16:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 16:40 UTC (permalink / raw)
  To: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Lee Jones, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 17:33:08 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
index d6c4f6a..24a055c 100644
--- a/drivers/video/backlight/lp8788_bl.c
+++ b/drivers/video/backlight/lp8788_bl.c
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_
@ 2014-11-23 16:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 16:40 UTC (permalink / raw)
  To: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Lee Jones, Tomi Valkeinen, linux-fbdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 17:33:08 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
index d6c4f6a..24a055c 100644
--- a/drivers/video/backlight/lp8788_bl.c
+++ b/drivers/video/backlight/lp8788_bl.c
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 0/2] staging: android: ion: Deletion of a few unnecessary checks
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-23 18:33                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 18:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Stephen Warren, Thierry Reding, devel, linux-tegra
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 19:13:56 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of unnecessary checks before two function calls
  One function call less in ion_buffer_create() after error detection

 drivers/staging/android/ion/ion.c              | 9 +++------
 drivers/staging/android/ion/ion_dummy_driver.c | 6 ++----
 drivers/staging/android/ion/tegra/tegra_ion.c  | 6 ++----
 3 files changed, 7 insertions(+), 14 deletions(-)

-- 
2.1.3

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 0/2] staging: android: ion: Deletion of a few unnecessary checks
@ 2014-11-23 18:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 18:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Stephen Warren, Thierry Reding, devel, linux-tegra
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 19:13:56 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of unnecessary checks before two function calls
  One function call less in ion_buffer_create() after error detection

 drivers/staging/android/ion/ion.c              | 9 +++------
 drivers/staging/android/ion/ion_dummy_driver.c | 6 ++----
 drivers/staging/android/ion/tegra/tegra_ion.c  | 6 ++----
 3 files changed, 7 insertions(+), 14 deletions(-)

-- 
2.1.3


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 0/2] staging: android: ion: Deletion of a few unnecessary checks
@ 2014-11-23 18:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 18:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Stephen Warren, Thierry Reding, devel, linux-tegra
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 19:13:56 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of unnecessary checks before two function calls
  One function call less in ion_buffer_create() after error detection

 drivers/staging/android/ion/ion.c              | 9 +++------
 drivers/staging/android/ion/ion_dummy_driver.c | 6 ++----
 drivers/staging/android/ion/tegra/tegra_ion.c  | 6 ++----
 3 files changed, 7 insertions(+), 14 deletions(-)

-- 
2.1.3


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  7:18                                               ` SF Markus Elfring
  (?)
@ 2014-11-23 18:37                                                 ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-23 18:37 UTC (permalink / raw)
  To: elfring
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 08:18:31 +0100

>> Whereas if you learn how to base your changes cleanly on the correct
>> base now, all of your future submissions will go quickly and smoothly
>> into my tree.
> 
> My reluctance to work with more Linux repositories will evolve
> over time. The faster affected software versions can be rebuilt
> the more it will become interesting to try even more source
> code improvements out, won't it?
> 
> I find it nice that you could accept update suggestions for
> a few other Linux components already.

You are seriously starting to waste our time.

Either resubmit your changes against a clean base, or more on.

Seriously, all I am purely interested in is seeing properly submitted
patches, reviewing them, and then integrating them.  Anything else is
pure noise to me.

Thanks.


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23 18:37                                                 ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-23 18:37 UTC (permalink / raw)
  To: elfring
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall, devel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 08:18:31 +0100

>> Whereas if you learn how to base your changes cleanly on the correct
>> base now, all of your future submissions will go quickly and smoothly
>> into my tree.
> 
> My reluctance to work with more Linux repositories will evolve
> over time. The faster affected software versions can be rebuilt
> the more it will become interesting to try even more source
> code improvements out, won't it?
> 
> I find it nice that you could accept update suggestions for
> a few other Linux components already.

You are seriously starting to waste our time.

Either resubmit your changes against a clean base, or more on.

Seriously, all I am purely interested in is seeing properly submitted
patches, reviewing them, and then integrating them.  Anything else is
pure noise to me.

Thanks.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-23 18:37                                                 ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-23 18:37 UTC (permalink / raw)
  To: elfring
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 08:18:31 +0100

>> Whereas if you learn how to base your changes cleanly on the correct
>> base now, all of your future submissions will go quickly and smoothly
>> into my tree.
> 
> My reluctance to work with more Linux repositories will evolve
> over time. The faster affected software versions can be rebuilt
> the more it will become interesting to try even more source
> code improvements out, won't it?
> 
> I find it nice that you could accept update suggestions for
> a few other Linux components already.

You are seriously starting to waste our time.

Either resubmit your changes against a clean base, or more on.

Seriously, all I am purely interested in is seeing properly submitted
patches, reviewing them, and then integrating them.  Anything else is
pure noise to me.

Thanks.


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/2] staging: android: ion: Deletion of unnecessary checks before two function calls
  2014-11-23 18:33                                   ` SF Markus Elfring
  (?)
@ 2014-11-23 18:39                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 18:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Stephen Warren, Thierry Reding, devel, linux-tegra
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 18:48:15 +0100

The functions ion_heap_destroy() and vfree() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/android/ion/ion.c              | 6 ++----
 drivers/staging/android/ion/ion_dummy_driver.c | 6 ++----
 drivers/staging/android/ion/tegra/tegra_ion.c  | 6 ++----
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 2703609..df12cc3 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -263,8 +263,7 @@ err:
 	heap->ops->unmap_dma(heap, buffer);
 	heap->ops->free(buffer);
 err1:
-	if (buffer->pages)
-		vfree(buffer->pages);
+	vfree(buffer->pages);
 err2:
 	kfree(buffer);
 	return ERR_PTR(ret);
@@ -276,8 +275,7 @@ void ion_buffer_destroy(struct ion_buffer *buffer)
 		buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
 	buffer->heap->ops->unmap_dma(buffer->heap, buffer);
 	buffer->heap->ops->free(buffer);
-	if (buffer->pages)
-		vfree(buffer->pages);
+	vfree(buffer->pages);
 	kfree(buffer);
 }
 
diff --git a/drivers/staging/android/ion/ion_dummy_driver.c b/drivers/staging/android/ion/ion_dummy_driver.c
index 3a45e79..d06bf52 100644
--- a/drivers/staging/android/ion/ion_dummy_driver.c
+++ b/drivers/staging/android/ion/ion_dummy_driver.c
@@ -112,10 +112,8 @@ static int __init ion_dummy_init(void)
 	}
 	return 0;
 err:
-	for (i = 0; i < dummy_ion_pdata.nr; i++) {
-		if (heaps[i])
-			ion_heap_destroy(heaps[i]);
-	}
+	for (i = 0; i < dummy_ion_pdata.nr; ++i)
+		ion_heap_destroy(heaps[i]);
 	kfree(heaps);
 
 	if (carveout_ptr) {
diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c
index 11c7cce..5b8ef0e 100644
--- a/drivers/staging/android/ion/tegra/tegra_ion.c
+++ b/drivers/staging/android/ion/tegra/tegra_ion.c
@@ -54,10 +54,8 @@ static int tegra_ion_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, idev);
 	return 0;
 err:
-	for (i = 0; i < num_heaps; i++) {
-		if (heaps[i])
-			ion_heap_destroy(heaps[i]);
-	}
+	for (i = 0; i < num_heaps; ++i)
+		ion_heap_destroy(heaps[i]);
 	return err;
 }
 
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/2] staging: android: ion: Deletion of unnecessary checks before two function calls
@ 2014-11-23 18:39                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 18:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Stephen Warren, Thierry Reding, devel, linux-tegra
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 18:48:15 +0100

The functions ion_heap_destroy() and vfree() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/android/ion/ion.c              | 6 ++----
 drivers/staging/android/ion/ion_dummy_driver.c | 6 ++----
 drivers/staging/android/ion/tegra/tegra_ion.c  | 6 ++----
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 2703609..df12cc3 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -263,8 +263,7 @@ err:
 	heap->ops->unmap_dma(heap, buffer);
 	heap->ops->free(buffer);
 err1:
-	if (buffer->pages)
-		vfree(buffer->pages);
+	vfree(buffer->pages);
 err2:
 	kfree(buffer);
 	return ERR_PTR(ret);
@@ -276,8 +275,7 @@ void ion_buffer_destroy(struct ion_buffer *buffer)
 		buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
 	buffer->heap->ops->unmap_dma(buffer->heap, buffer);
 	buffer->heap->ops->free(buffer);
-	if (buffer->pages)
-		vfree(buffer->pages);
+	vfree(buffer->pages);
 	kfree(buffer);
 }
 
diff --git a/drivers/staging/android/ion/ion_dummy_driver.c b/drivers/staging/android/ion/ion_dummy_driver.c
index 3a45e79..d06bf52 100644
--- a/drivers/staging/android/ion/ion_dummy_driver.c
+++ b/drivers/staging/android/ion/ion_dummy_driver.c
@@ -112,10 +112,8 @@ static int __init ion_dummy_init(void)
 	}
 	return 0;
 err:
-	for (i = 0; i < dummy_ion_pdata.nr; i++) {
-		if (heaps[i])
-			ion_heap_destroy(heaps[i]);
-	}
+	for (i = 0; i < dummy_ion_pdata.nr; ++i)
+		ion_heap_destroy(heaps[i]);
 	kfree(heaps);
 
 	if (carveout_ptr) {
diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c
index 11c7cce..5b8ef0e 100644
--- a/drivers/staging/android/ion/tegra/tegra_ion.c
+++ b/drivers/staging/android/ion/tegra/tegra_ion.c
@@ -54,10 +54,8 @@ static int tegra_ion_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, idev);
 	return 0;
 err:
-	for (i = 0; i < num_heaps; i++) {
-		if (heaps[i])
-			ion_heap_destroy(heaps[i]);
-	}
+	for (i = 0; i < num_heaps; ++i)
+		ion_heap_destroy(heaps[i]);
 	return err;
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/2] staging: android: ion: Deletion of unnecessary checks before two function calls
@ 2014-11-23 18:39                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 18:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Stephen Warren, Thierry Reding, devel, linux-tegra
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 18:48:15 +0100

The functions ion_heap_destroy() and vfree() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/android/ion/ion.c              | 6 ++----
 drivers/staging/android/ion/ion_dummy_driver.c | 6 ++----
 drivers/staging/android/ion/tegra/tegra_ion.c  | 6 ++----
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 2703609..df12cc3 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -263,8 +263,7 @@ err:
 	heap->ops->unmap_dma(heap, buffer);
 	heap->ops->free(buffer);
 err1:
-	if (buffer->pages)
-		vfree(buffer->pages);
+	vfree(buffer->pages);
 err2:
 	kfree(buffer);
 	return ERR_PTR(ret);
@@ -276,8 +275,7 @@ void ion_buffer_destroy(struct ion_buffer *buffer)
 		buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
 	buffer->heap->ops->unmap_dma(buffer->heap, buffer);
 	buffer->heap->ops->free(buffer);
-	if (buffer->pages)
-		vfree(buffer->pages);
+	vfree(buffer->pages);
 	kfree(buffer);
 }
 
diff --git a/drivers/staging/android/ion/ion_dummy_driver.c b/drivers/staging/android/ion/ion_dummy_driver.c
index 3a45e79..d06bf52 100644
--- a/drivers/staging/android/ion/ion_dummy_driver.c
+++ b/drivers/staging/android/ion/ion_dummy_driver.c
@@ -112,10 +112,8 @@ static int __init ion_dummy_init(void)
 	}
 	return 0;
 err:
-	for (i = 0; i < dummy_ion_pdata.nr; i++) {
-		if (heaps[i])
-			ion_heap_destroy(heaps[i]);
-	}
+	for (i = 0; i < dummy_ion_pdata.nr; ++i)
+		ion_heap_destroy(heaps[i]);
 	kfree(heaps);
 
 	if (carveout_ptr) {
diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c
index 11c7cce..5b8ef0e 100644
--- a/drivers/staging/android/ion/tegra/tegra_ion.c
+++ b/drivers/staging/android/ion/tegra/tegra_ion.c
@@ -54,10 +54,8 @@ static int tegra_ion_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, idev);
 	return 0;
 err:
-	for (i = 0; i < num_heaps; i++) {
-		if (heaps[i])
-			ion_heap_destroy(heaps[i]);
-	}
+	for (i = 0; i < num_heaps; ++i)
+		ion_heap_destroy(heaps[i]);
 	return err;
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detection
  2014-11-23 18:33                                   ` SF Markus Elfring
@ 2014-11-23 18:44                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 18:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 19:12:29 +0100

The jump label "err1" was used by the ion_buffer_create() function in case of
a memory allocation failure just to pass a null pointer to a vfree() function
call by a data structure element.
This implementation detail could be improved by the deletion of this
inappropriate jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/android/ion/ion.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index df12cc3..7a26b85 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -226,7 +226,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 		buffer->pages = vmalloc(sizeof(struct page *) * num_pages);
 		if (!buffer->pages) {
 			ret = -ENOMEM;
-			goto err1;
+			goto err2;
 		}
 
 		for_each_sg(table->sgl, sg, table->nents, i) {
@@ -262,7 +262,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 err:
 	heap->ops->unmap_dma(heap, buffer);
 	heap->ops->free(buffer);
-err1:
 	vfree(buffer->pages);
 err2:
 	kfree(buffer);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detecti
@ 2014-11-23 18:44                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 18:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 19:12:29 +0100

The jump label "err1" was used by the ion_buffer_create() function in case of
a memory allocation failure just to pass a null pointer to a vfree() function
call by a data structure element.
This implementation detail could be improved by the deletion of this
inappropriate jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/android/ion/ion.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index df12cc3..7a26b85 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -226,7 +226,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 		buffer->pages = vmalloc(sizeof(struct page *) * num_pages);
 		if (!buffer->pages) {
 			ret = -ENOMEM;
-			goto err1;
+			goto err2;
 		}
 
 		for_each_sg(table->sgl, sg, table->nents, i) {
@@ -262,7 +262,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
 err:
 	heap->ops->unmap_dma(heap, buffer);
 	heap->ops->free(buffer);
-err1:
 	vfree(buffer->pages);
 err2:
 	kfree(buffer);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-23 15:51                                                 ` Julia Lawall
@ 2014-11-23 19:03                                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 19:03 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Joe Perches, Andreas Noever, LKML, kernel-janitors

> Why not just make the static source code analysis aware of the problem?

This is also possible, of course.


> You can treat static functions differently that non-static ones.

I have added this detail to my ideas around the next fine-tuning
for the published semantic patch approach.


> There is no need to change the code.

Can name space prefixes help to make source code a bit safer eventually?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-23 19:03                                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-23 19:03 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Joe Perches, Andreas Noever, LKML, kernel-janitors

> Why not just make the static source code analysis aware of the problem?

This is also possible, of course.


> You can treat static functions differently that non-static ones.

I have added this detail to my ideas around the next fine-tuning
for the published semantic patch approach.


> There is no need to change the code.

Can name space prefixes help to make source code a bit safer eventually?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
  2014-11-23 19:03                                                   ` SF Markus Elfring
@ 2014-11-23 19:06                                                     ` Joe Perches
  -1 siblings, 0 replies; 3633+ messages in thread
From: Joe Perches @ 2014-11-23 19:06 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Julia Lawall, Andreas Noever, LKML, kernel-janitors

On Sun, 2014-11-23 at 20:03 +0100, SF Markus Elfring wrote:
> > Why not just make the static source code analysis aware of the problem?
> 
> This is also possible, of course.
> 
> 
> > You can treat static functions differently that non-static ones.
> 
> I have added this detail to my ideas around the next fine-tuning
> for the published semantic patch approach.
> 
> 
> > There is no need to change the code.
> 
> Can name space prefixes help to make source code a bit safer eventually?

Not really.
Adding prefixes can make code unnecessarily more verbose though.


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"
@ 2014-11-23 19:06                                                     ` Joe Perches
  0 siblings, 0 replies; 3633+ messages in thread
From: Joe Perches @ 2014-11-23 19:06 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Julia Lawall, Andreas Noever, LKML, kernel-janitors

On Sun, 2014-11-23 at 20:03 +0100, SF Markus Elfring wrote:
> > Why not just make the static source code analysis aware of the problem?
> 
> This is also possible, of course.
> 
> 
> > You can treat static functions differently that non-static ones.
> 
> I have added this detail to my ideas around the next fine-tuning
> for the published semantic patch approach.
> 
> 
> > There is no need to change the code.
> 
> Can name space prefixes help to make source code a bit safer eventually?

Not really.
Adding prefixes can make code unnecessarily more verbose though.


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] Sony-laptop: Deletion of an unnecessary check before the function call "pci_dev_put"
  2014-11-24 21:04                                   ` SF Markus Elfring
@ 2014-11-24  8:28                                     ` Darren Hart
  -1 siblings, 0 replies; 3633+ messages in thread
From: Darren Hart @ 2014-11-24  8:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Mattia Dongili, platform-driver-x86, LKML, kernel-janitors, Julia Lawall

On Mon, Nov 24, 2014 at 10:04:16PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 24 Nov 2014 22:00:21 +0100
> 
> The pci_dev_put() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks Markus, queued.

-- 
Darren Hart
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] Sony-laptop: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-24  8:28                                     ` Darren Hart
  0 siblings, 0 replies; 3633+ messages in thread
From: Darren Hart @ 2014-11-24  8:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Mattia Dongili, platform-driver-x86, LKML, kernel-janitors, Julia Lawall

On Mon, Nov 24, 2014 at 10:04:16PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 24 Nov 2014 22:00:21 +0100
> 
> The pci_dev_put() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks Markus, queued.

-- 
Darren Hart
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
  2014-11-24 19:40                                   ` SF Markus Elfring
@ 2014-11-24  8:28                                     ` Darren Hart
  -1 siblings, 0 replies; 3633+ messages in thread
From: Darren Hart @ 2014-11-24  8:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Anisse Astier, Corentin Chary, Ike Panhc, Jonathan Woithe,
	Mattia Dongili, platform-driver-x86, acpi4asus-user, LKML,
	kernel-janitors, Julia Lawall

On Mon, Nov 24, 2014 at 08:40:22PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 24 Nov 2014 20:30:29 +0100
> 
> The backlight_device_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks Markus, queued.

-- 
Darren Hart
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
@ 2014-11-24  8:28                                     ` Darren Hart
  0 siblings, 0 replies; 3633+ messages in thread
From: Darren Hart @ 2014-11-24  8:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Anisse Astier, Corentin Chary, Ike Panhc, Jonathan Woithe,
	Mattia Dongili, platform-driver-x86, acpi4asus-user, LKML,
	kernel-janitors, Julia Lawall

On Mon, Nov 24, 2014 at 08:40:22PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 24 Nov 2014 20:30:29 +0100
> 
> The backlight_device_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks Markus, queued.

-- 
Darren Hart
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
  2014-11-23 13:24                                                 ` SF Markus Elfring
  (?)
@ 2014-11-24  9:03                                                   ` Dan Carpenter
  -1 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-24  9:03 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, trivial, kernel-janitors, linux-kernel, Eric Paris,
	Coccinelle

On Sun, Nov 23, 2014 at 02:24:32PM +0100, SF Markus Elfring wrote:
> > Program analysis tools can also potentially exploit this information,
> 
> The published semantic patch scripts correspond to this desire.
> 

Sorry for that.

I have deleted the Smatch check for this so it no longer warns about:

	if (foo)
		kfree(foo);

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-24  9:03                                                   ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-24  9:03 UTC (permalink / raw)
  To: cocci

On Sun, Nov 23, 2014 at 02:24:32PM +0100, SF Markus Elfring wrote:
> > Program analysis tools can also potentially exploit this information,
> 
> The published semantic patch scripts correspond to this desire.
> 

Sorry for that.

I have deleted the Smatch check for this so it no longer warns about:

	if (foo)
		kfree(foo);

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [Cocci] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end"
@ 2014-11-24  9:03                                                   ` Dan Carpenter
  0 siblings, 0 replies; 3633+ messages in thread
From: Dan Carpenter @ 2014-11-24  9:03 UTC (permalink / raw)
  To: cocci

On Sun, Nov 23, 2014 at 02:24:32PM +0100, SF Markus Elfring wrote:
> > Program analysis tools can also potentially exploit this information,
> 
> The published semantic patch scripts correspond to this desire.
> 

Sorry for that.

I have deleted the Smatch check for this so it no longer warns about:

	if (foo)
		kfree(foo);

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: USB: serial: Deletion of an unnecessary check before the function call "release_firmware"
  2014-11-21 17:59                                         ` Julia Lawall
@ 2014-11-24  9:10                                           ` Johan Hovold
  -1 siblings, 0 replies; 3633+ messages in thread
From: Johan Hovold @ 2014-11-24  9:10 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Greg Kroah-Hartman, Johan Hovold, linux-usb,
	LKML, kernel-janitors

On Fri, Nov 21, 2014 at 06:59:00PM +0100, Julia Lawall wrote:
> On Fri, 21 Nov 2014, SF Markus Elfring wrote:
> 
> > >> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
> > >> index ab1d690..3653ec1 100644
> > >> --- a/drivers/usb/serial/mxuport.c
> > >> +++ b/drivers/usb/serial/mxuport.c
> > >> @@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
> > >>  	 */
> > >>  	usb_set_serial_data(serial, (void *)id->driver_info);
> > >>  out:
> > >> -	if (fw_p)
> > >> -		release_firmware(fw_p);
> > >> +	release_firmware(fw_p);
> > >
> > > I think that the if should stay.
> >
> > I have got an other opinion.
> >
> >
> > > There were two cases on the allocation, so there should be two cases
> > > on the release.
> >
> > I find that this implementation detail does not really matter for the
> > necessity of a null pointer check directly before such a function call.
> 
> Conceptually, if it is clear 10 lines above that nothing was allocated,
> and there is a fallback to existing data (according to the comment above)
> it is strange to be releasing something.

I agree with Julia here and will not apply this one.

Thanks,
Johan

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: USB: serial: Deletion of an unnecessary check before the function call "release_firmware"
@ 2014-11-24  9:10                                           ` Johan Hovold
  0 siblings, 0 replies; 3633+ messages in thread
From: Johan Hovold @ 2014-11-24  9:10 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Greg Kroah-Hartman, Johan Hovold, linux-usb,
	LKML, kernel-janitors

On Fri, Nov 21, 2014 at 06:59:00PM +0100, Julia Lawall wrote:
> On Fri, 21 Nov 2014, SF Markus Elfring wrote:
> 
> > >> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
> > >> index ab1d690..3653ec1 100644
> > >> --- a/drivers/usb/serial/mxuport.c
> > >> +++ b/drivers/usb/serial/mxuport.c
> > >> @@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
> > >>  	 */
> > >>  	usb_set_serial_data(serial, (void *)id->driver_info);
> > >>  out:
> > >> -	if (fw_p)
> > >> -		release_firmware(fw_p);
> > >> +	release_firmware(fw_p);
> > >
> > > I think that the if should stay.
> >
> > I have got an other opinion.
> >
> >
> > > There were two cases on the allocation, so there should be two cases
> > > on the release.
> >
> > I find that this implementation detail does not really matter for the
> > necessity of a null pointer check directly before such a function call.
> 
> Conceptually, if it is clear 10 lines above that nothing was allocated,
> and there is a fallback to existing data (according to the comment above)
> it is strange to be releasing something.

I agree with Julia here and will not apply this one.

Thanks,
Johan

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_device_unregister"
  2014-11-23 16:40                                   ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_ SF Markus Elfring
  (?)
@ 2014-11-24 10:09                                     ` Lee Jones
  -1 siblings, 0 replies; 3633+ messages in thread
From: Lee Jones @ 2014-11-24 10:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Tomi Valkeinen, linux-fbdev, LKML, kernel-janitors, Julia Lawall

On Sun, 23 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 23 Nov 2014 17:33:08 +0100

What format is this?

Can you use `git format-patch` and `git send-email` instead please?
 
> The backlight_device_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/video/backlight/lp8788_bl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
> index d6c4f6a..24a055c 100644
> --- a/drivers/video/backlight/lp8788_bl.c
> +++ b/drivers/video/backlight/lp8788_bl.c
> @@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
>  {
>  	struct backlight_device *bl_dev = bl->bl_dev;
>  
> -	if (bl_dev)
> -		backlight_device_unregister(bl_dev);
> +	backlight_device_unregister(bl_dev);
>  }
>  
>  static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backli
@ 2014-11-24 10:09                                     ` Lee Jones
  0 siblings, 0 replies; 3633+ messages in thread
From: Lee Jones @ 2014-11-24 10:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Tomi Valkeinen, linux-fbdev, LKML, kernel-janitors, Julia Lawall

On Sun, 23 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 23 Nov 2014 17:33:08 +0100

What format is this?

Can you use `git format-patch` and `git send-email` instead please?
 
> The backlight_device_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/video/backlight/lp8788_bl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
> index d6c4f6a..24a055c 100644
> --- a/drivers/video/backlight/lp8788_bl.c
> +++ b/drivers/video/backlight/lp8788_bl.c
> @@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
>  {
>  	struct backlight_device *bl_dev = bl->bl_dev;
>  
> -	if (bl_dev)
> -		backlight_device_unregister(bl_dev);
> +	backlight_device_unregister(bl_dev);
>  }
>  
>  static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backli
@ 2014-11-24 10:09                                     ` Lee Jones
  0 siblings, 0 replies; 3633+ messages in thread
From: Lee Jones @ 2014-11-24 10:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Tomi Valkeinen, linux-fbdev, LKML, kernel-janitors, Julia Lawall

On Sun, 23 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 23 Nov 2014 17:33:08 +0100

What format is this?

Can you use `git format-patch` and `git send-email` instead please?
 
> The backlight_device_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/video/backlight/lp8788_bl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
> index d6c4f6a..24a055c 100644
> --- a/drivers/video/backlight/lp8788_bl.c
> +++ b/drivers/video/backlight/lp8788_bl.c
> @@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
>  {
>  	struct backlight_device *bl_dev = bl->bl_dev;
>  
> -	if (bl_dev)
> -		backlight_device_unregister(bl_dev);
> +	backlight_device_unregister(bl_dev);
>  }
>  
>  static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_device_unregister"
  2014-11-23 16:40                                   ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_ SF Markus Elfring
  (?)
@ 2014-11-24 10:10                                     ` Lee Jones
  -1 siblings, 0 replies; 3633+ messages in thread
From: Lee Jones @ 2014-11-24 10:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Tomi Valkeinen, linux-fbdev, LKML, kernel-janitors, Julia Lawall

On Sun, 23 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 23 Nov 2014 17:33:08 +0100
> 
> The backlight_device_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.

Also the $SUBJECT should be less than 75 chars.

> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/video/backlight/lp8788_bl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
> index d6c4f6a..24a055c 100644
> --- a/drivers/video/backlight/lp8788_bl.c
> +++ b/drivers/video/backlight/lp8788_bl.c
> @@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
>  {
>  	struct backlight_device *bl_dev = bl->bl_dev;
>  
> -	if (bl_dev)
> -		backlight_device_unregister(bl_dev);
> +	backlight_device_unregister(bl_dev);
>  }
>  
>  static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backli
@ 2014-11-24 10:10                                     ` Lee Jones
  0 siblings, 0 replies; 3633+ messages in thread
From: Lee Jones @ 2014-11-24 10:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Tomi Valkeinen, linux-fbdev, LKML, kernel-janitors, Julia Lawall

On Sun, 23 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 23 Nov 2014 17:33:08 +0100
> 
> The backlight_device_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.

Also the $SUBJECT should be less than 75 chars.

> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/video/backlight/lp8788_bl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
> index d6c4f6a..24a055c 100644
> --- a/drivers/video/backlight/lp8788_bl.c
> +++ b/drivers/video/backlight/lp8788_bl.c
> @@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
>  {
>  	struct backlight_device *bl_dev = bl->bl_dev;
>  
> -	if (bl_dev)
> -		backlight_device_unregister(bl_dev);
> +	backlight_device_unregister(bl_dev);
>  }
>  
>  static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backli
@ 2014-11-24 10:10                                     ` Lee Jones
  0 siblings, 0 replies; 3633+ messages in thread
From: Lee Jones @ 2014-11-24 10:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Tomi Valkeinen, linux-fbdev, LKML, kernel-janitors, Julia Lawall

On Sun, 23 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 23 Nov 2014 17:33:08 +0100
> 
> The backlight_device_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.

Also the $SUBJECT should be less than 75 chars.

> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/video/backlight/lp8788_bl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
> index d6c4f6a..24a055c 100644
> --- a/drivers/video/backlight/lp8788_bl.c
> +++ b/drivers/video/backlight/lp8788_bl.c
> @@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
>  {
>  	struct backlight_device *bl_dev = bl->bl_dev;
>  
> -	if (bl_dev)
> -		backlight_device_unregister(bl_dev);
> +	backlight_device_unregister(bl_dev);
>  }
>  
>  static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister()
  2014-11-24 10:10                                     ` Lee Jones
@ 2014-11-24 18:05                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 18:05 UTC (permalink / raw)
  To: Lee Jones
  Cc: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Tomi Valkeinen, linux-fbdev, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
index d6c4f6a..24a055c 100644
--- a/drivers/video/backlight/lp8788_bl.c
+++ b/drivers/video/backlight/lp8788_bl.c
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister()
@ 2014-11-24 18:05                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 18:05 UTC (permalink / raw)
  To: Lee Jones
  Cc: Bryan Wu, Jean-Christophe Plagniol-Villard, Jingoo Han,
	Tomi Valkeinen, linux-fbdev, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
index d6c4f6a..24a055c 100644
--- a/drivers/video/backlight/lp8788_bl.c
+++ b/drivers/video/backlight/lp8788_bl.c
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] s390/pci: Deletion of unnecessary checks before the function call "debug_unregister"
  2014-11-22 14:05                                   ` SF Markus Elfring
@ 2014-11-24 19:06                                     ` Sebastian Ott
  -1 siblings, 0 replies; 3633+ messages in thread
From: Sebastian Ott @ 2014-11-24 19:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Heiko Carstens, Gerald Schaefer, Martin Schwidefsky, linux390,
	linux-s390, LKML, kernel-janitors, Julia Lawall

On Sat, 22 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 22 Nov 2014 15:00:55 +0100
> 
> The debug_unregister() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/s390/pci/pci_debug.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c
> index eec598c..18403a7 100644
> --- a/arch/s390/pci/pci_debug.c
> +++ b/arch/s390/pci/pci_debug.c
> @@ -158,10 +158,8 @@ int __init zpci_debug_init(void)
> 
>  void zpci_debug_exit(void)
>  {
> -	if (pci_debug_msg_id)
> -		debug_unregister(pci_debug_msg_id);
> -	if (pci_debug_err_id)
> -		debug_unregister(pci_debug_err_id);
> +	debug_unregister(pci_debug_msg_id);
> +	debug_unregister(pci_debug_err_id);
> 
>  	debugfs_remove(debugfs_root);
>  }

Applied.

Thanks,
Sebastian


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] s390/pci: Deletion of unnecessary checks before the function call "debug_unregister"
@ 2014-11-24 19:06                                     ` Sebastian Ott
  0 siblings, 0 replies; 3633+ messages in thread
From: Sebastian Ott @ 2014-11-24 19:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Heiko Carstens, Gerald Schaefer, Martin Schwidefsky, linux390,
	linux-s390, LKML, kernel-janitors, Julia Lawall

On Sat, 22 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 22 Nov 2014 15:00:55 +0100
> 
> The debug_unregister() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/s390/pci/pci_debug.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c
> index eec598c..18403a7 100644
> --- a/arch/s390/pci/pci_debug.c
> +++ b/arch/s390/pci/pci_debug.c
> @@ -158,10 +158,8 @@ int __init zpci_debug_init(void)
> 
>  void zpci_debug_exit(void)
>  {
> -	if (pci_debug_msg_id)
> -		debug_unregister(pci_debug_msg_id);
> -	if (pci_debug_err_id)
> -		debug_unregister(pci_debug_err_id);
> +	debug_unregister(pci_debug_msg_id);
> +	debug_unregister(pci_debug_err_id);
> 
>  	debugfs_remove(debugfs_root);
>  }

Applied.

Thanks,
Sebastian


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-24 19:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 19:40 UTC (permalink / raw)
  To: Anisse Astier, Corentin Chary, Darren Hart, Ike Panhc,
	Jonathan Woithe, Mattia Dongili, platform-driver-x86,
	acpi4asus-user
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 20:30:29 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/platform/x86/asus-laptop.c    | 3 +--
 drivers/platform/x86/asus-wmi.c       | 3 +--
 drivers/platform/x86/eeepc-laptop.c   | 3 +--
 drivers/platform/x86/fujitsu-laptop.c | 6 ++----
 drivers/platform/x86/ideapad-laptop.c | 3 +--
 drivers/platform/x86/intel_oaktrail.c | 3 +--
 drivers/platform/x86/msi-wmi.c        | 3 +--
 drivers/platform/x86/sony-laptop.c    | 3 +--
 drivers/platform/x86/toshiba_acpi.c   | 3 +--
 9 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 7f4dc6f..11fac1a 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -843,8 +843,7 @@ static int asus_backlight_init(struct asus_laptop *asus)
 
 static void asus_backlight_exit(struct asus_laptop *asus)
 {
-	if (asus->backlight_device)
-		backlight_device_unregister(asus->backlight_device);
+	backlight_device_unregister(asus->backlight_device);
 	asus->backlight_device = NULL;
 }
 
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 21fc932..7543a56 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1308,8 +1308,7 @@ static int asus_wmi_backlight_init(struct asus_wmi *asus)
 
 static void asus_wmi_backlight_exit(struct asus_wmi *asus)
 {
-	if (asus->backlight_device)
-		backlight_device_unregister(asus->backlight_device);
+	backlight_device_unregister(asus->backlight_device);
 
 	asus->backlight_device = NULL;
 }
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index bd533c2..9bc7eb7 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -1158,8 +1158,7 @@ static int eeepc_backlight_init(struct eeepc_laptop *eeepc)
 
 static void eeepc_backlight_exit(struct eeepc_laptop *eeepc)
 {
-	if (eeepc->backlight_device)
-		backlight_device_unregister(eeepc->backlight_device);
+	backlight_device_unregister(eeepc->backlight_device);
 	eeepc->backlight_device = NULL;
 }
 
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 87aa28c..f1a670b 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -1147,8 +1147,7 @@ fail_hotkey1:
 fail_hotkey:
 	platform_driver_unregister(&fujitsupf_driver);
 fail_backlight:
-	if (fujitsu->bl_device)
-		backlight_device_unregister(fujitsu->bl_device);
+	backlight_device_unregister(fujitsu->bl_device);
 fail_sysfs_group:
 	sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
 			   &fujitsupf_attribute_group);
@@ -1172,8 +1171,7 @@ static void __exit fujitsu_cleanup(void)
 
 	platform_driver_unregister(&fujitsupf_driver);
 
-	if (fujitsu->bl_device)
-		backlight_device_unregister(fujitsu->bl_device);
+	backlight_device_unregister(fujitsu->bl_device);
 
 	sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
 			   &fujitsupf_attribute_group);
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index ed494f3..3163061 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -729,8 +729,7 @@ static int ideapad_backlight_init(struct ideapad_private *priv)
 
 static void ideapad_backlight_exit(struct ideapad_private *priv)
 {
-	if (priv->blightdev)
-		backlight_device_unregister(priv->blightdev);
+	backlight_device_unregister(priv->blightdev);
 	priv->blightdev = NULL;
 }
 
diff --git a/drivers/platform/x86/intel_oaktrail.c b/drivers/platform/x86/intel_oaktrail.c
index 4bc9604..0dd72cf 100644
--- a/drivers/platform/x86/intel_oaktrail.c
+++ b/drivers/platform/x86/intel_oaktrail.c
@@ -271,8 +271,7 @@ static int oaktrail_backlight_init(void)
 
 static void oaktrail_backlight_exit(void)
 {
-	if (oaktrail_bl_device)
-		backlight_device_unregister(oaktrail_bl_device);
+	backlight_device_unregister(oaktrail_bl_device);
 }
 
 static int oaktrail_probe(struct platform_device *pdev)
diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
index 70222f2..6d2bac0 100644
--- a/drivers/platform/x86/msi-wmi.c
+++ b/drivers/platform/x86/msi-wmi.c
@@ -354,8 +354,7 @@ static void __exit msi_wmi_exit(void)
 		sparse_keymap_free(msi_wmi_input_dev);
 		input_unregister_device(msi_wmi_input_dev);
 	}
-	if (backlight)
-		backlight_device_unregister(backlight);
+	backlight_device_unregister(backlight);
 }
 
 module_init(msi_wmi_init);
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 26ad9ff..a48cdc7 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -3141,8 +3141,7 @@ static void sony_nc_backlight_setup(void)
 
 static void sony_nc_backlight_cleanup(void)
 {
-	if (sony_bl_props.dev)
-		backlight_device_unregister(sony_bl_props.dev);
+	backlight_device_unregister(sony_bl_props.dev);
 }
 
 static int sony_nc_add(struct acpi_device *device)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index d0dce73..703a68a 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1647,8 +1647,7 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
 		rfkill_destroy(dev->bt_rfk);
 	}
 
-	if (dev->backlight_dev)
-		backlight_device_unregister(dev->backlight_dev);
+	backlight_device_unregister(dev->backlight_dev);
 
 	if (dev->illumination_supported)
 		led_classdev_unregister(&dev->led_dev);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
@ 2014-11-24 19:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 19:40 UTC (permalink / raw)
  To: Anisse Astier, Corentin Chary, Darren Hart, Ike Panhc,
	Jonathan Woithe, Mattia Dongili, platform-driver-x86,
	acpi4asus-user
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 20:30:29 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/platform/x86/asus-laptop.c    | 3 +--
 drivers/platform/x86/asus-wmi.c       | 3 +--
 drivers/platform/x86/eeepc-laptop.c   | 3 +--
 drivers/platform/x86/fujitsu-laptop.c | 6 ++----
 drivers/platform/x86/ideapad-laptop.c | 3 +--
 drivers/platform/x86/intel_oaktrail.c | 3 +--
 drivers/platform/x86/msi-wmi.c        | 3 +--
 drivers/platform/x86/sony-laptop.c    | 3 +--
 drivers/platform/x86/toshiba_acpi.c   | 3 +--
 9 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 7f4dc6f..11fac1a 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -843,8 +843,7 @@ static int asus_backlight_init(struct asus_laptop *asus)
 
 static void asus_backlight_exit(struct asus_laptop *asus)
 {
-	if (asus->backlight_device)
-		backlight_device_unregister(asus->backlight_device);
+	backlight_device_unregister(asus->backlight_device);
 	asus->backlight_device = NULL;
 }
 
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 21fc932..7543a56 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1308,8 +1308,7 @@ static int asus_wmi_backlight_init(struct asus_wmi *asus)
 
 static void asus_wmi_backlight_exit(struct asus_wmi *asus)
 {
-	if (asus->backlight_device)
-		backlight_device_unregister(asus->backlight_device);
+	backlight_device_unregister(asus->backlight_device);
 
 	asus->backlight_device = NULL;
 }
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index bd533c2..9bc7eb7 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -1158,8 +1158,7 @@ static int eeepc_backlight_init(struct eeepc_laptop *eeepc)
 
 static void eeepc_backlight_exit(struct eeepc_laptop *eeepc)
 {
-	if (eeepc->backlight_device)
-		backlight_device_unregister(eeepc->backlight_device);
+	backlight_device_unregister(eeepc->backlight_device);
 	eeepc->backlight_device = NULL;
 }
 
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 87aa28c..f1a670b 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -1147,8 +1147,7 @@ fail_hotkey1:
 fail_hotkey:
 	platform_driver_unregister(&fujitsupf_driver);
 fail_backlight:
-	if (fujitsu->bl_device)
-		backlight_device_unregister(fujitsu->bl_device);
+	backlight_device_unregister(fujitsu->bl_device);
 fail_sysfs_group:
 	sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
 			   &fujitsupf_attribute_group);
@@ -1172,8 +1171,7 @@ static void __exit fujitsu_cleanup(void)
 
 	platform_driver_unregister(&fujitsupf_driver);
 
-	if (fujitsu->bl_device)
-		backlight_device_unregister(fujitsu->bl_device);
+	backlight_device_unregister(fujitsu->bl_device);
 
 	sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
 			   &fujitsupf_attribute_group);
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index ed494f3..3163061 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -729,8 +729,7 @@ static int ideapad_backlight_init(struct ideapad_private *priv)
 
 static void ideapad_backlight_exit(struct ideapad_private *priv)
 {
-	if (priv->blightdev)
-		backlight_device_unregister(priv->blightdev);
+	backlight_device_unregister(priv->blightdev);
 	priv->blightdev = NULL;
 }
 
diff --git a/drivers/platform/x86/intel_oaktrail.c b/drivers/platform/x86/intel_oaktrail.c
index 4bc9604..0dd72cf 100644
--- a/drivers/platform/x86/intel_oaktrail.c
+++ b/drivers/platform/x86/intel_oaktrail.c
@@ -271,8 +271,7 @@ static int oaktrail_backlight_init(void)
 
 static void oaktrail_backlight_exit(void)
 {
-	if (oaktrail_bl_device)
-		backlight_device_unregister(oaktrail_bl_device);
+	backlight_device_unregister(oaktrail_bl_device);
 }
 
 static int oaktrail_probe(struct platform_device *pdev)
diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
index 70222f2..6d2bac0 100644
--- a/drivers/platform/x86/msi-wmi.c
+++ b/drivers/platform/x86/msi-wmi.c
@@ -354,8 +354,7 @@ static void __exit msi_wmi_exit(void)
 		sparse_keymap_free(msi_wmi_input_dev);
 		input_unregister_device(msi_wmi_input_dev);
 	}
-	if (backlight)
-		backlight_device_unregister(backlight);
+	backlight_device_unregister(backlight);
 }
 
 module_init(msi_wmi_init);
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 26ad9ff..a48cdc7 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -3141,8 +3141,7 @@ static void sony_nc_backlight_setup(void)
 
 static void sony_nc_backlight_cleanup(void)
 {
-	if (sony_bl_props.dev)
-		backlight_device_unregister(sony_bl_props.dev);
+	backlight_device_unregister(sony_bl_props.dev);
 }
 
 static int sony_nc_add(struct acpi_device *device)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index d0dce73..703a68a 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1647,8 +1647,7 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
 		rfkill_destroy(dev->bt_rfk);
 	}
 
-	if (dev->backlight_dev)
-		backlight_device_unregister(dev->backlight_dev);
+	backlight_device_unregister(dev->backlight_dev);
 
 	if (dev->illumination_supported)
 		led_classdev_unregister(&dev->led_dev);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
@ 2014-11-24 19:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 19:40 UTC (permalink / raw)
  To: Anisse Astier, Corentin Chary, Darren Hart, Ike Panhc,
	Jonathan Woithe, Mattia Dongili, platform-driver-x86,
	acpi4asus-user
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 20:30:29 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/platform/x86/asus-laptop.c    | 3 +--
 drivers/platform/x86/asus-wmi.c       | 3 +--
 drivers/platform/x86/eeepc-laptop.c   | 3 +--
 drivers/platform/x86/fujitsu-laptop.c | 6 ++----
 drivers/platform/x86/ideapad-laptop.c | 3 +--
 drivers/platform/x86/intel_oaktrail.c | 3 +--
 drivers/platform/x86/msi-wmi.c        | 3 +--
 drivers/platform/x86/sony-laptop.c    | 3 +--
 drivers/platform/x86/toshiba_acpi.c   | 3 +--
 9 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 7f4dc6f..11fac1a 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -843,8 +843,7 @@ static int asus_backlight_init(struct asus_laptop *asus)
 
 static void asus_backlight_exit(struct asus_laptop *asus)
 {
-	if (asus->backlight_device)
-		backlight_device_unregister(asus->backlight_device);
+	backlight_device_unregister(asus->backlight_device);
 	asus->backlight_device = NULL;
 }
 
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 21fc932..7543a56 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1308,8 +1308,7 @@ static int asus_wmi_backlight_init(struct asus_wmi *asus)
 
 static void asus_wmi_backlight_exit(struct asus_wmi *asus)
 {
-	if (asus->backlight_device)
-		backlight_device_unregister(asus->backlight_device);
+	backlight_device_unregister(asus->backlight_device);
 
 	asus->backlight_device = NULL;
 }
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index bd533c2..9bc7eb7 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -1158,8 +1158,7 @@ static int eeepc_backlight_init(struct eeepc_laptop *eeepc)
 
 static void eeepc_backlight_exit(struct eeepc_laptop *eeepc)
 {
-	if (eeepc->backlight_device)
-		backlight_device_unregister(eeepc->backlight_device);
+	backlight_device_unregister(eeepc->backlight_device);
 	eeepc->backlight_device = NULL;
 }
 
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 87aa28c..f1a670b 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -1147,8 +1147,7 @@ fail_hotkey1:
 fail_hotkey:
 	platform_driver_unregister(&fujitsupf_driver);
 fail_backlight:
-	if (fujitsu->bl_device)
-		backlight_device_unregister(fujitsu->bl_device);
+	backlight_device_unregister(fujitsu->bl_device);
 fail_sysfs_group:
 	sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
 			   &fujitsupf_attribute_group);
@@ -1172,8 +1171,7 @@ static void __exit fujitsu_cleanup(void)
 
 	platform_driver_unregister(&fujitsupf_driver);
 
-	if (fujitsu->bl_device)
-		backlight_device_unregister(fujitsu->bl_device);
+	backlight_device_unregister(fujitsu->bl_device);
 
 	sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
 			   &fujitsupf_attribute_group);
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index ed494f3..3163061 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -729,8 +729,7 @@ static int ideapad_backlight_init(struct ideapad_private *priv)
 
 static void ideapad_backlight_exit(struct ideapad_private *priv)
 {
-	if (priv->blightdev)
-		backlight_device_unregister(priv->blightdev);
+	backlight_device_unregister(priv->blightdev);
 	priv->blightdev = NULL;
 }
 
diff --git a/drivers/platform/x86/intel_oaktrail.c b/drivers/platform/x86/intel_oaktrail.c
index 4bc9604..0dd72cf 100644
--- a/drivers/platform/x86/intel_oaktrail.c
+++ b/drivers/platform/x86/intel_oaktrail.c
@@ -271,8 +271,7 @@ static int oaktrail_backlight_init(void)
 
 static void oaktrail_backlight_exit(void)
 {
-	if (oaktrail_bl_device)
-		backlight_device_unregister(oaktrail_bl_device);
+	backlight_device_unregister(oaktrail_bl_device);
 }
 
 static int oaktrail_probe(struct platform_device *pdev)
diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
index 70222f2..6d2bac0 100644
--- a/drivers/platform/x86/msi-wmi.c
+++ b/drivers/platform/x86/msi-wmi.c
@@ -354,8 +354,7 @@ static void __exit msi_wmi_exit(void)
 		sparse_keymap_free(msi_wmi_input_dev);
 		input_unregister_device(msi_wmi_input_dev);
 	}
-	if (backlight)
-		backlight_device_unregister(backlight);
+	backlight_device_unregister(backlight);
 }
 
 module_init(msi_wmi_init);
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 26ad9ff..a48cdc7 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -3141,8 +3141,7 @@ static void sony_nc_backlight_setup(void)
 
 static void sony_nc_backlight_cleanup(void)
 {
-	if (sony_bl_props.dev)
-		backlight_device_unregister(sony_bl_props.dev);
+	backlight_device_unregister(sony_bl_props.dev);
 }
 
 static int sony_nc_add(struct acpi_device *device)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index d0dce73..703a68a 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1647,8 +1647,7 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
 		rfkill_destroy(dev->bt_rfk);
 	}
 
-	if (dev->backlight_dev)
-		backlight_device_unregister(dev->backlight_dev);
+	backlight_device_unregister(dev->backlight_dev);
 
 	if (dev->illumination_supported)
 		led_classdev_unregister(&dev->led_dev);
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] Sony-laptop: Deletion of an unnecessary check before the function call "pci_dev_put"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-24 21:04                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 21:04 UTC (permalink / raw)
  To: Darren Hart, Mattia Dongili, platform-driver-x86
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 22:00:21 +0100

The pci_dev_put() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/platform/x86/sony-laptop.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 26ad9ff..22b173d 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -3717,8 +3717,7 @@ static void sony_pic_detect_device_type(struct sony_pic_dev *dev)
 	dev->event_types = type2_events;
 
 out:
-	if (pcidev)
-		pci_dev_put(pcidev);
+	pci_dev_put(pcidev);
 
 	pr_info("detected Type%d model\n",
 		dev->model == SONYPI_DEVICE_TYPE1 ? 1 :
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] Sony-laptop: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-24 21:04                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 21:04 UTC (permalink / raw)
  To: Darren Hart, Mattia Dongili, platform-driver-x86
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 22:00:21 +0100

The pci_dev_put() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/platform/x86/sony-laptop.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 26ad9ff..22b173d 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -3717,8 +3717,7 @@ static void sony_pic_detect_device_type(struct sony_pic_dev *dev)
 	dev->event_types = type2_events;
 
 out:
-	if (pcidev)
-		pci_dev_put(pcidev);
+	pci_dev_put(pcidev);
 
 	pr_info("detected Type%d model\n",
 		dev->model = SONYPI_DEVICE_TYPE1 ? 1 :
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] Sony-laptop: Deletion of an unnecessary check before the function call "pci_dev_put"
@ 2014-11-24 21:04                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 21:04 UTC (permalink / raw)
  To: Darren Hart, Mattia Dongili, platform-driver-x86
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 22:00:21 +0100

The pci_dev_put() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/platform/x86/sony-laptop.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 26ad9ff..22b173d 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -3717,8 +3717,7 @@ static void sony_pic_detect_device_type(struct sony_pic_dev *dev)
 	dev->event_types = type2_events;
 
 out:
-	if (pcidev)
-		pci_dev_put(pcidev);
+	pci_dev_put(pcidev);
 
 	pr_info("detected Type%d model\n",
 		dev->model == SONYPI_DEVICE_TYPE1 ? 1 :
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
  2014-11-24 19:40                                   ` SF Markus Elfring
@ 2014-11-24 21:28                                     ` Anisse Astier
  -1 siblings, 0 replies; 3633+ messages in thread
From: Anisse Astier @ 2014-11-24 21:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Corentin Chary, Darren Hart, Ike Panhc, Jonathan Woithe,
	Mattia Dongili, platform-driver-x86, acpi4asus-user, LKML,
	kernel-janitors, Julia Lawall

Hi Markus,

Le lundi 24 novembre 2014, 20:40:22 SF Markus Elfring a écrit :
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 24 Nov 2014 20:30:29 +0100
> 
> The backlight_device_unregister() function tests whether its argument is
> NULL and then returns immediately. Thus the test around the call is not
> needed.
> 
> This issue was detected by using the Coccinelle software.

What script was used ? Is it in scripts/coccinelle ?


> diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
> index 70222f2..6d2bac0 100644
> --- a/drivers/platform/x86/msi-wmi.c
> +++ b/drivers/platform/x86/msi-wmi.c
> @@ -354,8 +354,7 @@ static void __exit msi_wmi_exit(void)
>  		sparse_keymap_free(msi_wmi_input_dev);
>  		input_unregister_device(msi_wmi_input_dev);
>  	}
> -	if (backlight)
> -		backlight_device_unregister(backlight);
> +	backlight_device_unregister(backlight);
>  }
> 
>  module_init(msi_wmi_init);

For this part:
Acked-by: Anisse Astier <anisse@astier.eu>

Regards,

Anisse

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
@ 2014-11-24 21:28                                     ` Anisse Astier
  0 siblings, 0 replies; 3633+ messages in thread
From: Anisse Astier @ 2014-11-24 21:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Corentin Chary, Darren Hart, Ike Panhc, Jonathan Woithe,
	Mattia Dongili, platform-driver-x86, acpi4asus-user, LKML,
	kernel-janitors, Julia Lawall

Hi Markus,

Le lundi 24 novembre 2014, 20:40:22 SF Markus Elfring a écrit :
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 24 Nov 2014 20:30:29 +0100
> 
> The backlight_device_unregister() function tests whether its argument is
> NULL and then returns immediately. Thus the test around the call is not
> needed.
> 
> This issue was detected by using the Coccinelle software.

What script was used ? Is it in scripts/coccinelle ?


> diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
> index 70222f2..6d2bac0 100644
> --- a/drivers/platform/x86/msi-wmi.c
> +++ b/drivers/platform/x86/msi-wmi.c
> @@ -354,8 +354,7 @@ static void __exit msi_wmi_exit(void)
>  		sparse_keymap_free(msi_wmi_input_dev);
>  		input_unregister_device(msi_wmi_input_dev);
>  	}
> -	if (backlight)
> -		backlight_device_unregister(backlight);
> +	backlight_device_unregister(backlight);
>  }
> 
>  module_init(msi_wmi_init);

For this part:
Acked-by: Anisse Astier <anisse@astier.eu>

Regards,

Anisse
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] [media] Siano: Deletion of an unnecessary check before the function call "rc_unregister_device"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-24 21:40                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 21:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 22:32:30 +0100

The rc_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/common/siano/smsir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c
index 273043e..35d0e88 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -107,8 +107,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
 
 void sms_ir_exit(struct smscore_device_t *coredev)
 {
-	if (coredev->ir.dev)
-		rc_unregister_device(coredev->ir.dev);
+	rc_unregister_device(coredev->ir.dev);
 
 	sms_log("");
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] [media] Siano: Deletion of an unnecessary check before the function call "rc_unregister_
@ 2014-11-24 21:40                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 21:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 22:32:30 +0100

The rc_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/common/siano/smsir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c
index 273043e..35d0e88 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -107,8 +107,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
 
 void sms_ir_exit(struct smscore_device_t *coredev)
 {
-	if (coredev->ir.dev)
-		rc_unregister_device(coredev->ir.dev);
+	rc_unregister_device(coredev->ir.dev);
 
 	sms_log("");
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] staging: olpc_dcon: Deletion of a check before backlight_device_unregister()
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-24 22:03                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 22:03 UTC (permalink / raw)
  To: Daniel Drake, Greg Kroah-Hartman, Jens Frederich, Jon Nettleton, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 22:58:48 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/olpc_dcon/olpc_dcon.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index eb83b28..6a9a881 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -682,8 +682,7 @@ static int dcon_remove(struct i2c_client *client)
 
 	free_irq(DCON_IRQ, dcon);
 
-	if (dcon->bl_dev)
-		backlight_device_unregister(dcon->bl_dev);
+	backlight_device_unregister(dcon->bl_dev);
 
 	if (dcon_device != NULL)
 		platform_device_unregister(dcon_device);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] staging: olpc_dcon: Deletion of a check before backlight_device_unregister()
@ 2014-11-24 22:03                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 22:03 UTC (permalink / raw)
  To: Daniel Drake, Greg Kroah-Hartman, Jens Frederich, Jon Nettleton, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 24 Nov 2014 22:58:48 +0100

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/olpc_dcon/olpc_dcon.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index eb83b28..6a9a881 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -682,8 +682,7 @@ static int dcon_remove(struct i2c_client *client)
 
 	free_irq(DCON_IRQ, dcon);
 
-	if (dcon->bl_dev)
-		backlight_device_unregister(dcon->bl_dev);
+	backlight_device_unregister(dcon->bl_dev);
 
 	if (dcon_device != NULL)
 		platform_device_unregister(dcon_device);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
  2014-11-24 21:28                                     ` Anisse Astier
@ 2014-11-24 22:12                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 22:12 UTC (permalink / raw)
  To: Anisse Astier
  Cc: Corentin Chary, Darren Hart, Ike Panhc, Jonathan Woithe,
	Mattia Dongili, platform-driver-x86, acpi4asus-user, LKML,
	kernel-janitors, Julia Lawall

>> This issue was detected by using the Coccinelle software.
> 
> What script was used ?

A semantic patch approach which I published on the mailing lists in March
is in action on my software development system for a while.


> Is it in scripts/coccinelle ?

Not yet.

I hope that the involved update suggestions got sufficient positive feedback
to integrate five scripts there.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
@ 2014-11-24 22:12                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-24 22:12 UTC (permalink / raw)
  To: Anisse Astier
  Cc: Corentin Chary, Darren Hart, Ike Panhc, Jonathan Woithe,
	Mattia Dongili, platform-driver-x86, acpi4asus-user, LKML,
	kernel-janitors, Julia Lawall

>> This issue was detected by using the Coccinelle software.
> 
> What script was used ?

A semantic patch approach which I published on the mailing lists in March
is in action on my software development system for a while.


> Is it in scripts/coccinelle ?

Not yet.

I hope that the involved update suggestions got sufficient positive feedback
to integrate five scripts there.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] GPU-DRM-MSM-Adreno: Deletion of unnecessary checks before the function call "release_firmware"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-25 12:50                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 12:50 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 13:44:20 +0100

The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 655ce5b..757052c 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -404,9 +404,7 @@ void adreno_gpu_cleanup(struct adreno_gpu *gpu)
 			msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id);
 		drm_gem_object_unreference(gpu->memptrs_bo);
 	}
-	if (gpu->pm4)
-		release_firmware(gpu->pm4);
-	if (gpu->pfp)
-		release_firmware(gpu->pfp);
+	release_firmware(gpu->pm4);
+	release_firmware(gpu->pfp);
 	msm_gpu_cleanup(&gpu->base);
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] GPU-DRM-MSM-Adreno: Deletion of unnecessary checks before the function call "release_fir
@ 2014-11-25 12:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 12:50 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 13:44:20 +0100

The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 655ce5b..757052c 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -404,9 +404,7 @@ void adreno_gpu_cleanup(struct adreno_gpu *gpu)
 			msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id);
 		drm_gem_object_unreference(gpu->memptrs_bo);
 	}
-	if (gpu->pm4)
-		release_firmware(gpu->pm4);
-	if (gpu->pfp)
-		release_firmware(gpu->pfp);
+	release_firmware(gpu->pm4);
+	release_firmware(gpu->pfp);
 	msm_gpu_cleanup(&gpu->base);
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] GPU-DRM-MSM-Adreno: Deletion of unnecessary checks before the function call "release_firmware"
@ 2014-11-25 12:50                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 12:50 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 13:44:20 +0100

The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 655ce5b..757052c 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -404,9 +404,7 @@ void adreno_gpu_cleanup(struct adreno_gpu *gpu)
 			msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id);
 		drm_gem_object_unreference(gpu->memptrs_bo);
 	}
-	if (gpu->pm4)
-		release_firmware(gpu->pm4);
-	if (gpu->pfp)
-		release_firmware(gpu->pfp);
+	release_firmware(gpu->pm4);
+	release_firmware(gpu->pfp);
 	msm_gpu_cleanup(&gpu->base);
 }
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] GPU-DRM-MSM: Deletion of unnecessary checks before two function calls
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
@ 2014-11-25 13:33                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 13:33 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 14:30:28 +0100

The functions framebuffer_release() and vunmap() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/msm/msm_fbdev.c | 3 +--
 drivers/gpu/drm/msm/msm_gem.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index ab5bfd2..fd5a6f3 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -193,8 +193,7 @@ fail_unlock:
 fail:
 
 	if (ret) {
-		if (fbi)
-			framebuffer_release(fbi);
+		framebuffer_release(fbi);
 		if (fb) {
 			drm_framebuffer_unregister_private(fb);
 			drm_framebuffer_remove(fb);
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 4b1b82a..157cf21 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -543,8 +543,7 @@ void msm_gem_free_object(struct drm_gem_object *obj)
 			drm_free_large(msm_obj->pages);
 
 	} else {
-		if (msm_obj->vaddr)
-			vunmap(msm_obj->vaddr);
+		vunmap(msm_obj->vaddr);
 		put_pages(obj);
 	}
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] GPU-DRM-MSM: Deletion of unnecessary checks before two function calls
@ 2014-11-25 13:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 13:33 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 14:30:28 +0100

The functions framebuffer_release() and vunmap() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/msm/msm_fbdev.c | 3 +--
 drivers/gpu/drm/msm/msm_gem.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index ab5bfd2..fd5a6f3 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -193,8 +193,7 @@ fail_unlock:
 fail:
 
 	if (ret) {
-		if (fbi)
-			framebuffer_release(fbi);
+		framebuffer_release(fbi);
 		if (fb) {
 			drm_framebuffer_unregister_private(fb);
 			drm_framebuffer_remove(fb);
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 4b1b82a..157cf21 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -543,8 +543,7 @@ void msm_gem_free_object(struct drm_gem_object *obj)
 			drm_free_large(msm_obj->pages);
 
 	} else {
-		if (msm_obj->vaddr)
-			vunmap(msm_obj->vaddr);
+		vunmap(msm_obj->vaddr);
 		put_pages(obj);
 	}
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] GPU-DRM-MSM: Deletion of unnecessary checks before two function calls
@ 2014-11-25 13:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 13:33 UTC (permalink / raw)
  To: David Airlie, dri-devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 14:30:28 +0100

The functions framebuffer_release() and vunmap() perform also input
parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/msm/msm_fbdev.c | 3 +--
 drivers/gpu/drm/msm/msm_gem.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index ab5bfd2..fd5a6f3 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -193,8 +193,7 @@ fail_unlock:
 fail:
 
 	if (ret) {
-		if (fbi)
-			framebuffer_release(fbi);
+		framebuffer_release(fbi);
 		if (fb) {
 			drm_framebuffer_unregister_private(fb);
 			drm_framebuffer_remove(fb);
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 4b1b82a..157cf21 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -543,8 +543,7 @@ void msm_gem_free_object(struct drm_gem_object *obj)
 			drm_free_large(msm_obj->pages);
 
 	} else {
-		if (msm_obj->vaddr)
-			vunmap(msm_obj->vaddr);
+		vunmap(msm_obj->vaddr);
 		put_pages(obj);
 	}
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] IMX-DRM-core: Deletion of a check before drm_fbdev_cma_restore_mode()
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-25 15:16                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 15:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 16:06:19 +0100

The drm_fbdev_cma_restore_mode() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/imx-drm/imx-drm-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 6b22106..0a1ecef 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -64,8 +64,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
 #if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
 	struct imx_drm_device *imxdrm = drm->dev_private;
 
-	if (imxdrm->fbhelper)
-		drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
+	drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
 #endif
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] IMX-DRM-core: Deletion of a check before drm_fbdev_cma_restore_mode()
@ 2014-11-25 15:16                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 15:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 16:06:19 +0100

The drm_fbdev_cma_restore_mode() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/imx-drm/imx-drm-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 6b22106..0a1ecef 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -64,8 +64,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
 #if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
 	struct imx_drm_device *imxdrm = drm->dev_private;
 
-	if (imxdrm->fbhelper)
-		drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
+	drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
 #endif
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_table"
  2014-11-22 12:00                                   ` [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_ta SF Markus Elfring
@ 2014-11-25 15:48                                     ` Jon Mason
  -1 siblings, 0 replies; 3633+ messages in thread
From: Jon Mason @ 2014-11-25 15:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: H. Peter Anvin, Ingo Molnar, Muli Ben-Yehuda, Thomas Gleixner,
	x86, discuss, LKML, kernel-janitors, Julia Lawall

On Sat, Nov 22, 2014 at 7:00 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 22 Nov 2014 12:55:28 +0100
>
> The free_tce_table() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Looks good to me

Acked-by: Jon Mason <jdmason@kudzu.us>


> ---
>  arch/x86/kernel/pci-calgary_64.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
> index 0497f71..d22a386 100644
> --- a/arch/x86/kernel/pci-calgary_64.c
> +++ b/arch/x86/kernel/pci-calgary_64.c
> @@ -1476,8 +1476,7 @@ cleanup:
>         for (--bus; bus >= 0; --bus) {
>                 struct calgary_bus_info *info = &bus_info[bus];
>
> -               if (info->tce_space)
> -                       free_tce_table(info->tce_space);
> +               free_tce_table(info->tce_space);
>         }
>         return -ENOMEM;
>  }
> --
> 2.1.3
>

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tc
@ 2014-11-25 15:48                                     ` Jon Mason
  0 siblings, 0 replies; 3633+ messages in thread
From: Jon Mason @ 2014-11-25 15:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: H. Peter Anvin, Ingo Molnar, Muli Ben-Yehuda, Thomas Gleixner,
	x86, discuss, LKML, kernel-janitors, Julia Lawall

On Sat, Nov 22, 2014 at 7:00 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 22 Nov 2014 12:55:28 +0100
>
> The free_tce_table() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Looks good to me

Acked-by: Jon Mason <jdmason@kudzu.us>


> ---
>  arch/x86/kernel/pci-calgary_64.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
> index 0497f71..d22a386 100644
> --- a/arch/x86/kernel/pci-calgary_64.c
> +++ b/arch/x86/kernel/pci-calgary_64.c
> @@ -1476,8 +1476,7 @@ cleanup:
>         for (--bus; bus >= 0; --bus) {
>                 struct calgary_bus_info *info = &bus_info[bus];
>
> -               if (info->tce_space)
> -                       free_tce_table(info->tce_space);
> +               free_tce_table(info->tce_space);
>         }
>         return -ENOMEM;
>  }
> --
> 2.1.3
>

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] staging: ozwpan: Deletion of unnecessary checks before the function call "oz_free_urb_link"
  2014-03-05 22:30                                 ` SF Markus Elfring
@ 2014-11-25 15:57                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 15:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Shigekatsu Tateno, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 16:51:08 +0100

The oz_free_urb_link() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/ozwpan/ozhcd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c
index 30bd928..c9b6d98 100644
--- a/drivers/staging/ozwpan/ozhcd.c
+++ b/drivers/staging/ozwpan/ozhcd.c
@@ -411,8 +411,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb,
 	}
 	spin_lock(&g_tasklet_lock);
 	spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
-	if (cancel_urbl)
-		oz_free_urb_link(cancel_urbl);
+	oz_free_urb_link(cancel_urbl);
 }
 
 /*
@@ -581,8 +580,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir,
 		}
 	}
 	spin_unlock_bh(&port->ozhcd->hcd_lock);
-	if (urbl)
-		oz_free_urb_link(urbl);
+	oz_free_urb_link(urbl);
 	return urbl ? 0 : -EIDRM;
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] staging: ozwpan: Deletion of unnecessary checks before the function call "oz_free_urb_li
@ 2014-11-25 15:57                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 15:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Shigekatsu Tateno, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 16:51:08 +0100

The oz_free_urb_link() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/ozwpan/ozhcd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c
index 30bd928..c9b6d98 100644
--- a/drivers/staging/ozwpan/ozhcd.c
+++ b/drivers/staging/ozwpan/ozhcd.c
@@ -411,8 +411,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb,
 	}
 	spin_lock(&g_tasklet_lock);
 	spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
-	if (cancel_urbl)
-		oz_free_urb_link(cancel_urbl);
+	oz_free_urb_link(cancel_urbl);
 }
 
 /*
@@ -581,8 +580,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir,
 		}
 	}
 	spin_unlock_bh(&port->ozhcd->hcd_lock);
-	if (urbl)
-		oz_free_urb_link(urbl);
+	oz_free_urb_link(urbl);
 	return urbl ? 0 : -EIDRM;
 }
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH v2] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-21 20:15                                     ` David Miller
  (?)
@ 2014-11-25 21:55                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 21:55 UTC (permalink / raw)
  To: David Miller, devel, netdev
  Cc: Haiyang Zhang, K. Y. Srinivasan, linux-kernel, kernel-janitors,
	Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 22:33:45 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/net/hyperv/netvsc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 6b46311..6fc834e 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -561,9 +561,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
-
+	vfree(net_device->sub_cb_buf);
 	free_netvsc_device(net_device);
 	return 0;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH v2] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-25 21:55                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 21:55 UTC (permalink / raw)
  To: David Miller, devel, netdev
  Cc: Julia Lawall, Haiyang Zhang, kernel-janitors, linux-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 22:33:45 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/net/hyperv/netvsc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 6b46311..6fc834e 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -561,9 +561,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
-
+	vfree(net_device->sub_cb_buf);
 	free_netvsc_device(net_device);
 	return 0;
 }
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH v2] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-25 21:55                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-25 21:55 UTC (permalink / raw)
  To: David Miller, devel, netdev
  Cc: Haiyang Zhang, K. Y. Srinivasan, linux-kernel, kernel-janitors,
	Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 22:33:45 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/net/hyperv/netvsc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 6b46311..6fc834e 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -561,9 +561,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
-
+	vfree(net_device->sub_cb_buf);
 	free_netvsc_device(net_device);
 	return 0;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [PATCH v2] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-25 21:55                                       ` SF Markus Elfring
@ 2014-11-25 22:25                                         ` David Miller
  -1 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-25 22:25 UTC (permalink / raw)
  To: elfring
  Cc: devel, netdev, haiyangz, kys, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 22:55:34 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 25 Nov 2014 22:33:45 +0100
> 
> The vfree() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH v2] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-25 22:25                                         ` David Miller
  0 siblings, 0 replies; 3633+ messages in thread
From: David Miller @ 2014-11-25 22:25 UTC (permalink / raw)
  To: elfring
  Cc: devel, netdev, haiyangz, kys, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 22:55:34 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 25 Nov 2014 22:33:45 +0100
> 
> The vfree() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [1/1] fs-ext4: Deletion of an unnecessary check before the function call "iput"
  2014-11-15 18:19                                   ` SF Markus Elfring
  (?)
@ 2014-11-26  1:16                                     ` Theodore Ts'o
  -1 siblings, 0 replies; 3633+ messages in thread
From: Theodore Ts'o @ 2014-11-26  1:16 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Andreas Dilger, linux-ext4, linux-kernel, kernel-janitors,
	trivial, Coccinelle

On Sat, Nov 15, 2014 at 07:19:36PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 15 Nov 2014 19:04:06 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied.

						- Ted

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [1/1] fs-ext4: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-26  1:16                                     ` Theodore Ts'o
  0 siblings, 0 replies; 3633+ messages in thread
From: Theodore Ts'o @ 2014-11-26  1:16 UTC (permalink / raw)
  To: cocci

On Sat, Nov 15, 2014 at 07:19:36PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 15 Nov 2014 19:04:06 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied.

						- Ted

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [Cocci] [1/1] fs-ext4: Deletion of an unnecessary check before the function call "iput"
@ 2014-11-26  1:16                                     ` Theodore Ts'o
  0 siblings, 0 replies; 3633+ messages in thread
From: Theodore Ts'o @ 2014-11-26  1:16 UTC (permalink / raw)
  To: cocci

On Sat, Nov 15, 2014 at 07:19:36PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 15 Nov 2014 19:04:06 +0100
> 
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied.

						- Ted

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] MTD: Deletion of unnecessary checks before two function calls
  2014-11-20 12:55                                   ` SF Markus Elfring
  (?)
@ 2014-11-26  6:50                                     ` Brian Norris
  -1 siblings, 0 replies; 3633+ messages in thread
From: Brian Norris @ 2014-11-26  6:50 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David Woodhouse, linux-mtd, LKML, kernel-janitors, Julia Lawall

On Thu, Nov 20, 2014 at 01:55:23PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 13:50:43 +0100
> 
> The functions kfree() and pci_dev_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to l2-mtd.git.

Brian

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] MTD: Deletion of unnecessary checks before two function calls
@ 2014-11-26  6:50                                     ` Brian Norris
  0 siblings, 0 replies; 3633+ messages in thread
From: Brian Norris @ 2014-11-26  6:50 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-mtd, kernel-janitors, David Woodhouse, LKML, Julia Lawall

On Thu, Nov 20, 2014 at 01:55:23PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 13:50:43 +0100
> 
> The functions kfree() and pci_dev_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to l2-mtd.git.

Brian

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] MTD: Deletion of unnecessary checks before two function calls
@ 2014-11-26  6:50                                     ` Brian Norris
  0 siblings, 0 replies; 3633+ messages in thread
From: Brian Norris @ 2014-11-26  6:50 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-mtd, kernel-janitors, David Woodhouse, LKML, Julia Lawall

On Thu, Nov 20, 2014 at 01:55:23PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 13:50:43 +0100
> 
> The functions kfree() and pci_dev_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to l2-mtd.git.

Brian

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detection
  2014-11-23 18:44                                     ` [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detecti SF Markus Elfring
@ 2014-11-26 21:42                                       ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 3633+ messages in thread
From: Greg Kroah-Hartman @ 2014-11-26 21:42 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: devel, LKML, kernel-janitors, Julia Lawall

On Sun, Nov 23, 2014 at 07:44:08PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 23 Nov 2014 19:12:29 +0100
> 
> The jump label "err1" was used by the ion_buffer_create() function in case of
> a memory allocation failure just to pass a null pointer to a vfree() function
> call by a data structure element.
> This implementation detail could be improved by the deletion of this
> inappropriate jump label.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/staging/android/ion/ion.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> index df12cc3..7a26b85 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -226,7 +226,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>  		buffer->pages = vmalloc(sizeof(struct page *) * num_pages);
>  		if (!buffer->pages) {
>  			ret = -ENOMEM;
> -			goto err1;
> +			goto err2;
>  		}
>  
>  		for_each_sg(table->sgl, sg, table->nents, i) {
> @@ -262,7 +262,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>  err:
>  	heap->ops->unmap_dma(heap, buffer);
>  	heap->ops->free(buffer);
> -err1:
>  	vfree(buffer->pages);
>  err2:

Now we have "err" and "err2", which doesn't make much sense, please fix
up.


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error det
@ 2014-11-26 21:42                                       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3633+ messages in thread
From: Greg Kroah-Hartman @ 2014-11-26 21:42 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: devel, LKML, kernel-janitors, Julia Lawall

On Sun, Nov 23, 2014 at 07:44:08PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 23 Nov 2014 19:12:29 +0100
> 
> The jump label "err1" was used by the ion_buffer_create() function in case of
> a memory allocation failure just to pass a null pointer to a vfree() function
> call by a data structure element.
> This implementation detail could be improved by the deletion of this
> inappropriate jump label.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/staging/android/ion/ion.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> index df12cc3..7a26b85 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -226,7 +226,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>  		buffer->pages = vmalloc(sizeof(struct page *) * num_pages);
>  		if (!buffer->pages) {
>  			ret = -ENOMEM;
> -			goto err1;
> +			goto err2;
>  		}
>  
>  		for_each_sg(table->sgl, sg, table->nents, i) {
> @@ -262,7 +262,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>  err:
>  	heap->ops->unmap_dma(heap, buffer);
>  	heap->ops->free(buffer);
> -err1:
>  	vfree(buffer->pages);
>  err2:

Now we have "err" and "err2", which doesn't make much sense, please fix
up.


^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detection
  2014-11-26 21:42                                       ` [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error det Greg Kroah-Hartman
@ 2014-11-27 14:25                                         ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-27 14:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, LKML, kernel-janitors, Julia Lawall

>> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
>> index df12cc3..7a26b85 100644
>> --- a/drivers/staging/android/ion/ion.c
>> +++ b/drivers/staging/android/ion/ion.c
>> @@ -226,7 +226,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>>  		buffer->pages = vmalloc(sizeof(struct page *) * num_pages);
>>  		if (!buffer->pages) {
>>  			ret = -ENOMEM;
>> -			goto err1;
>> +			goto err2;
>>  		}
>>  
>>  		for_each_sg(table->sgl, sg, table->nents, i) {
>> @@ -262,7 +262,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>>  err:
>>  	heap->ops->unmap_dma(heap, buffer);
>>  	heap->ops->free(buffer);
>> -err1:
>>  	vfree(buffer->pages);
>>  err2:
> 
> Now we have "err" and "err2", which doesn't make much sense,
> please fix up.

How do you want this source code to be improved?
Should I introduce longer names for the affected jump labels?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error det
@ 2014-11-27 14:25                                         ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-27 14:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, LKML, kernel-janitors, Julia Lawall

>> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
>> index df12cc3..7a26b85 100644
>> --- a/drivers/staging/android/ion/ion.c
>> +++ b/drivers/staging/android/ion/ion.c
>> @@ -226,7 +226,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>>  		buffer->pages = vmalloc(sizeof(struct page *) * num_pages);
>>  		if (!buffer->pages) {
>>  			ret = -ENOMEM;
>> -			goto err1;
>> +			goto err2;
>>  		}
>>  
>>  		for_each_sg(table->sgl, sg, table->nents, i) {
>> @@ -262,7 +262,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>>  err:
>>  	heap->ops->unmap_dma(heap, buffer);
>>  	heap->ops->free(buffer);
>> -err1:
>>  	vfree(buffer->pages);
>>  err2:
> 
> Now we have "err" and "err2", which doesn't make much sense,
> please fix up.

How do you want this source code to be improved?
Should I introduce longer names for the affected jump labels?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error det
  2014-11-23 18:44                                     ` [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detecti SF Markus Elfring
  (?)
  (?)
@ 2014-11-27 15:23                                     ` walter harms
  -1 siblings, 0 replies; 3633+ messages in thread
From: walter harms @ 2014-11-27 15:23 UTC (permalink / raw)
  To: kernel-janitors



Am 27.11.2014 15:25, schrieb SF Markus Elfring:
>>> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
>>> index df12cc3..7a26b85 100644
>>> --- a/drivers/staging/android/ion/ion.c
>>> +++ b/drivers/staging/android/ion/ion.c
>>> @@ -226,7 +226,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>>>  		buffer->pages = vmalloc(sizeof(struct page *) * num_pages);
>>>  		if (!buffer->pages) {
>>>  			ret = -ENOMEM;
>>> -			goto err1;
>>> +			goto err2;
>>>  		}
>>>  
>>>  		for_each_sg(table->sgl, sg, table->nents, i) {
>>> @@ -262,7 +262,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
>>>  err:
>>>  	heap->ops->unmap_dma(heap, buffer);
>>>  	heap->ops->free(buffer);
>>> -err1:
>>>  	vfree(buffer->pages);
>>>  err2:
>>
>> Now we have "err" and "err2", which doesn't make much sense,
>> please fix up.
> 
> How do you want this source code to be improved?
> Should I introduce longer names for the affected jump labels?
> 

hi markus,
the confusion arises because the errX are numbered and now on in the sequence is missing.

So far i see you can renumber them or give more descriptiv names.

hope that helps,
re,
 wh

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
  2014-11-24 22:12                                       ` SF Markus Elfring
@ 2014-11-27 18:13                                         ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-27 18:13 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Anisse Astier, Corentin Chary, Darren Hart, Ike Panhc,
	Jonathan Woithe, Mattia Dongili, platform-driver-x86,
	acpi4asus-user, LKML, kernel-janitors, Julia Lawall



On Mon, 24 Nov 2014, SF Markus Elfring wrote:

> >> This issue was detected by using the Coccinelle software.
> >
> > What script was used ?
>
> A semantic patch approach which I published on the mailing lists in March
> is in action on my software development system for a while.
>
>
> > Is it in scripts/coccinelle ?
>
> Not yet.
>
> I hope that the involved update suggestions got sufficient positive feedback
> to integrate five scripts there.

The current scripts are very complicated, involving the interaction
between multiple scripts and a database, and I think they are not very
suitable for make coccicheck.  Also, the idea of removing the null checks
is not appropriate in all contexts.  Perhaps it could be possible to add
a script to the Linux kernel that handles a number of common cases for
which removing the null test is widely considered to be desirable.

julia

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister()
@ 2014-11-27 18:13                                         ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-27 18:13 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Anisse Astier, Corentin Chary, Darren Hart, Ike Panhc,
	Jonathan Woithe, Mattia Dongili, platform-driver-x86,
	acpi4asus-user, LKML, kernel-janitors, Julia Lawall



On Mon, 24 Nov 2014, SF Markus Elfring wrote:

> >> This issue was detected by using the Coccinelle software.
> >
> > What script was used ?
>
> A semantic patch approach which I published on the mailing lists in March
> is in action on my software development system for a while.
>
>
> > Is it in scripts/coccinelle ?
>
> Not yet.
>
> I hope that the involved update suggestions got sufficient positive feedback
> to integrate five scripts there.

The current scripts are very complicated, involving the interaction
between multiple scripts and a database, and I think they are not very
suitable for make coccicheck.  Also, the idea of removing the null checks
is not appropriate in all contexts.  Perhaps it could be possible to add
a script to the Linux kernel that handles a number of common cases for
which removing the null test is widely considered to be desirable.

julia

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [Cocci] Remove unnecessary null pointer checks?
  2014-02-23 15:37     ` Julia Lawall
  2014-02-23 16:33       ` SF Markus Elfring
  2014-02-23 22:14       ` SF Markus Elfring
@ 2014-11-28 16:00       ` SF Markus Elfring
  2 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-28 16:00 UTC (permalink / raw)
  To: cocci

> Something goes wrong with the switch pattern.  I would have to look
> into why.

Do you know about any progress on the involved implementation details?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
  2014-11-15 20:18                                     ` Julia Lawall
  (?)
@ 2014-11-29  6:44                                       ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29  6:44 UTC (permalink / raw)
  To: Julia Lawall, OGAWA Hirofumi
  Cc: linux-kernel, kernel-janitors, trivial, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 07:37:34 +0100

The iput() function was called in an inefficient way by the implementation
of the fat_fill_super() function in case of an allocation failure.
The corresponding source code was improved by deletion of two unnecessary
null pointer checks and a few adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/fat/inode.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 756aead..a39afe8 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1716,20 +1716,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 
 	fsinfo_inode = new_inode(sb);
 	if (!fsinfo_inode)
-		goto out_fail;
+		goto fsinfo_inode_failure;
 	fsinfo_inode->i_ino = MSDOS_FSINFO_INO;
 	sbi->fsinfo_inode = fsinfo_inode;
 	insert_inode_hash(fsinfo_inode);
 
 	root_inode = new_inode(sb);
 	if (!root_inode)
-		goto out_fail;
+		goto failure_exit;
 	root_inode->i_ino = MSDOS_ROOT_INO;
 	root_inode->i_version = 1;
 	error = fat_read_root(root_inode);
 	if (error < 0) {
 		iput(root_inode);
-		goto out_fail;
+		goto failure_exit;
 	}
 	error = -ENOMEM;
 	insert_inode_hash(root_inode);
@@ -1737,7 +1737,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 	sb->s_root = d_make_root(root_inode);
 	if (!sb->s_root) {
 		fat_msg(sb, KERN_ERR, "get root inode failed");
-		goto out_fail;
+		goto failure_exit;
 	}
 
 	if (sbi->options.discard) {
@@ -1756,11 +1756,13 @@ out_invalid:
 	if (!silent)
 		fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
 
+failure_exit:
+	iput(fsinfo_inode);
+
+fsinfo_inode_failure:
+	iput(fat_inode);
+
 out_fail:
-	if (fsinfo_inode)
-		iput(fsinfo_inode);
-	if (fat_inode)
-		iput(fat_inode);
 	unload_nls(sbi->nls_io);
 	unload_nls(sbi->nls_disk);
 	if (sbi->options.iocharset != fat_default_iocharset)
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-29  6:44                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29  6:44 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 07:37:34 +0100

The iput() function was called in an inefficient way by the implementation
of the fat_fill_super() function in case of an allocation failure.
The corresponding source code was improved by deletion of two unnecessary
null pointer checks and a few adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/fat/inode.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 756aead..a39afe8 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1716,20 +1716,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 
 	fsinfo_inode = new_inode(sb);
 	if (!fsinfo_inode)
-		goto out_fail;
+		goto fsinfo_inode_failure;
 	fsinfo_inode->i_ino = MSDOS_FSINFO_INO;
 	sbi->fsinfo_inode = fsinfo_inode;
 	insert_inode_hash(fsinfo_inode);
 
 	root_inode = new_inode(sb);
 	if (!root_inode)
-		goto out_fail;
+		goto failure_exit;
 	root_inode->i_ino = MSDOS_ROOT_INO;
 	root_inode->i_version = 1;
 	error = fat_read_root(root_inode);
 	if (error < 0) {
 		iput(root_inode);
-		goto out_fail;
+		goto failure_exit;
 	}
 	error = -ENOMEM;
 	insert_inode_hash(root_inode);
@@ -1737,7 +1737,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 	sb->s_root = d_make_root(root_inode);
 	if (!sb->s_root) {
 		fat_msg(sb, KERN_ERR, "get root inode failed");
-		goto out_fail;
+		goto failure_exit;
 	}
 
 	if (sbi->options.discard) {
@@ -1756,11 +1756,13 @@ out_invalid:
 	if (!silent)
 		fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
 
+failure_exit:
+	iput(fsinfo_inode);
+
+fsinfo_inode_failure:
+	iput(fat_inode);
+
 out_fail:
-	if (fsinfo_inode)
-		iput(fsinfo_inode);
-	if (fat_inode)
-		iput(fat_inode);
 	unload_nls(sbi->nls_io);
 	unload_nls(sbi->nls_disk);
 	if (sbi->options.iocharset != fat_default_iocharset)
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [Cocci] [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-29  6:44                                       ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29  6:44 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 07:37:34 +0100

The iput() function was called in an inefficient way by the implementation
of the fat_fill_super() function in case of an allocation failure.
The corresponding source code was improved by deletion of two unnecessary
null pointer checks and a few adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/fat/inode.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 756aead..a39afe8 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1716,20 +1716,20 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 
 	fsinfo_inode = new_inode(sb);
 	if (!fsinfo_inode)
-		goto out_fail;
+		goto fsinfo_inode_failure;
 	fsinfo_inode->i_ino = MSDOS_FSINFO_INO;
 	sbi->fsinfo_inode = fsinfo_inode;
 	insert_inode_hash(fsinfo_inode);
 
 	root_inode = new_inode(sb);
 	if (!root_inode)
-		goto out_fail;
+		goto failure_exit;
 	root_inode->i_ino = MSDOS_ROOT_INO;
 	root_inode->i_version = 1;
 	error = fat_read_root(root_inode);
 	if (error < 0) {
 		iput(root_inode);
-		goto out_fail;
+		goto failure_exit;
 	}
 	error = -ENOMEM;
 	insert_inode_hash(root_inode);
@@ -1737,7 +1737,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 	sb->s_root = d_make_root(root_inode);
 	if (!sb->s_root) {
 		fat_msg(sb, KERN_ERR, "get root inode failed");
-		goto out_fail;
+		goto failure_exit;
 	}
 
 	if (sbi->options.discard) {
@@ -1756,11 +1756,13 @@ out_invalid:
 	if (!silent)
 		fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
 
+failure_exit:
+	iput(fsinfo_inode);
+
+fsinfo_inode_failure:
+	iput(fat_inode);
+
 out_fail:
-	if (fsinfo_inode)
-		iput(fsinfo_inode);
-	if (fat_inode)
-		iput(fat_inode);
 	unload_nls(sbi->nls_io);
 	unload_nls(sbi->nls_disk);
 	if (sbi->options.iocharset != fat_default_iocharset)
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
  2014-11-29  6:44                                       ` SF Markus Elfring
@ 2014-11-29 10:44                                         ` OGAWA Hirofumi
  -1 siblings, 0 replies; 3633+ messages in thread
From: OGAWA Hirofumi @ 2014-11-29 10:44 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, linux-kernel, kernel-janitors, trivial, Coccinelle

SF Markus Elfring <elfring@users.sourceforge.net> writes:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 29 Nov 2014 07:37:34 +0100
>
> The iput() function was called in an inefficient way by the implementation
> of the fat_fill_super() function in case of an allocation failure.
> The corresponding source code was improved by deletion of two unnecessary
> null pointer checks and a few adjustments for jump labels.

iput() checks NULL of inode. What is wrong just remove NULL check,
instead of adding new jump labels?

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-29 10:44                                         ` OGAWA Hirofumi
  0 siblings, 0 replies; 3633+ messages in thread
From: OGAWA Hirofumi @ 2014-11-29 10:44 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, linux-kernel, kernel-janitors, trivial, Coccinelle

SF Markus Elfring <elfring@users.sourceforge.net> writes:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 29 Nov 2014 07:37:34 +0100
>
> The iput() function was called in an inefficient way by the implementation
> of the fat_fill_super() function in case of an allocation failure.
> The corresponding source code was improved by deletion of two unnecessary
> null pointer checks and a few adjustments for jump labels.

iput() checks NULL of inode. What is wrong just remove NULL check,
instead of adding new jump labels?

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
  2014-11-29 10:44                                         ` OGAWA Hirofumi
  (?)
@ 2014-11-29 12:40                                           ` Julia Lawall
  -1 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-29 12:40 UTC (permalink / raw)
  To: OGAWA Hirofumi
  Cc: SF Markus Elfring, Julia Lawall, linux-kernel, kernel-janitors,
	trivial, Coccinelle

On Sat, 29 Nov 2014, OGAWA Hirofumi wrote:

> SF Markus Elfring <elfring@users.sourceforge.net> writes:
>
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sat, 29 Nov 2014 07:37:34 +0100
> >
> > The iput() function was called in an inefficient way by the implementation
> > of the fat_fill_super() function in case of an allocation failure.
> > The corresponding source code was improved by deletion of two unnecessary
> > null pointer checks and a few adjustments for jump labels.
>
> iput() checks NULL of inode. What is wrong just remove NULL check,
> instead of adding new jump labels?

Personally, I prefer that code that can be statically determined not to
need to be executed not to be executed.  It can make the code easier to
understand, because each function is only called when doing so is useful,
and it can be helpful to static analysis.

julia

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-29 12:40                                           ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-29 12:40 UTC (permalink / raw)
  To: cocci

On Sat, 29 Nov 2014, OGAWA Hirofumi wrote:

> SF Markus Elfring <elfring@users.sourceforge.net> writes:
>
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sat, 29 Nov 2014 07:37:34 +0100
> >
> > The iput() function was called in an inefficient way by the implementation
> > of the fat_fill_super() function in case of an allocation failure.
> > The corresponding source code was improved by deletion of two unnecessary
> > null pointer checks and a few adjustments for jump labels.
>
> iput() checks NULL of inode. What is wrong just remove NULL check,
> instead of adding new jump labels?

Personally, I prefer that code that can be statically determined not to
need to be executed not to be executed.  It can make the code easier to
understand, because each function is only called when doing so is useful,
and it can be helpful to static analysis.

julia

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [Cocci] [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-29 12:40                                           ` Julia Lawall
  0 siblings, 0 replies; 3633+ messages in thread
From: Julia Lawall @ 2014-11-29 12:40 UTC (permalink / raw)
  To: cocci

On Sat, 29 Nov 2014, OGAWA Hirofumi wrote:

> SF Markus Elfring <elfring@users.sourceforge.net> writes:
>
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sat, 29 Nov 2014 07:37:34 +0100
> >
> > The iput() function was called in an inefficient way by the implementation
> > of the fat_fill_super() function in case of an allocation failure.
> > The corresponding source code was improved by deletion of two unnecessary
> > null pointer checks and a few adjustments for jump labels.
>
> iput() checks NULL of inode. What is wrong just remove NULL check,
> instead of adding new jump labels?

Personally, I prefer that code that can be statically determined not to
need to be executed not to be executed.  It can make the code easier to
understand, because each function is only called when doing so is useful,
and it can be helpful to static analysis.

julia

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-29 13:42                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 13:42 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-29 13:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 13:42 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-29 13:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 13:42 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [Cocci] [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-29 13:42                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 13:42 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
  2014-11-29 12:40                                           ` Julia Lawall
@ 2014-11-29 13:59                                             ` OGAWA Hirofumi
  -1 siblings, 0 replies; 3633+ messages in thread
From: OGAWA Hirofumi @ 2014-11-29 13:59 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, linux-kernel, kernel-janitors, trivial, Coccinelle

Julia Lawall <julia.lawall@lip6.fr> writes:

>> iput() checks NULL of inode. What is wrong just remove NULL check,
>> instead of adding new jump labels?
>
> Personally, I prefer that code that can be statically determined not to
> need to be executed not to be executed.  It can make the code easier to
> understand, because each function is only called when doing so is useful,
> and it can be helpful to static analysis.

Hm, first of all, we want to prevent the bugs. More labels are more
chances of bug (and we don't care micro optimize on this error path),
isn't it?  Increasing the chance of bugs and bothers developers for
analyzer sounds like strange.

(And we are initializing those for avoiding to be bothered by choosing
correct label. If we really care micro optimize, initialization of those
should not be required and should not be touched on other paths, and gcc
can warn its usage.)

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: [PATCH v2] fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-29 13:59                                             ` OGAWA Hirofumi
  0 siblings, 0 replies; 3633+ messages in thread
From: OGAWA Hirofumi @ 2014-11-29 13:59 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, linux-kernel, kernel-janitors, trivial, Coccinelle

Julia Lawall <julia.lawall@lip6.fr> writes:

>> iput() checks NULL of inode. What is wrong just remove NULL check,
>> instead of adding new jump labels?
>
> Personally, I prefer that code that can be statically determined not to
> need to be executed not to be executed.  It can make the code easier to
> understand, because each function is only called when doing so is useful,
> and it can be helpful to static analysis.

Hm, first of all, we want to prevent the bugs. More labels are more
chances of bug (and we don't care micro optimize on this error path),
isn't it?  Increasing the chance of bugs and bothers developers for
analyzer sounds like strange.

(And we are initializing those for avoiding to be bothered by choosing
correct label. If we really care micro optimize, initialization of those
should not be required and should not be touched on other paths, and gcc
can warn its usage.)

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] net: cassini: Deletion of an unnecessary check before the function call "vfree"
  2014-11-29 13:42                                   ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-29 14:05                                     ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:05 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] net: cassini: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-29 14:05                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:05 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] net: cassini: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-29 14:05                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:05 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [Cocci] [PATCH 1/1] net: cassini: Deletion of an unnecessary check before the function call "vfree"
@ 2014-11-29 14:05                                     ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:05 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device"
  2014-03-05 22:30                                 ` SF Markus Elfring
  (?)
  (?)
@ 2014-11-29 14:33                                   ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:33 UTC (permalink / raw)
  To: Jiri Kosina, linux-input; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 15:16:01 +0100

The input_free_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/wacom_sys.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index eb55316..21ced00 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1099,10 +1099,8 @@ static void wacom_free_inputs(struct wacom *wacom)
 {
 	struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
 
-	if (wacom_wac->input)
-		input_free_device(wacom_wac->input);
-	if (wacom_wac->pad_input)
-		input_free_device(wacom_wac->pad_input);
+	input_free_device(wacom_wac->input);
+	input_free_device(wacom_wac->pad_input);
 	wacom_wac->input = NULL;
 	wacom_wac->pad_input = NULL;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device"
@ 2014-11-29 14:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:33 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 15:16:01 +0100

The input_free_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/wacom_sys.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index eb55316..21ced00 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1099,10 +1099,8 @@ static void wacom_free_inputs(struct wacom *wacom)
 {
 	struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
 
-	if (wacom_wac->input)
-		input_free_device(wacom_wac->input);
-	if (wacom_wac->pad_input)
-		input_free_device(wacom_wac->pad_input);
+	input_free_device(wacom_wac->input);
+	input_free_device(wacom_wac->pad_input);
 	wacom_wac->input = NULL;
 	wacom_wac->pad_input = NULL;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device"
@ 2014-11-29 14:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:33 UTC (permalink / raw)
  To: Jiri Kosina, linux-input; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 15:16:01 +0100

The input_free_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/wacom_sys.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index eb55316..21ced00 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1099,10 +1099,8 @@ static void wacom_free_inputs(struct wacom *wacom)
 {
 	struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
 
-	if (wacom_wac->input)
-		input_free_device(wacom_wac->input);
-	if (wacom_wac->pad_input)
-		input_free_device(wacom_wac->pad_input);
+	input_free_device(wacom_wac->input);
+	input_free_device(wacom_wac->pad_input);
 	wacom_wac->input = NULL;
 	wacom_wac->pad_input = NULL;
 }
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* [Cocci] [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device"
@ 2014-11-29 14:33                                   ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:33 UTC (permalink / raw)
  To: cocci

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 15:16:01 +0100

The input_free_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/wacom_sys.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index eb55316..21ced00 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1099,10 +1099,8 @@ static void wacom_free_inputs(struct wacom *wacom)
 {
 	struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
 
-	if (wacom_wac->input)
-		input_free_device(wacom_wac->input);
-	if (wacom_wac->pad_input)
-		input_free_device(wacom_wac->pad_input);
+	input_free_device(wacom_wac->input);
+	input_free_device(wacom_wac->pad_input);
 	wacom_wac->input = NULL;
 	wacom_wac->pad_input = NULL;
 }
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3633+ messages in thread

* Re: fs-fat: Less function calls in fat_fill_super() after error detection
  2014-11-29 13:59                                             ` OGAWA Hirofumi
@ 2014-11-29 14:50                                               ` SF Markus Elfring
  -1 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:50 UTC (permalink / raw)
  To: OGAWA Hirofumi
  Cc: Julia Lawall, linux-kernel, kernel-janitors, trivial, Coccinelle

> More labels are more chances of bug (and we don't care micro optimize
> on this error path), isn't it?

I would prefer that a few jump targets can be redirected so that unnecessary
function calls (and corresponding checks) can be avoided.


> Increasing the chance of bugs and bothers developers for analyzer sounds
> like strange.

There are different opinions around source code clarity.


> (And we are initializing those for avoiding to be bothered by choosing
> correct label.

Pointer initialisation is convenient and safe in some use cases, isn't it?


> If we really care micro optimize, initialization of those should not
> be required and should not be touched on other paths, and gcc can warn
> its usage.)

I imagine that a software optimiser can eventually perform better job
if unneeded statements could be omitted, couldn't it?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

* Re: fs-fat: Less function calls in fat_fill_super() after error detection
@ 2014-11-29 14:50                                               ` SF Markus Elfring
  0 siblings, 0 replies; 3633+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:50 UTC (permalink / raw)
  To: cocci

> More labels are more chances of bug (and we don't care micro optimize
> on this error path), isn't it?

I would prefer that a few jump targets can be redirected so that unnecessary
function calls (and corresponding checks) can be avoided.


> Increasing the chance of bugs and bothers developers for analyzer sounds
> like strange.

There are different opinions around source code clarity.


> (And we are initializing those for avoiding to be bothered by choosing
> correct label.

Pointer initialisation is convenient and safe in some use cases, isn't it?


> If we really care micro optimize, initialization of those should not
> be required and should not be touched on other paths, and gcc can warn
> its usage.)

I imagine that a software optimiser can eventually perform better job
if unneeded statements could be omitted, couldn't it?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3633+ messages in thread

end of thread, other threads:[~2014-11-29 14:51 UTC | newest]

Thread overview: 3633+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-21 21:52 [Cocci] Remove unnecessary null pointer checks? SF Markus Elfring
2014-02-21 22:27 ` Julia Lawall
2014-02-22  8:09   ` SF Markus Elfring
2014-02-22 12:36     ` Julia Lawall
2014-02-22 18:01       ` SF Markus Elfring
2014-10-26  6:07         ` SF Markus Elfring
     [not found]           ` <alpine.DEB.2.10.1410260614460.2563@hadrien>
2014-10-26 13:54             ` SF Markus Elfring
2014-02-23 14:40   ` SF Markus Elfring
2014-02-23 15:37     ` Julia Lawall
2014-02-23 16:33       ` SF Markus Elfring
2014-02-23 16:42         ` Julia Lawall
2014-02-23 22:14       ` SF Markus Elfring
2014-02-24  6:00         ` Julia Lawall
2014-02-24 10:55           ` SF Markus Elfring
2014-02-24 11:22             ` Julia Lawall
2014-02-24 15:05           ` SF Markus Elfring
2014-02-24 15:19             ` Julia Lawall
2014-02-24 15:58               ` SF Markus Elfring
2014-02-24 16:14             ` Julia Lawall
2014-02-24 16:34               ` SF Markus Elfring
2014-02-25  9:10               ` SF Markus Elfring
2014-02-25  9:16                 ` Julia Lawall
2014-02-25 10:01                   ` SF Markus Elfring
2014-02-25 17:28                   ` SF Markus Elfring
2014-02-25 17:42                     ` Julia Lawall
2014-02-25 20:11                       ` SF Markus Elfring
2014-02-25 20:20                         ` Julia Lawall
2014-02-25 20:37                           ` [Cocci] Source code analysis with big regular expressions? SF Markus Elfring
2014-02-25 20:44                             ` Julia Lawall
2014-02-25 20:54                               ` SF Markus Elfring
2014-02-25 21:02                                 ` Julia Lawall
2014-02-25 21:19                                   ` SF Markus Elfring
2014-02-25 21:29                                     ` Julia Lawall
2014-02-25 21:44                           ` [Cocci] Remove unnecessary null pointer checks? SF Markus Elfring
2014-02-25 21:48                             ` Julia Lawall
2014-02-26  8:04                           ` SF Markus Elfring
2014-02-26 11:30                           ` SF Markus Elfring
2014-02-26 20:35                             ` Julia Lawall
2014-02-26 21:01                               ` SF Markus Elfring
2014-02-26 21:09                                 ` Julia Lawall
2014-03-06  8:39                                   ` SF Markus Elfring
2014-03-06 16:24                                     ` Julia Lawall
2014-03-06 17:04                                       ` SF Markus Elfring
2014-09-30 13:24                                       ` [Cocci] Fix for "lexing: empty token" needed? SF Markus Elfring
2014-03-05 22:30                               ` [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls SF Markus Elfring
2014-03-05 22:30                                 ` [Cocci] " SF Markus Elfring
2014-03-05 22:30                                 ` SF Markus Elfring
2014-03-05 22:48                                 ` [coccicheck Linux 3.14-rc5 PATCH 1 of 5] " SF Markus Elfring
2014-03-05 22:48                                   ` [Cocci] " SF Markus Elfring
2014-03-05 22:48                                   ` [coccicheck Linux 3.14-rc5 PATCH 1 of 5] Deletion of unnecessary checks before specific function SF Markus Elfring
2014-03-05 22:50                                 ` [coccicheck Linux 3.14-rc5 PATCH 2 of 5] Deletion of unnecessary checks before specific function calls SF Markus Elfring
2014-03-05 22:50                                   ` [Cocci] " SF Markus Elfring
2014-03-05 22:50                                   ` [coccicheck Linux 3.14-rc5 PATCH 2 of 5] Deletion of unnecessary checks before specific function SF Markus Elfring
2014-03-05 22:52                                 ` [coccicheck Linux 3.14-rc5 PATCH 3 of 5] Deletion of unnecessary checks before specific function calls SF Markus Elfring
2014-03-05 22:52                                   ` [Cocci] " SF Markus Elfring
2014-03-05 22:52                                   ` [coccicheck Linux 3.14-rc5 PATCH 3 of 5] Deletion of unnecessary checks before specific function SF Markus Elfring
2014-03-05 22:55                                 ` [coccicheck Linux 3.14-rc5 PATCH 4 of 5] Deletion of unnecessary checks before specific function calls SF Markus Elfring
2014-03-05 22:55                                   ` [Cocci] " SF Markus Elfring
2014-03-05 22:55                                   ` [coccicheck Linux 3.14-rc5 PATCH 4 of 5] Deletion of unnecessary checks before specific function SF Markus Elfring
2014-03-05 22:58                                 ` [coccicheck Linux 3.14-rc5 PATCH 5 of 5] Deletion of unnecessary checks before specific function calls SF Markus Elfring
2014-03-05 22:58                                   ` [Cocci] " SF Markus Elfring
2014-03-05 22:58                                   ` [coccicheck Linux 3.14-rc5 PATCH 5 of 5] Deletion of unnecessary checks before specific function SF Markus Elfring
2014-10-01 13:01                                 ` [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls SF Markus Elfring
2014-10-01 13:01                                   ` [Cocci] " SF Markus Elfring
2014-10-01 13:01                                   ` SF Markus Elfring
2014-10-01 14:06                                   ` [coccicheck PATCH 1/5] " SF Markus Elfring
2014-10-01 14:06                                     ` [Cocci] " SF Markus Elfring
2014-10-01 14:06                                     ` SF Markus Elfring
2014-10-01 14:06                                   ` [coccicheck PATCH 2/5] " SF Markus Elfring
2014-10-01 14:06                                     ` [Cocci] " SF Markus Elfring
2014-10-01 14:06                                     ` SF Markus Elfring
2014-10-01 14:06                                   ` [coccicheck PATCH 3/5] " SF Markus Elfring
2014-10-01 14:06                                     ` [Cocci] " SF Markus Elfring
2014-10-01 14:06                                     ` SF Markus Elfring
2014-10-01 14:07                                   ` [coccicheck PATCH 4/5] " SF Markus Elfring
2014-10-01 14:07                                     ` [Cocci] " SF Markus Elfring
2014-10-01 14:07                                     ` SF Markus Elfring
2014-10-01 14:07                                   ` [coccicheck PATCH 5/5] " SF Markus Elfring
2014-10-01 14:07                                     ` [Cocci] " SF Markus Elfring
2014-10-01 14:07                                     ` SF Markus Elfring
2014-10-22 14:30                                 ` [PATCH 1/1] GPU-DRM-nouveau: Deletion of unnecessary checks before two " SF Markus Elfring
2014-10-22 14:30                                   ` SF Markus Elfring
2014-10-22 14:30                                   ` [Cocci] " SF Markus Elfring
2014-10-22 14:30                                   ` SF Markus Elfring
2014-10-22 16:48                                 ` [PATCH 1/1] GPU-DRM-GMA500: " SF Markus Elfring
2014-10-22 16:48                                   ` SF Markus Elfring
2014-10-22 16:48                                   ` [Cocci] " SF Markus Elfring
2014-10-22 16:48                                   ` SF Markus Elfring
2014-10-23 11:26                                   ` One Thousand Gnomes
2014-10-23 11:26                                     ` [Cocci] " One Thousand Gnomes
2014-10-23 11:26                                     ` One Thousand Gnomes
2014-10-26 12:10                                     ` SF Markus Elfring
2014-10-26 12:10                                       ` SF Markus Elfring
2014-10-26 12:10                                       ` [Cocci] " SF Markus Elfring
2014-10-26 12:10                                       ` SF Markus Elfring
2014-10-26 14:56                                       ` [Cocci] " Arthur Borsboom
2014-10-26 14:56                                         ` Arthur Borsboom
2014-10-22 18:00                                 ` [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call "clk_disable" SF Markus Elfring
2014-10-22 18:00                                   ` [Cocci] " SF Markus Elfring
2014-10-22 18:00                                   ` SF Markus Elfring
2014-10-22 18:00                                   ` SF Markus Elfring
2014-10-23 12:51                                   ` Jörg Rödel
2014-10-23 12:51                                     ` [Cocci] " Jörg Rödel
2014-10-23 12:51                                     ` Jörg Rödel
2014-10-23 12:51                                     ` Jörg Rödel
2014-10-22 18:55                                 ` [PATCH 1/1] SCSI-QLA2XXX: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
2014-10-22 18:55                                   ` [Cocci] " SF Markus Elfring
2014-10-22 19:10                                 ` [PATCH 1/1] SCSI-QLA2...: " SF Markus Elfring
2014-10-22 19:10                                   ` [Cocci] " SF Markus Elfring
2014-10-22 19:10                                   ` SF Markus Elfring
2014-10-22 19:10                                   ` SF Markus Elfring
2014-10-23 19:20                                 ` [PATCH 1/1] staging - rtl8188eu: Deletion of unnecessary checks before three function calls SF Markus Elfring
2014-10-23 19:20                                   ` [Cocci] " SF Markus Elfring
2014-10-23 19:20                                   ` SF Markus Elfring
2014-10-29  8:47                                   ` Greg Kroah-Hartman
2014-10-29  8:47                                     ` [Cocci] " Greg Kroah-Hartman
2014-10-29  8:47                                     ` Greg Kroah-Hartman
2014-10-31 17:55                                     ` [PATCH resent] staging: " SF Markus Elfring
2014-10-31 17:55                                       ` [Cocci] " SF Markus Elfring
2014-10-31 17:55                                       ` SF Markus Elfring
2014-10-31 18:01                                       ` Julia Lawall
2014-10-31 18:01                                         ` [Cocci] " Julia Lawall
2014-10-31 18:01                                         ` Julia Lawall
2014-10-31 18:08                                         ` SF Markus Elfring
2014-10-31 18:08                                           ` [Cocci] " SF Markus Elfring
2014-10-31 18:08                                           ` SF Markus Elfring
2014-10-31 18:11                                           ` Julia Lawall
2014-10-31 18:11                                             ` [Cocci] " Julia Lawall
2014-10-31 18:11                                             ` Julia Lawall
2014-11-12 10:51                                             ` [PATCH with SmPL?] staging: rtl8188eu: Adjustments around jump labels SF Markus Elfring
2014-11-12 10:51                                               ` [Cocci] " SF Markus Elfring
2014-11-12 10:51                                               ` SF Markus Elfring
2014-11-12 20:20                                         ` [PATCH v2 0/2] staging: rtl8188eu: Deletion of a few unnecessary checks SF Markus Elfring
2014-11-12 20:20                                           ` [Cocci] " SF Markus Elfring
2014-11-12 20:20                                           ` SF Markus Elfring
2014-11-12 20:25                                           ` [PATCH v2 1/2] staging: rtl8188eu: Deletion of unnecessary checks before three function calls SF Markus Elfring
2014-11-12 20:25                                             ` [Cocci] " SF Markus Elfring
2014-11-12 20:25                                             ` SF Markus Elfring
2014-11-12 21:18                                             ` Dan Carpenter
2014-11-12 21:18                                               ` [Cocci] " Dan Carpenter
2014-11-12 21:18                                               ` Dan Carpenter
2014-11-12 21:28                                               ` SF Markus Elfring
2014-11-12 21:28                                                 ` [Cocci] " SF Markus Elfring
2014-11-12 21:28                                                 ` SF Markus Elfring
2014-11-12 21:40                                                 ` Julia Lawall
2014-11-12 21:40                                                   ` [Cocci] " Julia Lawall
2014-11-12 21:40                                                   ` Julia Lawall
2014-11-12 22:08                                                 ` Dan Carpenter
2014-11-12 22:08                                                   ` [Cocci] " Dan Carpenter
2014-11-12 22:08                                                   ` Dan Carpenter
2014-11-13  8:47                                             ` Julia Lawall
2014-11-13  8:47                                               ` [Cocci] " Julia Lawall
2014-11-13  8:47                                               ` Julia Lawall
2014-11-12 20:30                                           ` [PATCH v2 2/2] staging: rtl8188eu: Better memory clean-up in efuse_phymap_to_logical() SF Markus Elfring
2014-11-12 20:30                                             ` [Cocci] " SF Markus Elfring
2014-11-12 20:30                                             ` SF Markus Elfring
2014-11-12 21:14                                             ` Dan Carpenter
2014-11-12 21:14                                               ` [Cocci] " Dan Carpenter
2014-11-12 21:14                                               ` Dan Carpenter
2014-11-12 21:50                                               ` SF Markus Elfring
2014-11-12 21:50                                                 ` [Cocci] " SF Markus Elfring
2014-11-12 21:50                                                 ` SF Markus Elfring
2014-11-12 22:05                                                 ` Dan Carpenter
2014-11-12 22:05                                                   ` [Cocci] " Dan Carpenter
2014-11-12 22:05                                                   ` Dan Carpenter
2014-11-13  8:50                                                   ` SF Markus Elfring
2014-11-13  8:50                                                     ` [Cocci] " SF Markus Elfring
2014-11-13  8:50                                                     ` SF Markus Elfring
2014-11-13  8:43                                             ` Julia Lawall
2014-11-13  8:43                                               ` [Cocci] " Julia Lawall
2014-11-13  8:43                                               ` Julia Lawall
2014-11-13  9:33                                               ` SF Markus Elfring
2014-11-13  9:33                                                 ` [Cocci] " SF Markus Elfring
2014-11-13  9:33                                                 ` SF Markus Elfring
2014-10-31 17:40                                 ` [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-10-31 17:40                                   ` [Cocci] " SF Markus Elfring
2014-10-31 17:40                                   ` SF Markus Elfring
2014-11-03  9:50                                   ` Dan Carpenter
2014-11-03  9:50                                     ` [Cocci] " Dan Carpenter
2014-11-03  9:50                                     ` Dan Carpenter
2014-11-03 15:55                                     ` SF Markus Elfring
2014-11-03 15:55                                       ` [Cocci] " SF Markus Elfring
2014-11-03 15:55                                       ` SF Markus Elfring
2014-11-03 16:25                                       ` Dan Carpenter
2014-11-03 16:25                                         ` [Cocci] " Dan Carpenter
2014-11-03 16:25                                         ` Dan Carpenter
2014-11-03 16:50                                         ` SF Markus Elfring
2014-11-03 16:50                                           ` [Cocci] " SF Markus Elfring
2014-11-03 16:50                                           ` SF Markus Elfring
2014-11-03 17:02                                           ` Julia Lawall
2014-11-03 17:02                                             ` [Cocci] " Julia Lawall
2014-11-03 17:02                                             ` Julia Lawall
2014-11-03 17:16                                           ` Dan Carpenter
2014-11-03 17:16                                             ` [Cocci] " Dan Carpenter
2014-11-03 17:16                                             ` Dan Carpenter
2014-11-03 17:40                                             ` SF Markus Elfring
2014-11-03 17:40                                               ` [Cocci] " SF Markus Elfring
2014-11-03 17:40                                               ` SF Markus Elfring
2014-11-03 17:05                                         ` [Cocci] " Derek M Jones
2014-11-03 17:32                                           ` Julia Lawall
2014-11-03 21:30                                           ` [Cocci] Are defensive checks treated differently in specific areas? SF Markus Elfring
2014-11-03 11:04                                   ` [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls Ursula Braun
2014-11-03 11:04                                     ` [Cocci] " Ursula Braun
2014-11-03 11:04                                     ` Ursula Braun
2014-11-03 16:10                                     ` SF Markus Elfring
2014-11-03 16:10                                       ` [Cocci] " SF Markus Elfring
2014-11-03 16:10                                       ` SF Markus Elfring
2014-11-03 16:28                                       ` Dan Carpenter
2014-11-03 16:28                                         ` [Cocci] " Dan Carpenter
2014-11-03 16:28                                         ` Dan Carpenter
2014-10-31 21:52                                 ` [PATCH 1/1] btrfs: Deletion of unnecessary checks before six " SF Markus Elfring
2014-10-31 21:52                                   ` [Cocci] " SF Markus Elfring
2014-10-31 21:52                                   ` SF Markus Elfring
2014-10-31 21:59                                   ` [Cocci] " Julia Lawall
2014-10-31 21:59                                     ` Julia Lawall
2014-10-31 21:59                                     ` Julia Lawall
2014-11-02  9:40                                 ` [PATCH 1/1] ocfs2: Deletion of unnecessary checks before two " SF Markus Elfring
2014-11-02  9:40                                   ` [Cocci] " SF Markus Elfring
2014-11-02  9:40                                   ` [Ocfs2-devel] " SF Markus Elfring
2014-11-02  9:40                                   ` SF Markus Elfring
2014-11-02 10:51                                   ` Julia Lawall
2014-11-02 10:51                                     ` [Cocci] " Julia Lawall
2014-11-02 10:51                                     ` [Ocfs2-devel] " Julia Lawall
2014-11-02 10:51                                     ` Julia Lawall
2014-11-02 14:20                                 ` [PATCH 1/1] ceph: " SF Markus Elfring
2014-11-02 14:20                                   ` [Cocci] " SF Markus Elfring
2014-11-02 14:20                                   ` SF Markus Elfring
2014-11-02 14:20                                   ` SF Markus Elfring
2014-11-03 10:35                                   ` Ilya Dryomov
2014-11-03 10:35                                     ` [Cocci] " Ilya Dryomov
2014-11-03 10:35                                     ` Ilya Dryomov
2014-11-03 13:27                                     ` SF Markus Elfring
2014-11-03 13:27                                       ` [Cocci] " SF Markus Elfring
2014-11-03 13:27                                       ` SF Markus Elfring
2014-11-03 13:27                                       ` SF Markus Elfring
2014-11-03 14:23                                       ` Ilya Dryomov
2014-11-03 14:23                                         ` [Cocci] " Ilya Dryomov
2014-11-03 14:23                                         ` Ilya Dryomov
2014-11-02 15:12                                 ` [PATCH 1/1] PCI: Deletion of unnecessary checks before three " SF Markus Elfring
2014-11-02 15:12                                 ` SF Markus Elfring
2014-11-02 15:12                                   ` [Cocci] " SF Markus Elfring
2014-11-02 15:12                                   ` SF Markus Elfring
2014-11-02 15:12                                   ` SF Markus Elfring
2014-11-11  4:07                                   ` Bjorn Helgaas
2014-11-11  4:07                                   ` Bjorn Helgaas
2014-11-11  4:07                                     ` [Cocci] " Bjorn Helgaas
2014-11-11  4:07                                     ` Bjorn Helgaas
2014-11-02 18:27                                 ` [PATCH 1/1] PCI: EMU10K1: " SF Markus Elfring
2014-11-02 18:27                                   ` [Cocci] " SF Markus Elfring
2014-11-02 18:27                                   ` SF Markus Elfring
2014-11-02 18:27                                   ` SF Markus Elfring
2014-11-03  9:45                                   ` Takashi Iwai
2014-11-03  9:45                                     ` [Cocci] " Takashi Iwai
2014-11-03  9:45                                     ` Takashi Iwai
2014-11-03 14:10                                     ` [PATCH resent] ALSA: emu10k1: " SF Markus Elfring
2014-11-03 14:10                                       ` [Cocci] " SF Markus Elfring
2014-11-03 14:10                                       ` SF Markus Elfring
2014-11-03 14:10                                       ` SF Markus Elfring
2014-11-03 14:17                                       ` Takashi Iwai
2014-11-03 14:17                                         ` [Cocci] " Takashi Iwai
2014-11-03 14:17                                         ` Takashi Iwai
2014-11-02 19:42                                 ` [PATCH 1/1] kconfig: Deletion of unnecessary checks before the function call "sym_calc_value" SF Markus Elfring
2014-11-02 19:42                                   ` [Cocci] " SF Markus Elfring
2014-11-02 19:42                                   ` SF Markus Elfring
2014-11-03 10:35                                   ` Paul Bolle
2014-11-03 10:35                                     ` [Cocci] " Paul Bolle
2014-11-03 10:35                                     ` Paul Bolle
2014-11-03 18:40                                   ` [PATCH v2] " SF Markus Elfring
2014-11-03 18:40                                     ` [Cocci] " SF Markus Elfring
2014-11-03 18:40                                     ` SF Markus Elfring
2014-11-15 18:19                                 ` [PATCH 1/1] fs-ext4: Deletion of an unnecessary check before the function call "iput" SF Markus Elfring
2014-11-15 18:19                                   ` [Cocci] " SF Markus Elfring
2014-11-15 18:19                                   ` SF Markus Elfring
2014-11-15 18:19                                   ` SF Markus Elfring
2014-11-26  1:16                                   ` [1/1] " Theodore Ts'o
2014-11-26  1:16                                     ` [Cocci] " Theodore Ts'o
2014-11-26  1:16                                     ` Theodore Ts'o
2014-11-15 18:42                                 ` [PATCH 1/1] ntfs: Deletion of unnecessary checks " SF Markus Elfring
2014-11-15 18:42                                   ` [Cocci] " SF Markus Elfring
2014-11-15 18:42                                   ` SF Markus Elfring
2014-11-15 19:54                                   ` [Cocci] " Julia Lawall
2014-11-15 19:54                                     ` Julia Lawall
2014-11-15 19:54                                     ` Julia Lawall
2014-11-15 20:01                                 ` [PATCH 1/1] fs-fat: Less function calls in fat_fill_super() after error detection SF Markus Elfring
2014-11-15 20:01                                   ` [Cocci] " SF Markus Elfring
2014-11-15 20:01                                   ` SF Markus Elfring
2014-11-15 20:18                                   ` Julia Lawall
2014-11-15 20:18                                     ` [Cocci] " Julia Lawall
2014-11-15 20:18                                     ` Julia Lawall
2014-11-29  6:44                                     ` [PATCH v2] " SF Markus Elfring
2014-11-29  6:44                                       ` [Cocci] " SF Markus Elfring
2014-11-29  6:44                                       ` SF Markus Elfring
2014-11-29 10:44                                       ` OGAWA Hirofumi
2014-11-29 10:44                                         ` OGAWA Hirofumi
2014-11-29 12:40                                         ` Julia Lawall
2014-11-29 12:40                                           ` [Cocci] " Julia Lawall
2014-11-29 12:40                                           ` Julia Lawall
2014-11-29 13:59                                           ` OGAWA Hirofumi
2014-11-29 13:59                                             ` OGAWA Hirofumi
2014-11-29 14:50                                             ` SF Markus Elfring
2014-11-29 14:50                                               ` SF Markus Elfring
2014-11-15 20:44                                 ` [PATCH 1/1] lib/mpi: Deletion of unnecessary checks before the function call "mpi_free_limb_space" SF Markus Elfring
2014-11-15 20:44                                   ` [Cocci] " SF Markus Elfring
2014-11-15 20:44                                   ` SF Markus Elfring
2014-11-16 10:40                                 ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" SF Markus Elfring
2014-11-16 10:40                                   ` [Cocci] " SF Markus Elfring
2014-11-16 10:40                                   ` SF Markus Elfring
2014-11-16 11:10                                   ` Dan Carpenter
2014-11-16 11:10                                     ` [Cocci] " Dan Carpenter
2014-11-16 11:10                                     ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
2014-11-16 11:14                                     ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" Dan Carpenter
2014-11-16 11:14                                       ` [Cocci] " Dan Carpenter
2014-11-16 11:14                                       ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
2014-11-16 11:48                                       ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" SF Markus Elfring
2014-11-16 11:48                                         ` [Cocci] " SF Markus Elfring
2014-11-16 11:48                                         ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e SF Markus Elfring
2014-11-17  7:34                                         ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" Dan Carpenter
2014-11-17  7:34                                           ` [Cocci] " Dan Carpenter
2014-11-17  7:34                                           ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
2014-11-17  8:56                                           ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" SF Markus Elfring
2014-11-17  8:56                                             ` [Cocci] " SF Markus Elfring
2014-11-17  8:56                                             ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e SF Markus Elfring
2014-11-17 13:45                                             ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" Dan Carpenter
2014-11-17 13:45                                               ` [Cocci] " Dan Carpenter
2014-11-17 13:45                                               ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
2014-11-17 14:30                                               ` s390/net: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-17 14:30                                                 ` SF Markus Elfring
2014-11-23 11:51                                             ` [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" Julia Lawall
2014-11-23 11:51                                               ` Julia Lawall
2014-11-23 11:51                                               ` [Cocci] [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "aud Julia Lawall
2014-11-23 13:24                                               ` kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" SF Markus Elfring
2014-11-23 13:24                                                 ` [Cocci] " SF Markus Elfring
2014-11-23 13:24                                                 ` SF Markus Elfring
2014-11-24  9:03                                                 ` Dan Carpenter
2014-11-24  9:03                                                   ` [Cocci] " Dan Carpenter
2014-11-24  9:03                                                   ` Dan Carpenter
2014-11-16 11:24                                   ` [PATCH 1/1] " Dan Carpenter
2014-11-16 11:24                                     ` [Cocci] " Dan Carpenter
2014-11-16 11:24                                     ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e Dan Carpenter
2014-11-16 12:07                                     ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_end" (or improve error handling?) SF Markus Elfring
2014-11-16 12:07                                       ` [Cocci] " SF Markus Elfring
2014-11-16 12:07                                       ` [PATCH 1/1] kernel-audit: Deletion of an unnecessary check before the function call "audit_log_e SF Markus Elfring
2014-11-16 12:34                                 ` [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put" SF Markus Elfring
2014-11-16 12:34                                   ` [Cocci] " SF Markus Elfring
2014-11-16 12:34                                   ` SF Markus Elfring
2014-11-16 13:29                                   ` [Cocci] " Julia Lawall
2014-11-16 13:29                                     ` Julia Lawall
2014-11-16 13:29                                     ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p Julia Lawall
2014-11-16 14:26                                     ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put" SF Markus Elfring
2014-11-16 14:26                                       ` SF Markus Elfring
2014-11-16 14:26                                       ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p SF Markus Elfring
2014-11-16 15:43                                       ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put" Julia Lawall
2014-11-16 15:43                                         ` Julia Lawall
2014-11-16 15:43                                         ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p Julia Lawall
2014-11-16 16:57                                         ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put" SF Markus Elfring
2014-11-16 16:57                                           ` SF Markus Elfring
2014-11-16 16:57                                           ` [Cocci] [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_p SF Markus Elfring
2014-11-17  8:23                                   ` [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call "module_put" Masami Hiramatsu
2014-11-17  8:23                                     ` Masami Hiramatsu
2014-11-19  7:08                                     ` SF Markus Elfring
2014-11-19  7:08                                       ` [Cocci] " SF Markus Elfring
2014-11-19  7:08                                       ` SF Markus Elfring
2014-11-20  3:53                                       ` Masami Hiramatsu
2014-11-20  3:53                                         ` Masami Hiramatsu
2014-11-16 13:28                                 ` [PATCH 1/1] kernel-power: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-16 13:28                                   ` [Cocci] " SF Markus Elfring
2014-11-16 13:28                                   ` SF Markus Elfring
2014-11-16 13:28                                   ` SF Markus Elfring
2014-11-18 23:32                                   ` Rafael J. Wysocki
2014-11-18 23:32                                     ` Rafael J. Wysocki
2014-11-16 13:50                                 ` [PATCH 1/1] kernel-trace: Deletion of an unnecessary check before the function call "iput" SF Markus Elfring
2014-11-16 13:50                                   ` [Cocci] " SF Markus Elfring
2014-11-16 13:50                                   ` SF Markus Elfring
2014-11-16 15:56                                   ` Julia Lawall
2014-11-16 15:56                                     ` [Cocci] " Julia Lawall
2014-11-16 15:56                                     ` Julia Lawall
2014-11-16 19:13                                     ` [PATCH v2 0/2] kernel-trace: Fixes around the jump label "fail_address_parse" SF Markus Elfring
2014-11-16 19:13                                       ` [Cocci] " SF Markus Elfring
2014-11-16 19:13                                       ` SF Markus Elfring
2014-11-16 19:18                                       ` [PATCH v2 1/2] kernel-trace: Deletion of an unnecessary check before the function call "iput" SF Markus Elfring
2014-11-16 19:18                                         ` [Cocci] " SF Markus Elfring
2014-11-16 19:18                                         ` SF Markus Elfring
2014-11-16 19:22                                       ` [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection SF Markus Elfring
2014-11-16 19:22                                         ` [Cocci] " SF Markus Elfring
2014-11-16 19:22                                         ` SF Markus Elfring
2014-11-16 19:31                                         ` Steven Rostedt
2014-11-16 19:31                                           ` [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detectio Steven Rostedt
2014-11-16 19:34                                           ` [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection Julia Lawall
2014-11-16 19:34                                             ` [Cocci] " Julia Lawall
2014-11-16 19:34                                             ` [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detectio Julia Lawall
2014-11-16 21:49                                             ` [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detection Steven Rostedt
2014-11-16 21:49                                               ` [PATCH v2 2/2] kernel-trace: Less calls for iput() in create_trace_uprobe() after error detectio Steven Rostedt
2014-11-16 22:40                                 ` [PATCH 1/1] fs-jbd: Deletion of an unnecessary check before the function call "iput" SF Markus Elfring
2014-11-16 22:40                                   ` [Cocci] " SF Markus Elfring
2014-11-16 22:40                                   ` SF Markus Elfring
2014-11-16 22:40                                   ` SF Markus Elfring
2014-11-18  9:16                                   ` Jan Kara
2014-11-18  9:16                                     ` Jan Kara
2014-11-17 10:07                                 ` [PATCH 1/1] ALSA: hda: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-17 10:07                                   ` [Cocci] " SF Markus Elfring
2014-11-17 10:07                                   ` SF Markus Elfring
2014-11-17 10:07                                   ` SF Markus Elfring
2014-11-17 12:45                                   ` Takashi Iwai
2014-11-17 12:45                                     ` Takashi Iwai
2014-11-17 10:34                                 ` [PATCH 1/1] ALSA: ice17xx: Deletion of unnecessary checks before the function call "snd_ac97_resume" SF Markus Elfring
2014-11-17 10:34                                   ` [Cocci] " SF Markus Elfring
2014-11-17 10:34                                   ` SF Markus Elfring
2014-11-17 10:34                                   ` SF Markus Elfring
2014-11-17 12:46                                   ` Takashi Iwai
2014-11-17 12:46                                     ` [PATCH 1/1] ALSA: ice17xx: Deletion of unnecessary checks before the function call "snd_ac97_res Takashi Iwai
2014-11-17 11:48                                 ` [PATCH 1/1] ALSA: lola: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-17 11:48                                   ` [Cocci] " SF Markus Elfring
2014-11-17 11:48                                   ` SF Markus Elfring
2014-11-17 11:48                                   ` SF Markus Elfring
2014-11-17 12:46                                   ` Takashi Iwai
2014-11-17 12:46                                     ` Takashi Iwai
2014-11-17 12:12                                 ` [PATCH 1/1] ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
2014-11-17 12:12                                   ` [Cocci] " SF Markus Elfring
2014-11-17 12:12                                   ` SF Markus Elfring
2014-11-17 12:12                                   ` SF Markus Elfring
2014-11-17 12:47                                   ` Takashi Iwai
2014-11-17 12:47                                     ` [PATCH 1/1] ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmw Takashi Iwai
2014-11-17 12:41                                 ` [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_put" SF Markus Elfring
2014-11-17 12:41                                   ` [Cocci] " SF Markus Elfring
2014-11-17 12:41                                   ` SF Markus Elfring
2014-11-17 12:41                                   ` SF Markus Elfring
2014-11-17 12:53                                   ` Takashi Iwai
2014-11-17 12:53                                     ` Takashi Iwai
2014-11-17 12:53                                     ` [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_p Takashi Iwai
2014-11-17 13:15                                 ` ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
2014-11-17 13:15                                   ` SF Markus Elfring
2014-11-17 13:15                                   ` SF Markus Elfring
2014-11-17 19:11                                   ` Jarkko Nikula
2014-11-17 19:11                                     ` Jarkko Nikula
2014-11-17 19:11                                     ` Jarkko Nikula
2014-11-18  9:40                                   ` Mark Brown
2014-11-17 13:42                                 ` [PATCH 1/1] tools lib traceevent: Deletion of an unnecessary check before the function call "free_arg" SF Markus Elfring
2014-11-17 13:42                                   ` [Cocci] " SF Markus Elfring
2014-11-17 13:42                                   ` [PATCH 1/1] tools lib traceevent: Deletion of an unnecessary check before the function call "free_ar SF Markus Elfring
2014-11-17 17:11                                 ` [PATCH 1/1] perf tools: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-17 17:11                                   ` [Cocci] " SF Markus Elfring
2014-11-17 17:11                                   ` SF Markus Elfring
2014-11-17 17:40                                 ` [PATCH 1/1] mm/zswap: Deletion of an unnecessary check before the function call "free_percpu" SF Markus Elfring
2014-11-17 17:40                                   ` [Cocci] " SF Markus Elfring
2014-11-17 17:40                                   ` SF Markus Elfring
2014-11-17 17:40                                   ` SF Markus Elfring
2014-11-18 22:17                                   ` Seth Jennings
2014-11-18 22:17                                     ` Seth Jennings
2014-11-18 22:17                                     ` Seth Jennings
2014-11-17 18:19                                 ` [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put" SF Markus Elfring
2014-11-17 18:19                                   ` [Cocci] " SF Markus Elfring
2014-11-17 18:19                                   ` SF Markus Elfring
2014-11-17 18:19                                   ` SF Markus Elfring
2014-11-17 19:18                                   ` Vyacheslav Dubeyko
2014-11-17 19:18                                     ` Vyacheslav Dubeyko
2014-11-17 18:42                                 ` [PATCH 1/1] configfs: Deletion of unnecessary checks before the function call "config_item_put" SF Markus Elfring
2014-11-17 18:42                                   ` [Cocci] " SF Markus Elfring
2014-11-17 18:42                                   ` SF Markus Elfring
2014-11-18  8:35                                 ` [PATCH 1/1] fs-eventpoll: Deletion of unnecessary checks before the function call "__pm_stay_awake" SF Markus Elfring
2014-11-18  8:35                                   ` [Cocci] " SF Markus Elfring
2014-11-18  8:35                                   ` SF Markus Elfring
2014-11-18  8:35                                   ` SF Markus Elfring
2014-11-18  9:10                                 ` [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_io_state" SF Markus Elfring
2014-11-18  9:10                                   ` [Cocci] " SF Markus Elfring
2014-11-18  9:10                                   ` SF Markus Elfring
2014-11-18  9:13                                   ` [osd-dev] " Boaz Harrosh
2014-11-18  9:13                                     ` [osd-dev] [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_ Boaz Harrosh
2014-11-18 10:35                                 ` [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-18 10:35                                   ` [Cluster-devel] " SF Markus Elfring
2014-11-18 10:35                                   ` [Cocci] " SF Markus Elfring
2014-11-18 10:35                                   ` SF Markus Elfring
2014-11-18 11:05                                   ` Steven Whitehouse
2014-11-18 11:05                                     ` [Cluster-devel] " Steven Whitehouse
2014-11-18 11:20                                 ` [PATCH 1/1] fs-namespace: Deletion of unnecessary checks before the function call "mntput" SF Markus Elfring
2014-11-18 11:20                                   ` [Cocci] " SF Markus Elfring
2014-11-18 11:20                                   ` SF Markus Elfring
2014-11-18 11:20                                   ` SF Markus Elfring
2014-11-18 13:10                                 ` [PATCH 1/1] NFS: Deletion of unnecessary checks before the function call "nfs_put_client" SF Markus Elfring
2014-11-18 13:10                                   ` [Cocci] " SF Markus Elfring
2014-11-18 13:10                                   ` SF Markus Elfring
2014-11-18 13:48                                 ` [PATCH 1/1] nilfs2: Deletion of an unnecessary check before the function call "iput" SF Markus Elfring
2014-11-18 13:48                                   ` SF Markus Elfring
2014-11-18 13:48                                   ` [Cocci] " SF Markus Elfring
2014-11-18 13:48                                   ` SF Markus Elfring
2014-11-19  0:09                                   ` Ryusuke Konishi
2014-11-19  0:09                                     ` Ryusuke Konishi
2014-11-18 14:51                                 ` [PATCH 1/1] fs-proc: One function call less in proc_sys_lookup() after error detection SF Markus Elfring
2014-11-18 14:51                                   ` [Cocci] " SF Markus Elfring
2014-11-18 14:51                                   ` SF Markus Elfring
2014-11-18 17:55                                 ` [PATCH 0/2] fs-udf: Deletion of two unnecessary checks SF Markus Elfring
2014-11-18 17:55                                   ` [Cocci] " SF Markus Elfring
2014-11-18 17:55                                   ` SF Markus Elfring
2014-11-18 18:00                                   ` [PATCH 1/2] fs-udf: Deletion of unnecessary checks before the function call "iput" SF Markus Elfring
2014-11-18 18:00                                     ` [Cocci] " SF Markus Elfring
2014-11-18 18:00                                     ` SF Markus Elfring
2014-11-18 18:02                                   ` [PATCH 2/2] fs-udf: One function call less in udf_fill_super() after error detection SF Markus Elfring
2014-11-18 18:02                                     ` [Cocci] " SF Markus Elfring
2014-11-18 18:02                                     ` SF Markus Elfring
2014-11-19 20:57                                   ` [PATCH 0/2] fs-udf: Deletion of two unnecessary checks Jan Kara
2014-11-19 20:57                                     ` Jan Kara
2014-11-18 19:16                                 ` [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove" SF Markus Elfring
2014-11-18 19:16                                   ` [Cocci] " SF Markus Elfring
2014-11-18 19:16                                   ` SF Markus Elfring
2014-11-18 19:16                                   ` SF Markus Elfring
2014-11-19 20:20                                   ` David Miller
2014-11-19 20:20                                     ` David Miller
2014-11-18 19:47                                 ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-18 19:47                                   ` SF Markus Elfring
2014-11-18 19:47                                   ` SF Markus Elfring
2014-11-19 13:40                                   ` Pablo Neira Ayuso
2014-11-19 13:40                                     ` Pablo Neira Ayuso
2014-11-19 22:26                                   ` Julian Anastasov
2014-11-19 22:26                                     ` Julian Anastasov
2014-11-20  1:13                                     ` Simon Horman
2014-11-20  1:13                                       ` Simon Horman
2014-11-20 12:16                                       ` Pablo Neira Ayuso
2014-11-20 12:16                                         ` Pablo Neira Ayuso
2014-11-18 20:08                                 ` [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get" SF Markus Elfring
2014-11-18 20:08                                   ` [Cocci] " SF Markus Elfring
2014-11-18 20:08                                   ` SF Markus Elfring
2014-11-18 20:08                                   ` SF Markus Elfring
2014-11-19 20:28                                   ` David Miller
2014-11-19 20:28                                     ` David Miller
2014-11-18 20:26                                 ` [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
2014-11-18 20:26                                   ` [Cocci] " SF Markus Elfring
2014-11-18 20:26                                   ` SF Markus Elfring
2014-11-18 20:26                                   ` SF Markus Elfring
2014-11-19 16:47                                   ` John Fastabend
2014-11-19 16:47                                     ` John Fastabend
2014-11-19 16:47                                     ` John Fastabend
2014-11-19 17:00                                     ` Daniel Borkmann
2014-11-19 17:00                                       ` Daniel Borkmann
2014-11-19 17:00                                       ` Daniel Borkmann
2014-11-19 18:49                                     ` SF Markus Elfring
2014-11-19 18:49                                       ` SF Markus Elfring
2014-11-19 18:49                                       ` SF Markus Elfring
2014-11-19 19:09                                       ` Daniel Borkmann
2014-11-19 19:09                                         ` Daniel Borkmann
2014-11-19 19:09                                         ` Daniel Borkmann
2014-11-20  8:47                                       ` Julia Lawall
2014-11-20  8:47                                         ` Julia Lawall
2014-11-20  9:22                                         ` Daniel Borkmann
2014-11-20  9:22                                           ` Daniel Borkmann
2014-11-20  9:22                                           ` Daniel Borkmann
2014-11-18 20:45                                 ` [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms" SF Markus Elfring
2014-11-18 20:45                                   ` [Cocci] " SF Markus Elfring
2014-11-18 20:45                                   ` SF Markus Elfring
2014-11-18 20:45                                   ` SF Markus Elfring
2014-11-19  8:45                                   ` Dan Carpenter
2014-11-19  8:45                                     ` [Cocci] " Dan Carpenter
2014-11-19  8:45                                     ` [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tf Dan Carpenter
2014-11-19  9:51                                     ` net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms" SF Markus Elfring
2014-11-19  9:51                                       ` SF Markus Elfring
2014-11-19  9:58                                       ` Julia Lawall
2014-11-19  9:58                                         ` Julia Lawall
2014-11-19 10:10                                       ` Dan Carpenter
2014-11-19 10:10                                         ` Dan Carpenter
2014-11-19 18:19                                         ` David Miller
2014-11-19 18:19                                           ` David Miller
2014-11-18 21:03                                 ` [PATCH 1/1] keys: Deletion of an unnecessary check before the function call "key_put" SF Markus Elfring
2014-11-18 21:03                                   ` [Cocci] " SF Markus Elfring
2014-11-18 21:03                                   ` SF Markus Elfring
2014-11-19  9:20                                 ` [PATCH 1/1] crypto-drbg: Deletion of unnecessary checks before the function call "kzfree" SF Markus Elfring
2014-11-19  9:20                                   ` SF Markus Elfring
2014-11-19  9:20                                   ` SF Markus Elfring
2014-11-20 14:39                                   ` Herbert Xu
2014-11-20 14:39                                     ` Herbert Xu
2014-11-20 16:00                                     ` SF Markus Elfring
2014-11-20 16:00                                       ` SF Markus Elfring
2014-11-19 10:44                                 ` [PATCH 1/1] firmware class: Deletion of an unnecessary check before the function call "vunmap" SF Markus Elfring
2014-11-19 10:44                                   ` SF Markus Elfring
2014-11-19 11:26                                 ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister" SF Markus Elfring
2014-11-19 11:26                                   ` SF Markus Elfring
2014-11-19 11:26                                   ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unre SF Markus Elfring
2014-11-19 12:09                                   ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister" Dan Carpenter
2014-11-19 12:09                                     ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_ Dan Carpenter
2014-11-19 12:54                                     ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister" walter harms
2014-11-19 12:54                                       ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_ walter harms
2014-11-19 13:05                                       ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister" Dan Carpenter
2014-11-19 13:05                                         ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_ Dan Carpenter
2014-11-19 13:39                                         ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister" walter harms
2014-11-19 13:39                                           ` [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_ walter harms
2014-11-19 12:43                                 ` [PATCH 1/1] drbd: Deletion of an unnecessary check before the function call "lc_destroy" SF Markus Elfring
2014-11-19 12:43                                   ` SF Markus Elfring
2014-11-19 13:28                                 ` [PATCH 1/1] agp/intel-gtt: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
2014-11-19 13:28                                   ` SF Markus Elfring
2014-11-19 13:50                                 ` [PATCH 1/1] char: tpm: Deletion of unnecessary checks before the function call "tpm_dev_vendor_release" SF Markus Elfring
2014-11-19 13:50                                   ` [PATCH 1/1] char: tpm: Deletion of unnecessary checks before the function call "tpm_dev_vendor_relea SF Markus Elfring
2014-11-19 15:06                                 ` [PATCH 1/1] EDAC: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
2014-11-19 15:06                                   ` SF Markus Elfring
2014-11-19 16:40                                   ` Borislav Petkov
2014-11-19 16:40                                     ` Borislav Petkov
2014-11-19 15:40                                 ` [PATCH 1/1] DRM-EDID: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
2014-11-19 15:40                                   ` SF Markus Elfring
2014-11-19 15:40                                   ` SF Markus Elfring
2014-11-20  4:03                                   ` Thierry Reding
2014-11-19 16:14                                 ` [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hotplug_event" SF Markus Elfring
2014-11-19 16:14                                   ` SF Markus Elfring
2014-11-19 16:14                                   ` [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hot SF Markus Elfring
2014-11-20  4:11                                   ` [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hotplug_event" Thierry Reding
2014-11-20  4:11                                     ` Thierry Reding
2014-11-20  4:11                                     ` [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma Thierry Reding
2014-11-19 16:37                                 ` [PATCH 1/1] DRM-UDL: Deletion of an unnecessary check before the function call "vunmap" SF Markus Elfring
2014-11-19 16:37                                   ` SF Markus Elfring
2014-11-19 16:37                                   ` SF Markus Elfring
2014-11-20  4:17                                   ` Thierry Reding
2014-11-20  4:17                                     ` Thierry Reding
2014-11-20  4:17                                     ` Thierry Reding
2014-11-19 16:55                                 ` [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-19 16:55                                   ` SF Markus Elfring
2014-11-19 16:55                                   ` SF Markus Elfring
2014-11-20  4:22                                   ` Thierry Reding
2014-11-20  4:22                                     ` Thierry Reding
2014-11-20  4:22                                     ` Thierry Reding
2014-11-19 17:38                                 ` [PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls SF Markus Elfring
2014-11-19 17:38                                   ` SF Markus Elfring
2014-11-19 17:38                                   ` SF Markus Elfring
2014-11-19 19:55                                 ` [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
2014-11-19 19:55                                   ` SF Markus Elfring
2014-11-19 19:55                                   ` SF Markus Elfring
2014-11-19 21:54                                   ` David Miller
2014-11-19 21:54                                     ` David Miller
2014-11-19 20:34                                 ` [PATCH 1/1] bcache: Deletion of an unnecessary check before the function call "kobject_put" SF Markus Elfring
2014-11-19 20:34                                   ` SF Markus Elfring
2014-11-19 20:34                                   ` SF Markus Elfring
2014-11-19 20:55                                 ` [PATCH 1/1] dm: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-19 20:55                                   ` SF Markus Elfring
2014-11-19 20:55                                   ` SF Markus Elfring
2014-11-20  8:19                                 ` [PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks SF Markus Elfring
2014-11-20  8:19                                   ` SF Markus Elfring
2014-11-20  8:29                                   ` [PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection SF Markus Elfring
2014-11-20  8:29                                     ` SF Markus Elfring
2014-11-20  8:33                                   ` [PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call "release_firmware" SF Markus Elfring
2014-11-20  8:33                                     ` [PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call "release_ SF Markus Elfring
2014-11-20  8:39                                   ` [PATCH 3/3] [media] si2168: One function call less in si2168_init() after error detection SF Markus Elfring
2014-11-20  8:39                                     ` SF Markus Elfring
2014-11-20  9:55                                 ` [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device" SF Markus Elfring
2014-11-20  9:55                                   ` [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregis SF Markus Elfring
2014-11-20 14:41                                   ` [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device" Stefan Richter
2014-11-20 14:41                                     ` [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unr Stefan Richter
2014-11-20 10:20                                 ` [PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call "rc_unregister_device" SF Markus Elfring
2014-11-20 10:20                                   ` [PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call "rc_unregister_de SF Markus Elfring
2014-11-20 10:50                                 ` [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-20 10:50                                   ` SF Markus Elfring
2014-11-20 10:50                                   ` SF Markus Elfring
2014-11-20 10:50                                   ` SF Markus Elfring
2014-11-20 12:08                                 ` [PATCH 1/1] [media] rc: " SF Markus Elfring
2014-11-20 12:08                                   ` SF Markus Elfring
2014-11-20 12:33                                 ` [PATCH 1/1] [media] USB: Deletion of unnecessary checks before three " SF Markus Elfring
2014-11-20 12:33                                   ` SF Markus Elfring
2014-11-20 12:55                                 ` [PATCH 1/1] MTD: Deletion of unnecessary checks before two " SF Markus Elfring
2014-11-20 12:55                                   ` SF Markus Elfring
2014-11-20 12:55                                   ` SF Markus Elfring
2014-11-26  6:50                                   ` Brian Norris
2014-11-26  6:50                                     ` Brian Norris
2014-11-26  6:50                                     ` Brian Norris
2014-11-20 13:28                                 ` [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put" SF Markus Elfring
2014-11-20 13:28                                   ` SF Markus Elfring
2014-11-20 13:28                                   ` SF Markus Elfring
2014-11-21 20:14                                   ` David Miller
2014-11-21 20:14                                     ` David Miller
2014-11-20 13:50                                 ` [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-20 13:50                                   ` SF Markus Elfring
2014-11-20 13:50                                   ` SF Markus Elfring
2014-11-20 13:50                                   ` SF Markus Elfring
2014-11-20 17:29                                   ` Sören Brinkmann
2014-11-20 17:29                                     ` Sören Brinkmann
2014-11-20 17:29                                     ` Sören Brinkmann
2014-11-21 20:14                                   ` David Miller
2014-11-21 20:14                                     ` David Miller
2014-11-21 20:14                                     ` David Miller
2014-11-21 20:14                                     ` David Miller
2014-11-20 14:25                                 ` [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-20 14:25                                   ` SF Markus Elfring
2014-11-20 14:25                                   ` SF Markus Elfring
2014-11-20 18:58                                   ` Haiyang Zhang
2014-11-20 18:58                                     ` Haiyang Zhang
2014-11-20 18:58                                     ` Haiyang Zhang
2014-11-21 20:15                                   ` David Miller
2014-11-21 20:15                                     ` David Miller
2014-11-21 20:15                                     ` David Miller
2014-11-21 22:15                                     ` SF Markus Elfring
2014-11-21 22:15                                       ` SF Markus Elfring
2014-11-21 22:15                                       ` SF Markus Elfring
2014-11-21 22:27                                       ` David Miller
2014-11-21 22:27                                         ` David Miller
2014-11-21 22:27                                         ` David Miller
2014-11-23  0:51                                         ` SF Markus Elfring
2014-11-23  0:51                                           ` SF Markus Elfring
2014-11-23  0:51                                           ` SF Markus Elfring
2014-11-23  1:27                                           ` Eric Dumazet
2014-11-23  1:27                                             ` Eric Dumazet
2014-11-23  1:27                                             ` Eric Dumazet
2014-11-23  7:01                                             ` SF Markus Elfring
2014-11-23  7:01                                               ` SF Markus Elfring
2014-11-23  7:01                                               ` SF Markus Elfring
2014-11-23  4:36                                           ` David Miller
2014-11-23  4:36                                             ` David Miller
2014-11-23  7:18                                             ` SF Markus Elfring
2014-11-23  7:18                                               ` SF Markus Elfring
2014-11-23 18:37                                               ` David Miller
2014-11-23 18:37                                                 ` David Miller
2014-11-23 18:37                                                 ` David Miller
2014-11-25 21:55                                     ` [PATCH v2] " SF Markus Elfring
2014-11-25 21:55                                       ` SF Markus Elfring
2014-11-25 21:55                                       ` SF Markus Elfring
2014-11-25 22:25                                       ` David Miller
2014-11-25 22:25                                         ` David Miller
2014-11-20 15:16                                 ` [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
2014-11-20 15:16                                   ` SF Markus Elfring
2014-11-20 15:16                                   ` SF Markus Elfring
2014-11-21 20:16                                   ` David Miller
2014-11-21 20:16                                     ` David Miller
2014-11-20 15:50                                 ` [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-20 15:50                                   ` SF Markus Elfring
2014-11-20 15:50                                   ` SF Markus Elfring
2014-11-20 18:04                                   ` Arend van Spriel
2014-11-20 18:04                                     ` Arend van Spriel
2014-11-20 18:04                                     ` Arend van Spriel
2014-11-20 16:47                                 ` [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put" SF Markus Elfring
2014-11-20 16:47                                   ` SF Markus Elfring
2014-11-20 17:23                                 ` [PATCH 1/1] SCSI-OSD: Deletion of an unnecessary check before the function call "put_disk" SF Markus Elfring
2014-11-20 17:23                                   ` SF Markus Elfring
2014-11-20 17:23                                   ` SF Markus Elfring
2014-11-20 17:55                                 ` [PATCH 1/1] SCSI: Deletion of unnecessary checks before the function call "put_device" SF Markus Elfring
2014-11-20 17:55                                   ` SF Markus Elfring
2014-11-20 17:55                                   ` SF Markus Elfring
2014-11-20 19:15                                 ` [PATCH 1/1] SCSI-libfc: Deletion of an unnecessary check before the function call "fc_fcp_ddp_done" SF Markus Elfring
2014-11-20 19:15                                   ` SF Markus Elfring
2014-11-20 19:15                                   ` SF Markus Elfring
2014-11-20 19:42                                 ` [PATCH 1/1] SCSI-eata_pio: Deletion of an unnecessary check before the function call "pci_dev_put" SF Markus Elfring
2014-11-20 19:42                                   ` SF Markus Elfring
2014-11-20 19:42                                   ` SF Markus Elfring
2014-11-20 22:23                                 ` [PATCH 1/1] SCSI-aic94xx: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
2014-11-20 22:23                                   ` SF Markus Elfring
2014-11-20 22:23                                   ` SF Markus Elfring
2014-11-20 22:46                                 ` [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-20 22:46                                   ` SF Markus Elfring
2014-11-20 22:46                                   ` SF Markus Elfring
2014-11-21  4:20                                   ` Anil Gurumurthy
2014-11-21  4:20                                     ` Anil Gurumurthy
2014-11-21  8:20                                 ` [PATCH 1/1] SCSI-libcxgbi: Deletion of an unnecessary check before the function call "dst_release" SF Markus Elfring
2014-11-21  8:20                                   ` SF Markus Elfring
2014-11-21  8:20                                   ` SF Markus Elfring
2014-11-21  8:45                                 ` [PATCH 1/1] SCSI-fnic: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-21  8:45                                   ` SF Markus Elfring
2014-11-21  8:45                                   ` SF Markus Elfring
2014-11-21  9:30                                 ` [PATCH 1/1] target: Deletion of unnecessary checks before the function call "module_put" SF Markus Elfring
2014-11-21  9:30                                   ` SF Markus Elfring
2014-11-21  9:30                                   ` SF Markus Elfring
2014-11-21 21:57                                   ` Nicholas A. Bellinger
2014-11-21 21:57                                     ` Nicholas A. Bellinger
2014-11-21 10:12                                 ` [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-21 10:12                                   ` SF Markus Elfring
2014-11-21 10:12                                   ` SF Markus Elfring
2014-11-21 10:12                                   ` SF Markus Elfring
2014-11-21 10:17                                   ` Julia Lawall
2014-11-21 10:17                                     ` Julia Lawall
2014-11-21 10:17                                     ` Julia Lawall
2014-11-21 13:25                                     ` SF Markus Elfring
2014-11-21 13:25                                       ` SF Markus Elfring
2014-11-21 13:25                                       ` SF Markus Elfring
2014-11-21 13:25                                       ` SF Markus Elfring
2014-11-21 16:17                                     ` [PATCH v2] " SF Markus Elfring
2014-11-21 16:17                                       ` SF Markus Elfring
2014-11-21 16:17                                       ` SF Markus Elfring
2014-11-21 16:17                                       ` SF Markus Elfring
2014-11-21 10:40                                 ` [PATCH 1/1] thunderbolt: Deletion of unnecessary checks before the function call "ring_free" SF Markus Elfring
2014-11-21 10:40                                   ` SF Markus Elfring
2014-11-21 11:29                                   ` Andreas Noever
2014-11-21 11:29                                     ` Andreas Noever
2014-11-21 12:21                                     ` SF Markus Elfring
2014-11-21 12:21                                       ` SF Markus Elfring
2014-11-21 18:14                                       ` Joe Perches
2014-11-21 18:14                                         ` Joe Perches
2014-11-23 14:14                                         ` SF Markus Elfring
2014-11-23 14:14                                           ` SF Markus Elfring
2014-11-23 15:20                                           ` Joe Perches
2014-11-23 15:20                                             ` Joe Perches
2014-11-23 15:42                                             ` SF Markus Elfring
2014-11-23 15:42                                               ` SF Markus Elfring
2014-11-23 15:51                                               ` Julia Lawall
2014-11-23 15:51                                                 ` Julia Lawall
2014-11-23 19:03                                                 ` SF Markus Elfring
2014-11-23 19:03                                                   ` SF Markus Elfring
2014-11-23 19:06                                                   ` Joe Perches
2014-11-23 19:06                                                     ` Joe Perches
2014-11-23 15:45                                             ` Andreas Noever
2014-11-23 15:45                                               ` Andreas Noever
2014-11-23 15:56                                               ` Joe Perches
2014-11-23 15:56                                                 ` Joe Perches
2014-11-21 11:45                                 ` [PATCH 1/1] tty-hvsi_lib: Deletion of an unnecessary check before the function call "tty_kref_put" SF Markus Elfring
2014-11-21 11:45                                   ` SF Markus Elfring
2014-11-21 11:45                                   ` SF Markus Elfring
2014-11-21 12:51                                 ` [PATCH 1/1] tty: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-21 12:51                                   ` SF Markus Elfring
2014-11-21 13:55                                 ` [PATCH 1/1] USB: gadget: function: Deletion of an unnecessary check before the function call "rndis_add_hdr" SF Markus Elfring
2014-11-21 13:55                                   ` [PATCH 1/1] USB: gadget: function: Deletion of an unnecessary check before the function call "rndis_ SF Markus Elfring
2014-11-21 14:23                                 ` [PATCH 1/1] USB: PCI-quirks: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
2014-11-21 14:23                                   ` SF Markus Elfring
2014-11-21 14:55                                 ` [PATCH 1/1] USB-SIS: Deletion of an unnecessary check before the function call "usb_put_dev" SF Markus Elfring
2014-11-21 14:55                                   ` SF Markus Elfring
2014-11-21 15:20                                 ` [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
2014-11-21 15:20                                   ` [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firmware SF Markus Elfring
2014-11-21 15:26                                   ` [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firmware" Julia Lawall
2014-11-21 15:26                                     ` [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firm Julia Lawall
2014-11-21 15:48                                     ` USB: serial: Deletion of an unnecessary check before the function call "release_firmware" SF Markus Elfring
2014-11-21 15:48                                       ` SF Markus Elfring
2014-11-21 17:59                                       ` Julia Lawall
2014-11-21 17:59                                         ` Julia Lawall
2014-11-24  9:10                                         ` Johan Hovold
2014-11-24  9:10                                           ` Johan Hovold
2014-11-21 15:36                                 ` [PATCH 1/1] USB-IP: Deletion of unnecessary checks before the function call "usb_put_dev" SF Markus Elfring
2014-11-21 15:36                                   ` SF Markus Elfring
2014-11-21 17:44                                   ` Valentina Manea
2014-11-21 17:44                                     ` Valentina Manea
2014-11-21 17:40                                 ` [PATCH 1/1] ALSA: core: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-21 17:40                                   ` SF Markus Elfring
2014-11-21 17:40                                   ` SF Markus Elfring
2014-11-21 19:07                                   ` Takashi Iwai
2014-11-21 19:07                                     ` Takashi Iwai
2014-11-21 18:11                                 ` [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and_free_resource" SF Markus Elfring
2014-11-21 18:11                                   ` SF Markus Elfring
2014-11-21 18:11                                   ` [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and SF Markus Elfring
2014-11-21 19:08                                   ` [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and_free_resource" Takashi Iwai
2014-11-21 19:08                                     ` [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release Takashi Iwai
2014-11-21 18:35                                 ` [PATCH 1/1] ALSA: sb: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-21 18:35                                   ` SF Markus Elfring
2014-11-21 18:35                                   ` SF Markus Elfring
2014-11-21 19:08                                   ` Takashi Iwai
2014-11-21 19:08                                     ` Takashi Iwai
2014-11-21 19:26                                 ` [PATCH 1/1] IDE: Deletion of an unnecessary check before the function call "module_put" SF Markus Elfring
2014-11-21 19:26                                   ` SF Markus Elfring
2014-11-21 19:26                                   ` SF Markus Elfring
2014-11-21 23:01                                 ` [PATCH 1/1] [IA64] Deletion of unnecessary checks before the function call "unw_remove_unwind_table" SF Markus Elfring
2014-11-21 23:01                                   ` SF Markus Elfring
2014-11-22 21:09                                   ` Dan Carpenter
2014-11-22 21:09                                     ` [PATCH 1/1] [IA64] Deletion of unnecessary checks before the function call "unw_remove_unwind_ta Dan Carpenter
2014-11-22 10:00                                 ` [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three function calls SF Markus Elfring
2014-11-22 10:00                                   ` SF Markus Elfring
2014-11-22 10:00                                   ` SF Markus Elfring
2014-11-22 10:00                                   ` SF Markus Elfring
2014-11-22 10:40                                 ` [PATCH 1/1] ARM-kernel: Deletion of unnecessary checks before two " SF Markus Elfring
2014-11-22 10:40                                   ` SF Markus Elfring
2014-11-22 10:40                                   ` SF Markus Elfring
2014-11-22 12:00                                 ` [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_table" SF Markus Elfring
2014-11-22 12:00                                   ` [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_ta SF Markus Elfring
2014-11-25 15:48                                   ` [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_table" Jon Mason
2014-11-25 15:48                                     ` [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tc Jon Mason
2014-11-22 13:10                                 ` [PATCH 1/1] x86: AMD-perf_event: Deletion of unnecessary checks before the function call "free_percpu" SF Markus Elfring
2014-11-22 13:10                                   ` [PATCH 1/1] x86: AMD-perf_event: Deletion of unnecessary checks before the function call "free_percp SF Markus Elfring
2014-11-22 14:05                                 ` [PATCH 1/1] s390/pci: Deletion of unnecessary checks before the function call "debug_unregister" SF Markus Elfring
2014-11-22 14:05                                   ` SF Markus Elfring
2014-11-24 19:06                                   ` Sebastian Ott
2014-11-24 19:06                                     ` Sebastian Ott
2014-11-22 15:26                                 ` [PATCH 1/1] PowerPC-83xx: Deletion of an unnecessary check before the function call "of_node_put" SF Markus Elfring
2014-11-22 15:26                                   ` SF Markus Elfring
2014-11-22 15:26                                   ` SF Markus Elfring
2014-11-22 16:00                                 ` [PATCH 1/1] video: fbdev-LCDC: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-22 16:00                                   ` SF Markus Elfring
2014-11-23 10:11                                 ` [PATCH 1/1] video: uvesafb: Deletion of an unnecessary check before the function call "uvesafb_free" SF Markus Elfring
2014-11-23 10:11                                   ` SF Markus Elfring
2014-11-23 10:44                                 ` [PATCH 1/1] video: udlfb: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
2014-11-23 10:44                                   ` SF Markus Elfring
2014-11-23 11:33                                 ` [PATCH 1/1] video: smscufx: " SF Markus Elfring
2014-11-23 11:33                                   ` SF Markus Elfring
2014-11-23 12:00                                 ` [PATCH 1/1] video: fbdev-SIS: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
2014-11-23 12:00                                   ` SF Markus Elfring
2014-11-23 13:14                                 ` [PATCH 1/1] video: fbdev-OMAP2: Deletion of unnecessary checks before the function call "i2c_put_adapter" SF Markus Elfring
2014-11-23 13:14                                   ` SF Markus Elfring
2014-11-23 13:14                                   ` [PATCH 1/1] video: fbdev-OMAP2: Deletion of unnecessary checks before the function call "i2c_put_ada SF Markus Elfring
2014-11-23 14:20                                 ` [PATCH 1/1] video: mx3fb: Deletion of an unnecessary check before the function call "backlight_device_unregister" SF Markus Elfring
2014-11-23 14:20                                   ` [PATCH 1/1] video: mx3fb: Deletion of an unnecessary check before the function call "backlight_devic SF Markus Elfring
2014-11-23 15:00                                 ` [PATCH 1/1] video: fbdev-MMP: Deletion of an unnecessary check before the function call "mmp_unregister_path" SF Markus Elfring
2014-11-23 15:00                                   ` [PATCH 1/1] video: fbdev-MMP: Deletion of an unnecessary check before the function call "mmp_unregis SF Markus Elfring
2014-11-23 15:33                                 ` [PATCH 1/1] video: fbdev-VIA: Deletion of an unnecessary check before the function call "framebuffer_release" SF Markus Elfring
2014-11-23 15:33                                   ` [PATCH 1/1] video: fbdev-VIA: Deletion of an unnecessary check before the function call "framebuffer SF Markus Elfring
2014-11-23 16:10                                 ` [PATCH 1/1] video: uvesafb: Deletion of an unnecessary check before the function call "platform_device_put" SF Markus Elfring
2014-11-23 16:10                                   ` [PATCH 1/1] video: uvesafb: Deletion of an unnecessary check before the function call "platform_devi SF Markus Elfring
2014-11-23 16:40                                 ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_device_unregister" SF Markus Elfring
2014-11-23 16:40                                   ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_ SF Markus Elfring
2014-11-24 10:09                                   ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_device_unregister" Lee Jones
2014-11-24 10:09                                     ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backli Lee Jones
2014-11-24 10:09                                     ` Lee Jones
2014-11-24 10:10                                   ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_device_unregister" Lee Jones
2014-11-24 10:10                                     ` [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backli Lee Jones
2014-11-24 10:10                                     ` Lee Jones
2014-11-24 18:05                                     ` [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister() SF Markus Elfring
2014-11-24 18:05                                       ` SF Markus Elfring
2014-11-23 18:33                                 ` [PATCH 0/2] staging: android: ion: Deletion of a few unnecessary checks SF Markus Elfring
2014-11-23 18:33                                   ` SF Markus Elfring
2014-11-23 18:33                                   ` SF Markus Elfring
2014-11-23 18:39                                   ` [PATCH 1/2] staging: android: ion: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-23 18:39                                     ` SF Markus Elfring
2014-11-23 18:39                                     ` SF Markus Elfring
2014-11-23 18:44                                   ` [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detection SF Markus Elfring
2014-11-23 18:44                                     ` [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detecti SF Markus Elfring
2014-11-26 21:42                                     ` [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detection Greg Kroah-Hartman
2014-11-26 21:42                                       ` [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error det Greg Kroah-Hartman
2014-11-27 14:25                                       ` [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error detection SF Markus Elfring
2014-11-27 14:25                                         ` [PATCH 2/2] staging: android: ion: One function call less in ion_buffer_create() after error det SF Markus Elfring
2014-11-27 15:23                                     ` walter harms
2014-11-24 19:40                                 ` [PATCH 1/1] platform: x86: Deletion of checks before backlight_device_unregister() SF Markus Elfring
2014-11-24 19:40                                   ` SF Markus Elfring
2014-11-24 19:40                                   ` SF Markus Elfring
2014-11-24  8:28                                   ` Darren Hart
2014-11-24  8:28                                     ` Darren Hart
2014-11-24 21:28                                   ` Anisse Astier
2014-11-24 21:28                                     ` Anisse Astier
2014-11-24 22:12                                     ` SF Markus Elfring
2014-11-24 22:12                                       ` SF Markus Elfring
2014-11-27 18:13                                       ` Julia Lawall
2014-11-27 18:13                                         ` Julia Lawall
2014-11-24 21:04                                 ` [PATCH 1/1] Sony-laptop: Deletion of an unnecessary check before the function call "pci_dev_put" SF Markus Elfring
2014-11-24 21:04                                   ` SF Markus Elfring
2014-11-24 21:04                                   ` SF Markus Elfring
2014-11-24  8:28                                   ` Darren Hart
2014-11-24  8:28                                     ` Darren Hart
2014-11-24 21:40                                 ` [PATCH 1/1] [media] Siano: Deletion of an unnecessary check before the function call "rc_unregister_device" SF Markus Elfring
2014-11-24 21:40                                   ` [PATCH 1/1] [media] Siano: Deletion of an unnecessary check before the function call "rc_unregister_ SF Markus Elfring
2014-11-24 22:03                                 ` [PATCH 1/1] staging: olpc_dcon: Deletion of a check before backlight_device_unregister() SF Markus Elfring
2014-11-24 22:03                                   ` SF Markus Elfring
2014-11-25 12:50                                 ` [PATCH 1/1] GPU-DRM-MSM-Adreno: Deletion of unnecessary checks before the function call "release_firmware" SF Markus Elfring
2014-11-25 12:50                                   ` SF Markus Elfring
2014-11-25 12:50                                   ` [PATCH 1/1] GPU-DRM-MSM-Adreno: Deletion of unnecessary checks before the function call "release_fir SF Markus Elfring
2014-11-25 13:33                                 ` [PATCH 1/1] GPU-DRM-MSM: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-25 13:33                                   ` SF Markus Elfring
2014-11-25 13:33                                   ` SF Markus Elfring
2014-11-25 15:16                                 ` [PATCH 1/1] IMX-DRM-core: Deletion of a check before drm_fbdev_cma_restore_mode() SF Markus Elfring
2014-11-25 15:16                                   ` SF Markus Elfring
2014-11-25 15:57                                 ` [PATCH 1/1] staging: ozwpan: Deletion of unnecessary checks before the function call "oz_free_urb_link" SF Markus Elfring
2014-11-25 15:57                                   ` [PATCH 1/1] staging: ozwpan: Deletion of unnecessary checks before the function call "oz_free_urb_li SF Markus Elfring
2014-11-29 13:42                                 ` [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-29 13:42                                   ` [Cocci] " SF Markus Elfring
2014-11-29 13:42                                   ` SF Markus Elfring
2014-11-29 13:42                                   ` SF Markus Elfring
2014-11-29 14:05                                   ` [PATCH 1/1] net: cassini: " SF Markus Elfring
2014-11-29 14:05                                     ` [Cocci] " SF Markus Elfring
2014-11-29 14:05                                     ` SF Markus Elfring
2014-11-29 14:05                                     ` SF Markus Elfring
2014-11-29 14:33                                 ` [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device" SF Markus Elfring
2014-11-29 14:33                                   ` [Cocci] " SF Markus Elfring
2014-11-29 14:33                                   ` SF Markus Elfring
2014-11-29 14:33                                   ` SF Markus Elfring
     [not found]                               ` <5317A59D.4@users.so urceforge.net>
     [not found]                                 ` <5317A59D.4-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2014-11-19 18:25                                   ` [PATCH 1/1] InfiniBand: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-19 18:25                                     ` SF Markus Elfring
2014-11-19 18:25                                     ` SF Markus Elfring
2014-03-01  8:16                             ` [Cocci] Improvements for passing of big regular expressions in SmPL constraints? SF Markus Elfring
2014-03-01 13:15                               ` Julia Lawall
2014-03-01 13:34                                 ` SF Markus Elfring
2014-03-01 13:36                                   ` Julia Lawall
2014-03-08 12:30                             ` [Cocci] Determination of the number for named function parameters SF Markus Elfring
2014-03-08 14:16                               ` Julia Lawall
2014-03-08 15:10                                 ` SF Markus Elfring
2014-03-08 20:01                                   ` SF Markus Elfring
2014-03-08 21:41                                     ` Julia Lawall
2014-03-09  8:00                                       ` SF Markus Elfring
2014-03-09  8:12                                         ` Julia Lawall
2014-03-09  8:50                                           ` SF Markus Elfring
2014-03-14 14:25                                             ` SF Markus Elfring
2014-03-09 12:51                                           ` SF Markus Elfring
2014-03-09 13:06                                             ` Julia Lawall
2014-03-09 13:36                                               ` SF Markus Elfring
2014-03-09 13:40                                                 ` Julia Lawall
2014-03-09 13:51                                                   ` SF Markus Elfring
2014-03-10 18:00                                           ` [Cocci] Selection of class libraries ...? SF Markus Elfring
2014-03-10 18:19                                             ` Julia Lawall
2014-03-10 18:30                                               ` SF Markus Elfring
2014-03-10 19:24                                                 ` Julia Lawall
2014-03-10 21:10                                                   ` SF Markus Elfring
2014-03-10 21:15                                                     ` Julia Lawall
2014-03-10 21:26                                                       ` SF Markus Elfring
2014-03-12 10:10                                                       ` [Cocci] Clarification for OCaml scripts in SmPL SF Markus Elfring
2014-03-12 12:10                                                         ` SF Markus Elfring
2014-03-14  0:19                                                           ` Julia Lawall
2014-03-13 23:56                                                         ` Julia Lawall
2014-03-13 23:58                                                           ` Julia Lawall
2014-03-14  0:09                                                         ` Julia Lawall
2014-03-14  7:14                                                           ` SF Markus Elfring
2014-03-14  8:29                                                             ` Julia Lawall
2014-03-14  8:39                                                               ` SF Markus Elfring
2014-03-14  8:48                                                                 ` Julia Lawall
2014-03-14  9:01                                                                   ` SF Markus Elfring
2014-03-08 21:59                                   ` [Cocci] Determination of the number for named function parameters Julia Lawall
2014-03-09  7:01                                     ` SF Markus Elfring
2014-03-09  7:13                                       ` Julia Lawall
2014-03-09  7:18                                         ` [Cocci] Improvements for the SmPL grammar description? SF Markus Elfring
2014-02-26  7:25                   ` [Cocci] Branch layout for if statements with SmPL disjunctions SF Markus Elfring
2014-02-26  9:39                     ` Julia Lawall
2014-11-28 16:00       ` [Cocci] Remove unnecessary null pointer checks? SF Markus Elfring
2014-03-27 13:41   ` [Cocci] How to exclude volatile data accesses in expressions with SmPL? SF Markus Elfring
2014-03-27 18:10     ` Julia Lawall
2014-03-27 18:39       ` SF Markus Elfring
2014-03-27 18:43         ` Julia Lawall
2014-03-27 18:59           ` SF Markus Elfring
2014-04-07 15:07           ` SF Markus Elfring
2014-04-07 15:16             ` Julia Lawall
2014-04-07 15:28               ` SF Markus Elfring
2014-04-07 15:34                 ` Julia Lawall
2014-04-07 15:40                   ` SF Markus Elfring

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.