All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhumika Goyal <bhumirks@gmail.com>
To: outreachy-kernel@googlegroups.com, gregkh@linuxfoundation.org
Cc: Bhumika Goyal <bhumirks@gmail.com>
Subject: [PATCH] Staging: rtl8192e: rtl_core: Constify rtllib_qos_parameters structures
Date: Tue,  4 Oct 2016 23:22:36 +0530	[thread overview]
Message-ID: <1475603556-21698-1-git-send-email-bhumirks@gmail.com> (raw)

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>
---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 4c30eea..f985d88 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -367,7 +367,7 @@ static void _rtl92e_update_cap(struct net_device *dev, u16 cap)
 	}
 }
 
-static struct rtllib_qos_parameters def_qos_parameters = {
+static const struct rtllib_qos_parameters def_qos_parameters = {
 	{cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3)},
 	{cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7)},
 	{2, 2, 2, 2},
-- 
1.9.1



                 reply	other threads:[~2016-10-04 17:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475603556-21698-1-git-send-email-bhumirks@gmail.com \
    --to=bhumirks@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.