From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peng Fan Date: Wed, 22 May 2019 07:08:14 +0000 Subject: [U-Boot] [PATCH V2 3/3] drivers: core: use strcmp when find device by name In-Reply-To: <20190522072201.5130-1-peng.fan@nxp.com> References: <20190522072201.5130-1-peng.fan@nxp.com> Message-ID: <20190522072201.5130-3-peng.fan@nxp.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de `if (!strncmp(dev->name, name, strlen(name)))` might find out the wrong device, it might find out `dram_pll_ref_sel`, when name is `dram_pll`. So use strcmp to avoid such issue. Signed-off-by: Peng Fan Reviewed-by: Simon Glass --- V2: None drivers/core/uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index fc3157de39..e2f35393a9 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -260,7 +260,7 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name, return ret; uclass_foreach_dev(dev, uc) { - if (!strncmp(dev->name, name, strlen(name))) { + if (!strcmp(dev->name, name)) { *devp = dev; return 0; } -- 2.16.4