Re: [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls

2014-03-05 Thread SF Markus Elfring
 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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck Linux 3.14-rc5 PATCH 1 of 5] Deletion of unnecessary checks before specific function calls

2014-03-05 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck Linux 3.14-rc5 PATCH 2 of 5] Deletion of unnecessary checks before specific function calls

2014-03-05 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck Linux 3.14-rc5 PATCH 3 of 5] Deletion of unnecessary checks before specific function calls

2014-03-05 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck Linux 3.14-rc5 PATCH 4 of 5] Deletion of unnecessary checks before specific function calls

2014-03-05 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck Linux 3.14-rc5 PATCH 5 of 5] Deletion of unnecessary checks before specific function calls

2014-03-05 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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 

Re: [PATCH 1/1] scripts/coccinelle/free: add conditional kfree test

2014-06-17 Thread SF Markus Elfring
 This patch adds a trivial script warning on

 if(foo)
  kfree(foo)
[...]
 You should probably add all of the unnecessary
 conditional tests that checkpatch uses:
[...]


Would you like to look at my previous update suggestion Deletion of unnecessary
checks before specific function calls again?
https://systeme.lip6.fr/pipermail/cocci/2014-March/000675.html
https://lkml.org/lkml/2014/3/5/344

Regards,
Markus

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] coccinelle: add pycocci wrapper for multithreaded support

2014-04-10 Thread SF Markus Elfring
 I checked the profile results, the reason the jobs finish is some threads
 had no work or little work.

Could you find out during the data processing which parts or files
result in a special application behaviour you would like to point out here?

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: [Cocci] [PATCH] coccinelle: add pycocci wrapper for multithreaded support

2014-04-11 Thread SF Markus Elfring
 Could you find out during the data processing which parts or files
 result in a special application behaviour you would like to point out here?
 I don't understand the question at all, but since the various files have 
 different properties, it is hard to determine automatically in advance how 
 much work Coccinelle will need to do on each one.

It was reported that a system utilisation did not fit to some
expectations. I am curious if any more details or patterns can be
determined for an observed situation.

Do the involved files need also another look?
- semantic patches
- source directories

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Cocci] SmPL for automatic request_firmware_nowait() conversion

2014-06-21 Thread SF Markus Elfring
 Obviously I considered writing SmPL for this, but one thing which seemed
 hard was that for after the request_firmware_nowait() we tend to tuck
 away into another new call the rest of the code that was in place in the
 original function after the old request_firmware() call. Is there a way
 to dump all that code into the new routine?

Does the refactoring Extraction of an interface fit also to your use case?
http://refactoring.com/catalog/extractInterface.html
http://c2.com/cgi/wiki?ExtractInterface


 I think the hardest thing would be to also move the right set of variables 
 over.

The current syntax for semantic patches has got some limitations for its
expression power. I guess that it is still a software development challenge to
support also variations in involved statements.


 Its hard for me to think of how I can hint to Coccinelle enough information
 about what stuff it needs to move around. I think one hint would be:
 
   Hey all that code that is static and is used *before* and *after* 
 request_firmware()
stuff it into the private data structure

Do you need dynamic source code introspection here?

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V3] scripts/coccinelle/free: Delete NULL test before freeing functions?

2014-06-28 Thread SF Markus Elfring

 V3: 
-Update print_main message.

Does the discussion topic need also an adjustment?

How do you think about my previous update suggestion Deletion of
unnecessary checks before specific function calls?
https://systeme.lip6.fr/pipermail/cocci/2014-March/000675.html
https://lkml.org/lkml/2014/3/5/344

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V3] scripts/coccinelle/free: Delete NULL test before freeing functions?

2014-06-28 Thread SF Markus Elfring

 How do you think about my previous update suggestion Deletion of
 unnecessary checks before specific function calls?
 https://systeme.lip6.fr/pipermail/cocci/2014-March/000675.html
 https://lkml.org/lkml/2014/3/5/344
 I didn't see you made the same kind of script.

Will my approach become a bit more complete in the near future?
http://article.gmane.org/gmane.comp.version-control.coccinelle/3512/

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V3] scripts/coccinelle/free: Delete NULL test before freeing functions?

2014-06-28 Thread SF Markus Elfring
 Sorry but I'm not working on coccinelle ; just did a small script for kernel 
 tree.

I would appreciate a more constructive feedback for my update suggestions around
the topic Deletion of unnecessary checks before specific function calls.
- Did you look at the concrete patches?
- How do you think about the general approach?

Examples:
https://systeme.lip6.fr/pipermail/cocci/2014-March/000676.html
http://marc.info/?l=kernel-janitorsm=139405971927100w=2

https://systeme.lip6.fr/pipermail/cocci/2014-March/000677.html
http://marc.info/?l=kernel-janitorsm=139405983727148w=2

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Cocci] [PATCH V3] scripts/coccinelle/free: Delete NULL test before freeing functions?

