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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 17E5DC433EF for ; Fri, 3 Sep 2021 13:16:59 +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 7049760FDC for ; Fri, 3 Sep 2021 13:16:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7049760FDC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 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) 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 Content-Transfer-Encoding: 8bit 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 --- 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]); -- 2.33.0