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 67295C433EF for ; Sun, 6 Mar 2022 03:09:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 076D183BE5; Sun, 6 Mar 2022 04:08:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="QD4w73Hw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6624083B8D; Sun, 6 Mar 2022 04:08:32 +0100 (CET) Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) (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 D1C5E83B6C for ; Sun, 6 Mar 2022 04:08:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ot1-x32d.google.com with SMTP id w17-20020a056830111100b005b22c584b93so384312otq.11 for ; Sat, 05 Mar 2022 19:08:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Qgf1tz/e0X2AL4kCkf/3TXFWolulWILBubmVtoWEYCc=; b=QD4w73HwmuBu5pqXbF24UFUMVvnVVtA/DrMAjkWc6oM5EDg6KnIh4cvDD2RQx4USqP c8TWMMFtVf9GxGJRYA4icni5L6KFRVZKybk1dCc4L+ZkDgJaE5+v3bOBBFGNjtQG5nNb sJgPDzuNKltny9HccbjXf4DW0+l4TfT4p5glo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Qgf1tz/e0X2AL4kCkf/3TXFWolulWILBubmVtoWEYCc=; b=fIfoKJUQ4bArQF29LPaDRSontBTHsBvnImxA1gMamIyfh6sJwtiXkzznRdTT7oabhN xW1EpsmFkgrUX3k7NahMCawn/gFVUlbPhWL+SYGn+DXNh/PJjdlZoIkTg5drK/RJ+00I YAAr7VEMWwyxMMURmm5JPUFFj0v5AYUwNaJ63BjyncsUWh6VGkxApuAnZCzFDgt3MYjo 92mTu66qr1C7T5Mc+Tqi9fiQPhqackhWmxV5bVTEO0yVtsugEMU3a8a8N1NC+/0hKb7V mR7yBmUvOUfygcorefaIk+uxnkT6OmkTQecUEpzqlqCYrWrcCeuIqSeoNSFuDXGs5MLl TNmg== X-Gm-Message-State: AOAM533rfSVTF0J0KCfmMQznJ0uNEc2NvGlBMeYie9ZyJBXYSPMeVqxP e+Eqpb2xUlyr91X8yixhHBgervgIK49heDrbF9khgg== X-Google-Smtp-Source: ABdhPJwnTZmGHvwbarGm97GB2UisFirMudYm6O49x3D5xetSbwn0Bpp0UP6P6onD+J6tcCmiTCb5Rirb/j+2vvX5paM= X-Received: by 2002:a9d:20ca:0:b0:5ad:3241:47f0 with SMTP id x68-20020a9d20ca000000b005ad324147f0mr2715025ota.269.1646536104147; Sat, 05 Mar 2022 19:08:24 -0800 (PST) MIME-Version: 1.0 References: <20220223230040.159317-1-sjg@chromium.org> <20220223230040.159317-18-sjg@chromium.org> <8b9233e4-1106-3a09-5395-7488a9cb917a@gmail.com> In-Reply-To: <8b9233e4-1106-3a09-5395-7488a9cb917a@gmail.com> From: Simon Glass Date: Sat, 5 Mar 2022 20:08:11 -0700 Message-ID: Subject: Re: [PATCH v2 17/25] binman: Add a consistent way to report errors with fit To: Alper Nebi Yasak Cc: Ivan Mikhaylov , Tom Rini , Philippe Reynes , huang lin , Jeffy Chen , Kever Yang , U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" 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 Hi Alper, On Thu, 3 Mar 2022 at 14:16, Alper Nebi Yasak wrote: > > 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. I have so far stuck with ValueError as I find the need to import classes to raise an exception a pain. But I suppose that would be OK. > > > 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? OK I fixed 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... Well I was planning to change Raise() to raise(), so I'll rename this raise_subnode() > > > + > > def _build_input(self): > > """Finish the FIT by adding the 'data' properties to it > > > > [...] Regards, Simon