This patch detects the cases in which a variable is not modified through
the code and it is used as a return value. The variable is detected and
removed by coccinelle using the following semantic patch:
@@ type T; expression expr; identifier r; constant c; @@
-T r = expr;
... when != r
when strict
-return r;
+return expr;
Staging: rtl8192u: Convert use of __constant_<foo> to <foo>
Using functions of the form __constant_<foo> isn't preferred
outside of include/uapi/ as using the function without
__constant_ is identical when the argument is a constant.
So, this patch replaces __constant_htons with htons.
This is done using Coccinelle and semantic patch used for
this is as follows:
Use timer API function del_timer_sync instead of driver
specific function _cancel_timer as besides deactivating
a timer, it also ensures that the timer is stopped on all
CPUs before the driver exists. Also, variables
timer_cancelled and bool are removed as they are no longer
needed.
Staging: rtl8712: Eliminate use of _cancel_timer_ex
Use timer API function del_timer_sync instead of driver
specific function _cancel_timer_ex as besides deactivating
a timer, it ensures that the timer is stopped on all
CPUs before the driver exists. Also, definition of function
_cancel_timer_ex is removed as it is no longer needed after
this change.
This is done using Coccinelle and semantic patch used for
this is as follows:
Haneen Mohammed [Fri, 13 Mar 2015 11:29:30 +0000 (14:29 +0300)]
Staging: comedi: Remove parentheses around right side assignment
Parentheses are not needed around the right hand side of an assignment.
This patch remove parenthese of such occurences. Issue was detected and
solved using the following coccinelle script:
@rule1@
identifier x, y, z;
expression E1, E2;
@@
(
x = (y == z);
|
x = (E1 == E2);
|
x =
-(
...
-)
;
)
Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Supriya Karanth [Wed, 11 Mar 2015 16:11:00 +0000 (01:11 +0900)]
staging: sm750fb: Add void to function definition with no arguments
Found by checkpatch.pl - ERROR: Bad function definition
A function with no arguments allows for variadic arguments. Add
void in between the empty parentheses to indicate that the function
takes no arguments.
changes made using coccinelle script:
@@
type T;
identifier f;
@@
T f(
+void
) {
...
}
Aya Mahfouz [Tue, 10 Mar 2015 17:04:09 +0000 (19:04 +0200)]
staging: ft1000: ft1000-usb: ft1000_hw.c: adjust function arguments
Handles the following issues:
Removing extra parentheses around function arguments,
Removing unnecessary pointer to pointer casts.
Issues were detected using the following coccinelle script:
@@
expression e;
type t;
identifier f;
@@
f(...,
-(t *)
e
,...)
@@
expression e;
identifier f;
@@
f(...,
&
-(
e
-)
,...)
@@
expression e;
identifier f;
@@
f(...,
-(
e
-)
,...)
Parentheses removal were left to the script. However, there were some
cases that were handled manually. In addition, handling pointer casts
were done manually too because not all replacements generated by the
script were suitable. When pointer casts on function arguments were
in the form:
<func>(...,(<type> *)&<expression>,...)
the replacements were discarded due to compilation warnings.
Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Aya Mahfouz [Tue, 10 Mar 2015 17:03:18 +0000 (19:03 +0200)]
staging: ft1000: ft1000-usb: ft1000_download.c: adjust function arguments
Handles the following issues:
Removing extra parentheses around function arguments,
Removing unnecessary pointer to pointer cast.
Issues were detected using the following coccinelle script:
@@
expression e;
type t;
identifier f;
@@
f(...,
-(t *)
e
,...)
@@
expression e;
identifier f;
@@
f(...,
&
-(
e
-)
,...)
@@
expression e;
identifier f;
@@
f(...,
-(
e
-)
,...)
Parentheses removal were left to the script. However, handling pointer
casts were done manually because not all replacements generated by the
script were suitable. In general, the following cases were discarded:
pointer casts in macros,
pointer casts on function arguments in the form of:
<func>(...,(<type> *)&<expression>,...)
since both cases generated compilation warnings.
Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Aya Mahfouz [Tue, 10 Mar 2015 17:02:29 +0000 (19:02 +0200)]
staging: ft1000: ft1000-usb: adjust function arguments
Handles the following issues:
Removing extra parentheses around function arguments,
Removing unnecessary pointer to pointer cast.
Issues were detected using the following coccinelle script:
@@
expression e;
type t;
identifier f;
@@
f(...,
-(t *)
e
,...)
@@
expression e;
identifier f;
@@
f(...,
&
-(
e
-)
,...)
@@
expression e;
identifier f;
@@
f(...,
-(
e
-)
,...)
Parentheses removal were left to the script. However, handling pointer
casts were done manually because not all replacements generated by the
script were suitable. In general, the following cases were discarded:
pointer casts in macros,
pointer casts on function arguments in the form of:
<func>(...,(<type> *)&<expression>,...)
since both cases generated compilation warnings.
Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Aya Mahfouz [Tue, 10 Mar 2015 17:01:41 +0000 (19:01 +0200)]
staging: ft1000: ft1000-pcmcia: adjust function arguments
Handles the following issues:
Removing extra parentheses around function arguments,
Removing unnecessary pointer to potinter cast.
Issues were detected using the following coccinelle
script:
@@
expression e;
type t;
identifier f;
@@
f(...,
-(t *)
e
,...)
@@
expression e;
identifier f;
@@
f(...,
&
-(
e
-)
,...)
@@
expression e;
identifier f;
@@
f(...,
-(
e
-)
,...)
Parentheses removal were left to the script. However, handling pointer
casts were done manually because not all replacements generated by the
script were suitable. In general, the following cases were discarded:
pointer casts in macros,
pointer casts on function arguments in the form of:
<func>(...,(<type> *)&<expression>,...)
since both cases generated compilation warnings.
Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Aya Mahfouz [Tue, 10 Mar 2015 16:58:00 +0000 (18:58 +0200)]
staging: mt29f_spinand: remove pointer to pointer cast in function argument
Removes unnecessary pointer to pointer cast on function arguments.
It is worth noting that buf is already a u8 pointer.
Issue detected and resolved using the following coccinelle script:
@@
expression e;
type t;
identifier f;
@@
f(...,
-(t *)
e
,...)
Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Somya Anand [Fri, 13 Mar 2015 19:33:10 +0000 (01:03 +0530)]
Staging: lustre: Iterate list using list_for_each_entry
Code using doubly linked list is iterated generally using list_empty and
list_entry functions, but it can be better written using list_for_each_entry
macro.
This patch replaces the while loop containing list_empty and list_entry with
list_for_each_entry and list_for_each_entry_safe. list_for_each_entry is a
macro which is used to iterate over a list of given type. So while loop used to
iterate over a list can be replaced with list_for_each_entry macro. However, if
list_del is used in the loop, then list_for_each_entry_safe is a better choice.
This transformation is done by using the following coccinelle script.
@ rule1 @
expression E1;
identifier I1, I2;
type T;
iterator name list_for_each_entry;
@@
- while (list_empty(&E1) == 0)
+ list_for_each_entry (I1, &E1, I2)
{
...when != T *I1;
- I1 = list_entry(E1.next, T, I2);
...when != list_del(...);
when != list_del_init(...);
}
@ rule2 @
expression E1;
identifier I1, I2;
type T;
iterator name list_for_each_entry_safe;
@@
T *I1;
+ T *tmp;
...
- while (list_empty(&E1) == 0)
+ list_for_each_entry_safe (I1, tmp, &E1, I2)
{
...when != T *I1;
- I1 = list_entry(E1.next, T, I2);
...
}
Haneen Mohammed [Fri, 13 Mar 2015 17:48:53 +0000 (20:48 +0300)]
Staging: lustre: Remove parentheses around right side an assignment
Parentheses are not needed around the right hand side of an assignment.
This patch remove parenthese of such occurenses. Issue was detected and
solved using the following coccinelle script:
@rule1@
identifier x, y, z;
expression E1, E2;
@@
(
x = (y == z);
|
x = (E1 == E2);
|
x =
-(
...
-)
;
)
Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: rtl8192u: Replace printk() with netdev_dbg()
This patch replaces the printk() function with netdev_dbg() in order to
fix the following: "WARNING: printk() should include KERN_ facility level"
and "WARNING: line over 80 characters".
Staging: rtl8192u: Add function to improve code quality
This patch introduces a new function for the authentication response
error check in the ieee80211_rx_frame_softmac() function to fix the
indentation problem. It also adds the iotAction variable in the new
function to fix the "more than 80 characters per line" warning.
Somya Anand [Mon, 9 Mar 2015 13:48:24 +0000 (19:18 +0530)]
Staging: rtl8188eu: Remove redundant local variable
This patch removes a redundant variable "val" and adds
inline return statements. It also adds a default case
to the switch statement which returns 0 to keep the logic
intact.
It also removes a redundant variable "inx" and adds inline
return statements.
This issue is identified by the following coccinelle script.
@@
expression ret;
identifier f;
@@
Somya Anand [Wed, 11 Mar 2015 11:32:12 +0000 (17:02 +0530)]
Staging: dgnc: Remove redundant parentheses
This patch removes the redundant parentheses inorder to make code
simplified. While doing this, the precedence order of the operation
is taken into consideration to keep the logic of the code intact.
Remove FSF address because it's known in the past that it has changed.
Also, remove the pointless "do not change the coding style" comments
because it's one of the reasons why it's in staging and it's quite
contradictory to what it says in TODO. Also, they contain wrong e-mails
of people which are responsible for these drivers - see TODO or
MAINTAINERS for that. We can preserve the original copyright at the top
of the most files because it shows who originally made them.
Dan Carpenter [Tue, 10 Mar 2015 07:39:42 +0000 (10:39 +0300)]
staging: dgnc: off by one in dgnc_mgmt_ioctl()
"dgnc_NumBoards" is the number of initialized elements in the
dgnc_Board[] array so the comparison should be ">=" instead of ">" so we
don't read invalid data. We can remove the special handling of the
empty array now that we've fixed this bug.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
dgnc: Make all lines under 80 characters in dgnc_driver.c
Some of the lines are over 80 characters in dgnc_driver.c so fix them by
moving the comments closer to the code, tidying the comments to make
them smaller, and remove a redundant space after +.
There are a lot double of blank lines in dgnc_cls.c thus remove them to make
the file follow the CodingStyle. Also, remove one blank line at the
end of dgnc_cls.c.
Staging: sm750fb: provide error path for hw_sm750le_setBLANK()
This provides a default path for the switch statement in
hw_sm750le_setBLANK() so that the compiler will not correctly complain
about undefined values being sent to the hardware.
Instead, properly error out if the blank command is unknown by the
driver.
Staging: sm750fb: fix build warning with lynx_accel
Change the return value of lynx_accel to be void, to fix the build
warning, and due to the fact that the function can't seem to fail at
all, and no one cares if it does or not.
Staging: sm750fb: fix build warning with proc_panDisplay
Change the options to the proc_panDisplay function pointer to match the
function pointer that we want to assign to it, in order to remove the
build warning.
Lorenzo Stoakes [Tue, 10 Mar 2015 15:25:47 +0000 (15:25 +0000)]
staging: sm750fb: Cleanup the type of mmio750
This patch assigns the more appropriate void* type to the mmio750 variable
eliminating an unnecessary volatile qualifier in the process. Additionally it
updates parameter types as necessary where those parameters interact with
mmio750, removes unnecessary casts and updates the type of the
lynx_share->pvReg field which is passed to the ddk750_set_mmio method.
As a consequence, this patch fixes the following sparse warning:-
drivers/staging/sm750fb/ddk750_help.c:12:17: warning: incorrect type in assignment (different address spaces)
Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Sudip Mukherjee [Tue, 10 Mar 2015 17:16:52 +0000 (22:46 +0530)]
staging: sm750fb: remove unused functions
removed the functions which were not used anywhere.
it has been build tested also confirmed with git grep that there is
no other reference of these functions.
Sudip Mukherjee [Tue, 10 Mar 2015 08:45:39 +0000 (14:15 +0530)]
staging: sm750fb: fix build failure
for powerpc-allyesconfig build failed with an error of g_option
undeclared. we will get this error on all architecture if MODULE is
not defined. fixed the declaration of g_option.
Sudip Mukherjee [Tue, 10 Mar 2015 08:45:38 +0000 (14:15 +0530)]
staging: sm750fb: fix undeclared function
kbuild test robot reported that for microblaze-allyesconfig
chan_to_field() and lynxfb_ops_set_par() were not defined. These two
functions were defined under CONFIG_PM, so for any archtecture if
CONFIG_PM is not defined we will have this error.
while moving the lynxfb_suspend() function some very obvious
checkpatch errors, like space after comma, space after if, space
before opening brace, were taken care of.
Sudip Mukherjee [Tue, 10 Mar 2015 08:45:35 +0000 (14:15 +0530)]
staging: sm750fb: wrong type for print
mention correct format specifier while printing.
fixes all the build warnings about incorrect argument type while
printing.
since this is a framebuffer device and it should follow what the
framebuffer layer is suggesting in struct fb_fix_screeninfo at
smem_start and mmio_start, so accordingly changed the datatypes of
vidmem_start, vidreg_start, vidmem_size and vidreg_size.
This patch removes the IEEE80211_PRINT_STR macro definition because it appears
only in the header file and it doesn't serve any purpose in this context.
Variable len is used only to store the return value. Hence len is
removed and the return statement modified. Coccinelle was used to
detect such removable variables:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
Signed-off-by: Tina Johnson <tinajohnson.1234@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Variable len is used only to store the return value. Hence len is
removed and the return statement modified. Coccinelle was used to
detect such removable variables:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
Signed-off-by: Tina Johnson <tinajohnson.1234@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Variable ret is used only to store the error code to be returned.
Hence use of ret is removed and the return statement modified.
Coccinelle was used to prepare the patch:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
Signed-off-by: Tina Johnson <tinajohnson.1234@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Variable ret is used only to store the return value. Hence ret is
removed and the return statement modified. Coccinelle was used to
detect such removable variables:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
Signed-off-by: Tina Johnson <tinajohnson.1234@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Variable ret is used only to store the return value. Hence ret is
removed and the return statement modified. Coccinelle was used to
detect such removable variables:
@rule1@
identifier ret;
expression e;
@@
-ret =
+return
e;
-return ret;
Signed-off-by: Tina Johnson <tinajohnson.1234@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>