From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E59E1C2BA4C for ; Wed, 26 Jan 2022 09:55:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 241308309D; Wed, 26 Jan 2022 10:55:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=tq-group.com header.i=@tq-group.com header.b="gy+OrpJv"; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.b="dfIDQ111"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4104E830CE; Wed, 26 Jan 2022 10:54:59 +0100 (CET) Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5C34A80F9E for ; Wed, 26 Jan 2022 10:54:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=matthias.schiffer@ew.tq-group.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1643190896; x=1674726896; h=message-id:subject:from:to:date:in-reply-to:references: mime-version:content-transfer-encoding; bh=sPG5z0thNHOKIaoAkis60HAxB6FwgqQsYOqO88iAT7k=; b=gy+OrpJv2A/wgYdyl77FrGQRgiiBwuZdYOqJnr+cdV8TnJkPJ4Shsn5L c6nCGaVSLLs7iU5Arsw9baLRDSMqqrJdutR554IM8n2yuh310duHTPigg NaYIN3cKNMkrzyjkVTjZtULc3taRdsck7fcpmxd5jD4dcnN9GnGede4DI vnhliDdu5Fs30vtYcaDudeZA6WjwguU8vi3wVLObbra9RZfJ8z7Fsics/ EmZvc5mr3+D/vR6CtVmOVuGmn9phSMFJN6HDbKE7Bp1/bUwHOExJl5iRo 5bqIXJaW2eiHG+fI4p94ZPQIPdgDYzsLwciC4arX16JXV8/ECiUB3pLpi Q==; X-IronPort-AV: E=Sophos;i="5.88,317,1635199200"; d="scan'208";a="21717590" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 26 Jan 2022 10:54:55 +0100 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Wed, 26 Jan 2022 10:54:55 +0100 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Wed, 26 Jan 2022 10:54:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1643190895; x=1674726895; h=message-id:subject:from:to:date:in-reply-to:references: mime-version:content-transfer-encoding; bh=sPG5z0thNHOKIaoAkis60HAxB6FwgqQsYOqO88iAT7k=; b=dfIDQ111AEUHDGOV58dzep17c8LpjSCeSR1xgew3+aNFjW4F77/FKIB1 N20ObjfrXk0fdn2IrvfzXKQLPJ63rr3HmmFTFHDSp8NtwnY/6o8GWOHn9 qXmJZfjVxx0jrOq6AnWpVu3l9BSdAqlGWeZETKojL2W58mpZo7OLo0bJX kxxtxPmeViJ//o/BYwCk72A8YltOBYWMWkM0mzhRSwapyP1wFd+KMBHzR OkAUIaSCbyBvuq2Mkf8MoHuSDqXzHea7YtUsdR+BgEh8lSI1VlFa2aGca tL+qXmLlnfSnwgkbcjESoX1JFWKBtw1ovC+thNzPsktpZ1l3/sD0OFwiY w==; X-IronPort-AV: E=Sophos;i="5.88,317,1635199200"; d="scan'208";a="21717589" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 26 Jan 2022 10:54:55 +0100 Received: from schifferm-ubuntu (SCHIFFERM-M2.tq-net.de [10.121.201.138]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id 22CB3280065; Wed, 26 Jan 2022 10:54:55 +0100 (CET) Message-ID: <7df14f127c28ecf6f3cc389820066fb898a630ac.camel@ew.tq-group.com> Subject: Re: [PATCH] fastboot: only look up real partition names when no alias exists From: Matthias Schiffer To: Sean Anderson , u-boot@lists.denx.de Date: Wed, 26 Jan 2022 10:54:52 +0100 In-Reply-To: <5759d408-e876-9444-d14a-22bb37aecc14@seco.com> References: <20211216102638.111391-1-matthias.schiffer@ew.tq-group.com> <5759d408-e876-9444-d14a-22bb37aecc14@seco.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Fri, 2021-12-17 at 18:20 -0500, Sean Anderson wrote: > Hi Matthias, > > On 12/16/21 5:26 AM, Matthias Schiffer wrote: > > Having U-Boot look up the passed partition name even though an > > alias > > exists is unexpected, leading to warning messages (when the alias > > name > > doesn't exist as a real partition name) or the use of the wrong > > partition. > > > > Change part_get_info_by_name_or_alias() to consider real partitions > > names only if no alias of the same name exists, allowing to use > > aliases > > to override the configuration for existing partition names. > > Much saner IMO. > > I think the correct move in the long term is to add a "quiet" > parameter to do_get_part_info (and all its helpers). This is OK as an > incremental improvement. > > > Also change one use of strcpy() to strlcpy(). > > > > Signed-off-by: Matthias Schiffer > > > > --- > > drivers/fastboot/fb_mmc.c | 29 ++++++++++++----------------- > > 1 file changed, 12 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c > > index 2738dc836e..fb7791d9da 100644 > > --- a/drivers/fastboot/fb_mmc.c > > +++ b/drivers/fastboot/fb_mmc.c > > @@ -104,23 +104,18 @@ static int > > part_get_info_by_name_or_alias(struct blk_desc **dev_desc, > > const char *name, > > struct disk_partition *info) > > { > > - int ret; > > - > > - ret = do_get_part_info(dev_desc, name, info); > > - if (ret < 0) { > > - /* strlen("fastboot_partition_alias_") + PART_NAME_LEN > > + 1 */ > > - char env_alias_name[25 + PART_NAME_LEN + 1]; > > - char *aliased_part_name; > > - > > - /* check for alias */ > > - strcpy(env_alias_name, "fastboot_partition_alias_"); > > - strlcat(env_alias_name, name, sizeof(env_alias_name)); > > - aliased_part_name = env_get(env_alias_name); > > - if (aliased_part_name != NULL) > > - ret = do_get_part_info(dev_desc, > > aliased_part_name, > > - info); > > - } > > - return ret; > > + /* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */ > > + char env_alias_name[25 + PART_NAME_LEN + 1]; > > + char *aliased_part_name; > > + > > + /* check for alias */ > > + strlcpy(env_alias_name, "fastboot_partition_alias_", > > sizeof(env_alias_name)); > > + strlcat(env_alias_name, name, sizeof(env_alias_name)); > > + aliased_part_name = env_get(env_alias_name); > > + if (aliased_part_name) > > + name = aliased_part_name; > > + > > + return do_get_part_info(dev_desc, name, info); > > } > > > > /** > > > > Reviewed-by: Sean Anderson > > --Sean Can we get this committed? Kind regards, Matthias