Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECD58C4338F for ; Mon, 2 Aug 2021 02:45:56 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E1AEE60EB2 for ; Mon, 2 Aug 2021 02:45:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E1AEE60EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0C51F83311; Mon, 2 Aug 2021 04:45:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id F36DF8331C; Mon, 2 Aug 2021 04:45:51 +0200 (CEST) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) (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 0830A82DA1 for ; Mon, 2 Aug 2021 04:45:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=wlozano@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: wlozano) with ESMTPSA id 715A91F42381 Subject: Re: [PATCH 1/3] dtoc: Rename is_wider_than() to reduce confusion To: Simon Glass , U-Boot Mailing List Cc: Tom Rini References: <20210729012311.1406847-1-sjg@chromium.org> <20210729012311.1406847-2-sjg@chromium.org> From: Walter Lozano Message-ID: <6e2f5e0d-7d18-92d2-ca82-f4dbabe125d6@collabora.com> Date: Sun, 1 Aug 2021 23:45:41 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210729012311.1406847-2-sjg@chromium.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Hi Simon, Thanks for checking this bug, I'm glad that you were able to come with fix quickly. I have some questions, I hope that you find some time to help me understand. On 7/28/21 10:23 PM, Simon Glass wrote: > The current name is confusing because the logic is actually backwards from > what you might expect. Rename it to needs_widening() and update the > comments. > > Signed-off-by: Simon Glass > --- > > tools/dtoc/fdt.py | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py > index 3996971e39c..9749966d5fb 100644 > --- a/tools/dtoc/fdt.py > +++ b/tools/dtoc/fdt.py > @@ -24,16 +24,19 @@ from patman import tools > > # A list of types we support > class Type(IntEnum): > + # Types in order from widest to narrowest > (BYTE, INT, STRING, BOOL, INT64) = range(5) Sorry but I don't understand why BYTE is wider than INT (or INT64) > > - def is_wider_than(self, other): > - """Check if another type is 'wider' than this one > + def needs_widening(self, other): > + """Check if this type needs widening to hold a value from another type > > - A wider type is one that holds more information than an earlier one, > - similar to the concept of type-widening in C. > + A wider type is one that can hold a wider array of information than > + another one, or is less restrictive, so it can hold the information of > + another type as well as its own. This is similar to the concept of > + type-widening in C. > > This uses a simple arithmetic comparison, since type values are in order > - from narrowest (BYTE) to widest (INT64). > + from widest (BYTE) to narrowest (INT64). > > Args: > other: Other type to compare against > @@ -149,7 +152,7 @@ class Prop: > update the current property to be like the second, since it is less > specific. > """ > - if self.type.is_wider_than(newprop.type): > + if self.type.needs_widening(newprop.type): > if self.type == Type.INT and newprop.type == Type.BYTE: > if type(self.value) == list: > new_value = [] Regards, Walter