From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1945979AbcB0JvA (ORCPT ); Sat, 27 Feb 2016 04:51:00 -0500 Received: from mx01-fr.bfs.de ([193.174.231.67]:38085 "EHLO mx01-fr.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756241AbcB0Ju5 (ORCPT ); Sat, 27 Feb 2016 04:50:57 -0500 Message-ID: <56D17170.80408@bfs.de> Date: Sat, 27 Feb 2016 10:50:40 +0100 From: walter harms Reply-To: wharms@bfs.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11 MIME-Version: 1.0 To: Dan Carpenter CC: David Airlie , Alex Deucher , Maruthi Srinivas Bayyavarapu , Jammy Zhou , Murali Krishna Vemuri , Chunming Zhou , 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() References: <20160225074709.GA7333@mwanda> In-Reply-To: <20160225074709.GA7333@mwanda> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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. re, wh