Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging: rtl8192e: rtl_core: Constify rtllib_qos_parameters structures

Declare the structure rtllib_qos_parameters as constant as it is only
passed as the second argument to the function memcpy. This argument
is constant so the fields of rtllib_qos_parameters structure are
never modified and hence it can be declared as const.
Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct rtllib_qos_parameters i@p = {...};

@ok1@
identifier r1.i;
position p;
expression e1,e2;
@@
memcpy(e1,&i@p,e2)

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct rtllib_qos_parameters i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct rtllib_qos_parameters i;

File size before:
text data bss dec hex filename
30910 496 201 31607 7b77
drivers/staging/rtl8192e/rtl8192e/rtl_core.o

File size after:
text data bss dec hex filename
30942 464 201 31607 7b77
drivers/staging/rtl8192e/rtl8192e/rtl_core.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Bhumika Goyal and committed by
Greg Kroah-Hartman
67f9dcb1 9ab9d452

+1 -1
+1 -1
drivers/staging/rtl8192e/rtl8192e/rtl_core.c
··· 367 367 } 368 368 } 369 369 370 - static struct rtllib_qos_parameters def_qos_parameters = { 370 + static const struct rtllib_qos_parameters def_qos_parameters = { 371 371 {cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3)}, 372 372 {cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7)}, 373 373 {2, 2, 2, 2},