From patchwork Fri Sep 3 13:16:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 1524299 X-Patchwork-Delegate: twarren@nvidia.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=GVtqgX9p; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H1JH12WFLz9sCD for ; Fri, 3 Sep 2021 23:17:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4981D83570; Fri, 3 Sep 2021 15:16:44 +0200 (CEST) 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="GVtqgX9p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D0D64834D0; Fri, 3 Sep 2021 15:16:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (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 E891683503 for ; Fri, 3 Sep 2021 15:16:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=thierry.reding@gmail.com Received: by mail-wr1-x430.google.com with SMTP id i6so8215932wrv.2 for ; Fri, 03 Sep 2021 06:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HjE7na0VAScrRFHCmq4AhaeuwGHwUR3uNkcyuFGC4Wg=; b=GVtqgX9p8BihyRfkjZm55R5U45y9f4PHrei9XejKnE+e5EUyjM9ihf2fjHLSZPW66f WQPvZqyG/jFmDdDcU87Bgvi7Q4k/o5aPVqx08yYSG+RCnMWVy+iILrO4ZQvB9P41LtSg yCR3QFQP6NChLV8p9+QvfQN38K2vRSmSvL9Hqoj5uR3Z1/uXrLieE9e7GHALjUITbHeI bmWfA3LKW0DxGZoWeWhTkZnjE7W6UzbpFuX67ICKK2tsIRU6e4ok60wVUMw0a7L+1MxE poABxE3QBz8v6dpKTJB+tY839+BKdxfztAsg04t160YWRLjZKVqvqgqXs1Ssb8zdDPjb q9xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HjE7na0VAScrRFHCmq4AhaeuwGHwUR3uNkcyuFGC4Wg=; b=GXgZp9cgJrV4XgEq3U0ekaJJ8yJ8deFLigTKjbuNcYFyFgwO0IwUAPzal4+T3QrInz DCAvsygNOP4NrtJFyHQQ3Uf75l2HHHwbJ9OBlnZZioGbb8pn5rGxD+HWW+TkYRUkm7wL SB4ce70vSQtd3VCqa7yF4do1lXpUb2Sv2rRDNcA8gnlAWT7r1EODuTEtbYyl0yhAWog/ p/oAL8kxfTKL6eKvQxhXzWzv052T+aKyNQq71dqVFNRgShzUNCEKsMBuBX6WontYyFih jiShJv8u2Vnx4MCcmUFc4E8/hVRgv5Fk81yqCsu5S/uY6VNLslh5yp/9pAtcQ2ZNvhZc ucKw== X-Gm-Message-State: AOAM530ecGKFoVfwGJC0mA71rObD02J8o5mT6goLP4s9rNThJU3iy/4q MKfuPgmuMTojtO83kgIJOWE= X-Google-Smtp-Source: ABdhPJxLbP3jub5/5d8Qd/hzS1lCDchvbFdk3YJIPJEc4EQdEhNvP86PMxTHewLZEMgsLmCxXAMd4g== X-Received: by 2002:adf:90d0:: with SMTP id i74mr4017874wri.185.1630674994529; Fri, 03 Sep 2021 06:16:34 -0700 (PDT) Received: from localhost ([217.111.27.204]) by smtp.gmail.com with ESMTPSA id q10sm4244467wmq.12.2021.09.03.06.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:16:33 -0700 (PDT) From: Thierry Reding To: Tom Warren Cc: Simon Glass , u-boot@lists.denx.de Subject: [PATCH 1/9] fdtdec: Allow using fdtdec_get_carveout() in loops Date: Fri, 3 Sep 2021 15:16:17 +0200 Message-Id: <20210903131625.2153838-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210903131625.2153838-1-thierry.reding@gmail.com> References: <20210903131625.2153838-1-thierry.reding@gmail.com> MIME-Version: 1.0 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 From: Thierry Reding In order make it possible to use fdtdec_get_carveout() in loops, return FDT_ERR_NOTFOUND when the passed-in index exceeds the number of phandles present in the given property. Signed-off-by: Thierry Reding Reviewed-by: Simon Glass --- lib/fdtdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 337c4443b032..7f6b6d523232 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1469,7 +1469,7 @@ int fdtdec_get_carveout(const void *blob, const char *node, const char *name, if (len < (sizeof(phandle) * (index + 1))) { debug("invalid phandle index\n"); - return -FDT_ERR_BADPHANDLE; + return -FDT_ERR_NOTFOUND; } phandle = fdt32_to_cpu(prop[index]);