2014-06-29 Thread SF Markus Elfring
 https://systeme.lip6.fr/pipermail/cocci/2014-March/000676.html
 http://marc.info/?l=kernel-janitorsm=139405971927100w=2
 Regular expressions do not allow taking advantage of the optimizations 
 provided by Coccinelle and are not easy for a reader to understand.

I find that the application of regexes is appropriate here.
Would you like to optimise any implementation details from my general
approach?


 https://systeme.lip6.fr/pipermail/cocci/2014-March/000677.html
 http://marc.info/?l=kernel-janitorsm=139405983727148w=2
 This is not safe due to the use of when any.  You have no guarantee that 
 there is not a dereference of input in the matched region, or that the 
 value of input is still the argument value at the point of the test.

Do you suggest to make the desired detection of input parameter
validation a bit safer?

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V3] scripts/coccinelle/free: Delete NULL test before freeing functions?

2014-06-29 Thread SF Markus Elfring

   I hope you had information you wanted from Julia ?

Yes. - I am waiting on another Coccinelle software release which will
contain improvements for my feature requests and bug reports.
I'm curious when I should retry proposed filter patterns.

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 119/197] scripts/coccinelle/free: Delete NULL test before freeing functions

2014-08-09 Thread SF Markus Elfring
 +@r depends on context || report || org @
 +expression E;
 +position p;
 +@@
 +
 +* if (E)
 +*
 \(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb\)(E);

How do you think about to add the construct @p also behind the function name
usb_free_urb?


Is my previous update suggestion for such an issue worth for another look, too?

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 119/197] scripts/coccinelle/free: Delete NULL test before freeing functions?

2014-08-09 Thread SF Markus Elfring
 I still don't think this should be done for any random function that 
 performs a null test on its argument.  The corrections involved here are 
 not as trivial as they would seem.

I would prefer to make the list of corresponding function names more complete.


 Often it is not the case that the null test at the call site should be
 just deleted, instead the code should be reorganized.

Which source code places do you know where a different approach might look 
better?


 (Personally, I don't like the whole null test removal idea. [...]

Would you like to clarify involved software concerns a bit more?

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] scripts/coccinelle/free/ifnullfree.cocci: simplify and extend to of_node_put

2014-08-11 Thread SF Markus Elfring
  @r depends on context || report || org @
 @@ -37,7 +35,8 @@ position p;
  @@
  
  * if (E)
 -*
 \(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb\)(E);
 +*  \(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb@p\|
 +*of_node_put@p\)(E);

Why do you want to limit this semantic patch pattern to such a small list of
function names?

Would you like to consider also the hundreds of other functions which perform
input parameter validation?
Are you interested to make the checked list more complete with further
(eventually automatic?) extensions?

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] staging - rtl8188eu: Deletion of unnecessary checks before three function calls

2014-10-23 Thread SF Markus Elfring
From 45970693cad6c12da2d5ac7da3d2bd7a566170d7 Mon Sep 17 00:00:00 2001
From: Markus Elfring elfr...@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 elfr...@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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls

2014-10-26 Thread SF Markus Elfring
 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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] GPU-DRM-nouveau: Deletion of unnecessary checks before two function calls

2014-10-22 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls

2014-10-22 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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;

-

Re: [PATCH 1/1] IOMMU-MSM: Deletion of unnecessary checks before the function call clk_disable

2014-10-22 Thread SF Markus Elfring
 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 af73fb59d5d4b2c289fb236d0752522b6b38 Mon Sep 17 00:00:00 2001
From: Markus Elfring elfr...@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 elfr...@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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] SCSI-QLA2...: Deletion of unnecessary checks before the function call vfree

2014-10-22 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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;

Re: [PATCH 1/6] Coccinelle: Semantic patch for replacing puts with putc

2014-09-12 Thread SF Markus Elfring
 Using seq_puts to write a one-character string is suboptimal,
 since puts has to call strlen().

Are there any more functions which work with such strings in a similar way?
Would it make sense to look also at other function names?

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Cocci] [PATCH v2 2/7] module: add extra argument for parse_params() callback

2014-10-04 Thread SF Markus Elfring
 This adds an extra argument onto parse_params() to be used
 as a way to make the unused callback a bit more useful and
 generic by allowing the caller to pass on a data structure
 of its choice.

How do you think about to work with more data type definitions for such callback
functions?

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Cocci] [PATCH v2 2/7] module: add extra argument for parse_params() callback

2014-10-06 Thread SF Markus Elfring
 How do you think about to work with more data type definitions for such
 callback functions?
 
 Sorry I don't understand what you mean.

Can a specific typedef help in corresponding software maintenance?

Do you find descriptions from an other software application useful for such an
use case here?
http://www.fltk.org/doc-1.3/group__callback__functions.html

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH with Coccinelle?] Deletion of unnecessary checks before specific function calls

