From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: David Airlie <airlied@linux.ie>,
Alex Deucher <alexander.deucher@amd.com>,
Maruthi Srinivas Bayyavarapu <Maruthi.Bayyavarapu@amd.com>,
Jammy Zhou <Jammy.Zhou@amd.com>,
Murali Krishna Vemuri <murali-krishna.vemuri@amd.com>,
Chunming Zhou <david1.zhou@amd.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch] drm/amd: cleanup get_mfd_cell_dev()
Date: Sat, 27 Feb 2016 13:40:49 +0300 [thread overview]
Message-ID: <20160227104049.GN5273@mwanda> (raw)
In-Reply-To: <56D17170.80408@bfs.de>
On Sat, Feb 27, 2016 at 10:50:40AM +0100, walter harms wrote:
>
>
> Am 25.02.2016 08:47, schrieb Dan Carpenter:
> > It's simpler to just use snprintf() to print this to one buffer instead
> > of using strcpy() and strcat(). Also using snprintf() is slightly safer
> > than using sprintf().
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> > index 9f8cfaa..d6b0bff 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> > @@ -240,12 +240,10 @@ static int acp_poweron(struct generic_pm_domain *genpd)
> > static struct device *get_mfd_cell_dev(const char *device_name, int r)
> > {
> > char auto_dev_name[25];
> > - char buf[8];
> > struct device *dev;
> >
> > - sprintf(buf, ".%d.auto", r);
> > - strcpy(auto_dev_name, device_name);
> > - strcat(auto_dev_name, buf);
> > + snprintf(auto_dev_name, sizeof(auto_dev_name),
> > + "%s.%d.auto", device_name, r);
> > dev = bus_find_device_by_name(&platform_bus_type, NULL, auto_dev_name);
> > dev_info(dev, "device %s added to pm domain\n", auto_dev_name);
> >
>
> hi,
> i tried to understand what is the base for char auto_dev_name[25]. It is not clear
> from these snipped if that is large or small.
>
> (To be aware i assume that
> get_mfd_cell_dev("terrible_long_and_Stupid_name",1234567899346712) will never happen
> but i could find no reason)
>
> A small comment that explains the magic 25 would be nice.
I have no idea, either of course. For example,
mc13xxx_add_subdevice_pdata() assumes device_name by itself can be 30
characters. Hence the change to snprintf.
regards,
dan carpenter
next prev parent reply other threads:[~2016-02-27 10:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-25 7:47 [patch] drm/amd: cleanup get_mfd_cell_dev() Dan Carpenter
2016-02-26 17:46 ` Alex Deucher
2016-02-27 9:50 ` walter harms
2016-02-27 10:40 ` Dan Carpenter [this message]
2016-02-27 11:18 ` walter harms
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=20160227104049.GN5273@mwanda \
--to=dan.carpenter@oracle.com \
--cc=Jammy.Zhou@amd.com \
--cc=Maruthi.Bayyavarapu@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=david1.zhou@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=murali-krishna.vemuri@amd.com \
--cc=wharms@bfs.de \
/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