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 898CFC433EF for ; Thu, 3 Mar 2022 21:18:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 403D583D22; Thu, 3 Mar 2022 22:16:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="NetVe0fr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 321F383D80; Thu, 3 Mar 2022 22:16:52 +0100 (CET) Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D43CC83B5B for ; Thu, 3 Mar 2022 22:16:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ej1-x635.google.com with SMTP id p15so13370792ejc.7 for ; Thu, 03 Mar 2022 13:16:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :references:content-language:in-reply-to:content-transfer-encoding; bh=BNxZ28KXcmDLt7ImJxYSNFLeqXMPWUt14mObXyYSKdY=; b=NetVe0frkipwuaXPNwtK+pQcO63HAeZe755qa8ZOKQwRFo/XNHxnjqKvpWFbklohSC qiGLqoMXpnleGCzWlRvQZTvCaA6pYKj/RHp9kL63C8yFMgIimGaTBU8i6GXg0Yet4uGy MVEWK2tgRvVYb59LC6GCaCnEoy6bwd2X8v3dswrQSPgL5W5El8PRixxG2a10tQ1V6hLc pggnItU+mbWsORaS1e1S9v69xwsReJpy4vPmupdhvMahI3YULnTqHdQTGdpSbsF0tGNY 51plqC5V12/PAOq4XJ2ocXTl+PYKY8aNasWk1Ae1IeHSahj8alm3vi07tbIRX6PR+llk epMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:references:content-language:in-reply-to :content-transfer-encoding; bh=BNxZ28KXcmDLt7ImJxYSNFLeqXMPWUt14mObXyYSKdY=; b=Qb9Da5xwWeqY+6IjJdnumE7ZjNujK6VF3+D7t+JMcr7HGaWiVT5NBFMrxNMFIWIMTR bjeYvH/oIM9rixA01fCKeWsBlykASvIfaMPI5RxZMSsLeYCks1sIWKEZ1jJLBViUYOdR yuWXWkJWEJxW7IC3/RXS/BDE/rk3xCoFIIMGtaUtzG9C7K8HMojePU2BFfOxeVaI+gmO 9qcR/kAnVLagYHqsH42FJ8uQlRE4jzrqGHtdPlq0KsciCfltpiy3cYvN+AHoJ5+TOgKx UR0YdFMrotQwRWmpbpi8swtd5Uta67laYAG7CKfNTsU0O7ThnmD5bZhZppKMOWmth6w+ bv5Q== X-Gm-Message-State: AOAM530nEiBKQ/JaYSEckWSI5vScyfe4uyghu5wEDVXx+w0QQCCDjRbj BF6vmXscHJneH6QUzEqtoEw= X-Google-Smtp-Source: ABdhPJwMi2NFpmZSCE2DjQTkmdO5ku92gLrkttBwznpbFpH774I4aWBY0UHj8ce4EmxG3NKjtTtxaw== X-Received: by 2002:a17:906:1e94:b0:6cc:4382:f12e with SMTP id e20-20020a1709061e9400b006cc4382f12emr29047510ejj.482.1646342207479; Thu, 03 Mar 2022 13:16:47 -0800 (PST) Received: from [192.168.0.74] ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id z8-20020a170906270800b006bbd3efa6b8sm1064790ejc.80.2022.03.03.13.16.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Mar 2022 13:16:46 -0800 (PST) Message-ID: <8b9233e4-1106-3a09-5395-7488a9cb917a@gmail.com> Date: Fri, 4 Mar 2022 00:10:16 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 From: Alper Nebi Yasak Subject: Re: [PATCH v2 17/25] binman: Add a consistent way to report errors with fit To: Simon Glass Cc: Ivan Mikhaylov , Tom Rini , Philippe Reynes , huang lin , Jeffy Chen , Kever Yang , U-Boot Mailing List References: <20220223230040.159317-1-sjg@chromium.org> <20220223230040.159317-18-sjg@chromium.org> Content-Language: en-US In-Reply-To: <20220223230040.159317-18-sjg@chromium.org> Content-Type: text/plain; charset=UTF-8 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 24/02/2022 02:00, Simon Glass wrote: > Add a new function to handling reporting errors within a particular > subnode of the FIT description. This can be used to make the format of > these errors consistent. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > tools/binman/etype/fit.py | 33 +++++++++++++++++++++++++-------- > tools/binman/ftest.py | 2 +- > 2 files changed, 26 insertions(+), 9 deletions(-) Reviewed-by: Alper Nebi Yasak I don't like entry.Raise(msg) in general, if it were me I would define Exception subclasses and e.g. raise CustomError(self, subnode) for the various error conditions, but that's beside the point. > diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py > index 70966028e8..50a9179f9f 100644 > --- a/tools/binman/etype/fit.py > +++ b/tools/binman/etype/fit.py > [...] > @@ -273,6 +274,20 @@ class Entry_fit(Entry_section): > > return tools.read_file(output_fname) > > + def _raise(self, base_node, node, msg): > + """Raise an error with a paticular FIT subnode > + > + Args: > + base_node (Node): Base Node of the FIT (with 'description' property) > + node (Node): FIT subnode containing the error > + msg (str): Message to report > + > + Raises: > + ValueError, as requested > + """ > + rel_path = node.path[len(base_node.path) + 1:] Can base_node be anything except self._node here, why not use that? > + self.Raise(f"subnode '{rel_path}': {msg}") The names are a bit inconsistent, but I guess you intend to change Entry.Raise() to Entry._raise() later on... > + > def _build_input(self): > """Finish the FIT by adding the 'data' properties to it > > [...]