From: Rehas Sachdeva <aquannie@gmail.com>
To: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Cc: outreachy-kernel@googlegroups.com,
Julia Lawall <julia.lawall@lip6.fr>,
Bryan O'Donoghue <pure.logic@nexus-software.ie>,
Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [Outreachy kernel] [Outreachy Kernel] [PATCH] staging: greybus: Constify local struct gb_loopback_stats
Date: Mon, 3 Oct 2016 16:14:14 +0530 [thread overview]
Message-ID: <20161003104414.GA18762@toblerone> (raw)
In-Reply-To: <1475489763.28319.85.camel@nexus-software.ie>
On Mon, Oct 03, 2016 at 11:16:03AM +0100, Bryan O'Donoghue wrote:
> On Sun, 2016-10-02 at 21:36 +0200, Julia Lawall wrote:
> >
> > On Mon, 3 Oct 2016, Rehas Sachdeva wrote:
> >
> > > The local declaration "struct gb_loopback_stats reset" is not
> > modified
> > > throughout its scope and hence can be made const. Done using
> > Coccinelle.
> > >
> > > Signed-off-by: Rehas Sachdeva <aquannie@gmail.com>
> > > ---
> > >� drivers/staging/greybus/loopback.c | 2 +-
> > >� 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/staging/greybus/loopback.c
> > b/drivers/staging/greybus/loopback.c
> > > index 7882306..fb5a068 100644
> > > --- a/drivers/staging/greybus/loopback.c
> > > +++ b/drivers/staging/greybus/loopback.c
> > > @@ -837,7 +837,7 @@ static int gb_loopback_request_handler(struct
> > gb_operation *operation)
> > >
> > >� static void gb_loopback_reset_stats(struct gb_loopback *gb)
> > >� {
> > > -�����struct gb_loopback_stats reset = {
> > > +�����const struct gb_loopback_stats reset = {
> >
> > Should it also be static?� I recall this comment being made in
> > another
> > case, but I don't know what the tradeoffs are.
>
Yes it can be static too, since we are not updating it, so we don't care
if its value is retained in subsequent function calls. I agree with Bryan that
we might as well make all locally scoped const variables static too.
Making it static decreases the size of text segment, without affecting any
other segment. I don't know if its particularly useful.
Rehas
> const yes agree - good catch.
>
> static ... can't see a reason why TBH. Making this variable static we
> might as well declare all locally scoped variables static.
>
> ---
> bod
next prev parent reply other threads:[~2016-10-03 10:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-02 19:22 [Outreachy Kernel] [PATCH] staging: greybus: Constify local struct gb_loopback_stats Rehas Sachdeva
2016-10-02 19:36 ` [Outreachy kernel] " Julia Lawall
2016-10-03 10:14 ` Greg Kroah-Hartman
[not found] ` <1475489763.28319.85.camel@nexus-software.ie>
2016-10-03 10:44 ` Rehas Sachdeva [this message]
[not found] ` <1475497775.28319.95.camel@nexus-software.ie>
2016-10-03 14:37 ` Julia Lawall
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=20161003104414.GA18762@toblerone \
--to=aquannie@gmail.com \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=julia.lawall@lip6.fr \
--cc=outreachy-kernel@googlegroups.com \
--cc=pure.logic@nexus-software.ie \
/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.