Linux-PM Archive mirror
 help / color / mirror / Atom feed
From: Julian Calaby <julian.calaby@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Yangtao Li <tiny.windzz@gmail.com>,  Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	 Samuel Holland <samuel@sholland.org>,
	linux-pm@vger.kernel.org,
	 Vincent Guittot <vincent.guittot@linaro.org>,
	kernel test robot <lkp@intel.com>,
	 linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq: sun50i: Fix build warning around snprint()
Date: Tue, 23 Apr 2024 16:28:17 +1000	[thread overview]
Message-ID: <CAGRGNgWH7PW4fgMOYtEVohrPq0MVusKFOpF8GXCbMDA5D7BScA@mail.gmail.com> (raw)
In-Reply-To: <20240423061253.blyfuqasyiatm5sa@vireshk-i7>

Hi Viresh,

On Tue, Apr 23, 2024 at 4:12 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 23-04-24, 11:38, Julian Calaby wrote:
> > On Mon, Apr 22, 2024 at 1:31 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > > diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > index 30e5c337611c..cd50cea16a87 100644
> > > --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > @@ -208,7 +206,7 @@ static int sun50i_cpufreq_get_efuse(void)
> > >  static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
> > >  {
> > >         int *opp_tokens;
> > > -       char name[MAX_NAME_LEN];
> > > +       char name[] = "speedXXXXXXXXXXX"; /* Integers can take 11 chars max */
> >
> > Would it make sense to just set a static length for the string here,
> > say 17-20 characters and add a comment explaining the number, say: /*
> > "speed" + 11 chars for the int */
> >
> > The string constant, while it'll probably be optimised away, seems
> > weird and wasteful.
>
> The counting goes wrong (I have done it in the past) sometimes and so
> I like to explicitly reserve space like this, it also makes it look
> cleaner, i.e. how the eventual string will be named.

I completely agree - ultimately it's whatever works and either way
works equally well.

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

      reply	other threads:[~2024-04-23  6:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22  3:31 [PATCH] cpufreq: sun50i: Fix build warning around snprint() Viresh Kumar
2024-04-22  6:27 ` Chen-Yu Tsai
2024-04-22 22:39 ` Andre Przywara
2024-04-23  1:38 ` Julian Calaby
2024-04-23  6:12   ` Viresh Kumar
2024-04-23  6:28     ` Julian Calaby [this message]

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=CAGRGNgWH7PW4fgMOYtEVohrPq0MVusKFOpF8GXCbMDA5D7BScA@mail.gmail.com \
    --to=julian.calaby@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=lkp@intel.com \
    --cc=rafael@kernel.org \
    --cc=samuel@sholland.org \
    --cc=tiny.windzz@gmail.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=wens@csie.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).