2014-10-01 Thread SF Markus Elfring
 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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck PATCH 1/5] Deletion of unnecessary checks before specific function calls

2014-10-01 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck PATCH 2/5] Deletion of unnecessary checks before specific function calls

2014-10-01 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck PATCH 3/5] Deletion of unnecessary checks before specific function calls

2014-10-01 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck PATCH 4/5] Deletion of unnecessary checks before specific function calls

2014-10-01 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [coccicheck PATCH 5/5] Deletion of unnecessary checks before specific function calls

2014-10-01 Thread SF Markus Elfring
 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 elfr...@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 elfr...@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 000..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 

Re: [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls

2014-10-31 Thread SF Markus Elfring
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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls

2014-10-31 Thread SF Markus Elfring
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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH resent] staging: rtl8188eu: Deletion of unnecessary checks before three function calls

2014-10-31 Thread SF Markus Elfring
 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 elfr...@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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] fs-proc: One function call less in proc_sys_lookup() after error detection

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] fs-udf: Deletion of two unnecessary checks

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] fs-udf: Deletion of unnecessary checks before the function call iput

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] fs-udf: One function call less in udf_fill_super() after error detection

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call proc_remove

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] netlink: Deletion of an unnecessary check before the function call __module_get

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call kfree

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call ipcomp_free_tfms

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] keys: Deletion of an unnecessary check before the function call key_put

2014-11-18 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] kprobes: Deletion of an unnecessary check before the function call module_put

2014-11-18 Thread SF Markus Elfring
 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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] crypto-drbg: Deletion of unnecessary checks before the function call kzfree

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: net: xfrm: Deletion of an unnecessary check before the function call ipcomp_free_tfms

2014-11-19 Thread SF Markus Elfring
 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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] firmware class: Deletion of an unnecessary check before the function call vunmap

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call wakeup_source_unregister

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] drbd: Deletion of an unnecessary check before the function call lc_destroy

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] agp/intel-gtt: Deletion of unnecessary checks before the function call pci_dev_put

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] char: tpm: Deletion of unnecessary checks before the function call tpm_dev_vendor_release

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] EDAC: Deletion of unnecessary checks before the function call pci_dev_put

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] DRM-EDID: Deletion of an unnecessary check before the function call release_firmware

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call drm_fbdev_cma_hotplug_event

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] DRM-UDL: Deletion of an unnecessary check before the function call vunmap

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call vfree

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] InfiniBand: Deletion of unnecessary checks before two function calls

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: net: sched: Deletion of an unnecessary check before the function call kfree

2014-11-19 Thread SF Markus Elfring
 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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call vfree

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] bcache: Deletion of an unnecessary check before the function call kobject_put

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] dm: Deletion of unnecessary checks before two function calls

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call release_firmware

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] [media] si2168: One function call less in si2168_init() after error detection

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call dvb_unregister_device

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call rc_unregister_device

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] [media] rc: Deletion of unnecessary checks before two function calls

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] [media] USB: Deletion of unnecessary checks before three function calls

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] MTD: Deletion of unnecessary checks before two function calls

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call of_dev_put

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call vfree

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call kfree

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: crypto-drbg: Deletion of unnecessary checks before the function call kzfree

2014-11-20 Thread SF Markus Elfring
 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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call pci_dev_put

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] SCSI-OSD: Deletion of an unnecessary check before the function call put_disk

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] SCSI: Deletion of unnecessary checks before the function call put_device

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] SCSI-libfc: Deletion of an unnecessary check before the function call fc_fcp_ddp_done

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] SCSI-eata_pio: Deletion of an unnecessary check before the function call pci_dev_put

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] SCSI-aic94xx: Deletion of an unnecessary check before the function call kfree

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call vfree

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] SCSI-libcxgbi: Deletion of an unnecessary check before the function call dst_release

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] SCSI-fnic: Deletion of an unnecessary check before the function call vfree

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] target: Deletion of unnecessary checks before the function call module_put

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] thunderbolt: Deletion of unnecessary checks before the function call ring_free

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] tty-hvsi_lib: Deletion of an unnecessary check before the function call tty_kref_put

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: thunderbolt: Deletion of unnecessary checks before the function call ring_free

2014-11-21 Thread SF Markus Elfring
 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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] tty: Deletion of unnecessary checks before two function calls

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: thermal: Exynos: Deletion of unnecessary checks before two function calls

2014-11-21 Thread SF Markus Elfring
  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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] USB: gadget: function: Deletion of an unnecessary check before the function call rndis_add_hdr

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] USB: PCI-quirks: Deletion of unnecessary checks before the function call pci_dev_put

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] USB-SIS: Deletion of an unnecessary check before the function call usb_put_dev

2014-11-21 Thread SF Markus Elfring
From: Markus Elfring elfr...@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 elfr...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >