From patchwork Sun Aug 1 21:00:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1512141 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=fD9JS8VL; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4GdD8q0q2xz9sW5 for ; Mon, 2 Aug 2021 07:02:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7A2BC83338; Sun, 1 Aug 2021 23:01:10 +0200 (CEST) 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="fD9JS8VL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0243283314; Sun, 1 Aug 2021 23:00:52 +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.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) (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 C6021832F6 for ; Sun, 1 Aug 2021 23:00:47 +0200 (CEST) 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@chromium.org Received: by mail-ot1-x331.google.com with SMTP id z6-20020a9d24860000b02904d14e47202cso6944089ota.4 for ; Sun, 01 Aug 2021 14:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b8ETa0O+YD2zqbhrHRx8zl6PSIEujGZ6HCC+C5HiH/A=; b=fD9JS8VLGmkNT1FGuMcik4sGGNnFLZmFwKuAGyQGvePBaXFNjersVtkntqzfWPUh0S GTTtUiwaz3UfFxjq/PG2vaQTAVbk5Fg1DnZSU3oe21IefzGkQH4Pr0Fq8fjqxN7R3IKG sx7cqrdvKl3j4wtG7TvIkzC+B+UMUsNOpc+EE= 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=b8ETa0O+YD2zqbhrHRx8zl6PSIEujGZ6HCC+C5HiH/A=; b=mVK78BsHwLC7oUR15231Ns8PsbHcsjxw0AJRCyxNzfaIboTNbmh280Hzr/7TjDd+yX hsXMwZkXCtOwo3xLBcD7mtfyE+PgmhtH2z/1KRuK+UWA9VeiPlA38EWaQXZwSxn6SNy0 f0UD8Fs8bfKcXYM4CMHNNK9x7AF5Zzx/iVeFg38aoJK0WOlE5JiS6RZj1vosqmoKEMip 2DP9ji7n3QPucDjHMDDECUOjxWO/rarT+OSZ+QjLY0jF/hD7FFZCWhA1dW6XmjLxD4UB /ocQo2e/lNt7N7m3VgW+kFJQs1b446GevzwkRpqkq7iDg8EuwQbiixr9Fxxt3SppYIIF e19A== X-Gm-Message-State: AOAM530EHWX335RHxrlTnKblSKcmTQRJvXHL55mqZvtwHjrgS/gX14Fv kigxNPgJSWhksy4SwBPCgL8iU5R4vFn1dY0F X-Google-Smtp-Source: ABdhPJy89wQfzOAom0g99hNffXNye1oo9n4tGh4pvyA8F2ZHJ9lz4UikcRN3bYP3MOAYF21AVOiUsA== X-Received: by 2002:a05:6830:2909:: with SMTP id z9mr9496336otu.131.1627851646281; Sun, 01 Aug 2021 14:00:46 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id s16sm1560707otg.51.2021.08.01.14.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Aug 2021 14:00:45 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Bin Meng , Tom Rini , Alexandru Gagniuc , Simon Glass , Joe Hershberger , Marek Vasut Subject: [PATCH v3 06/15] image: Avoid switch default in image_decomp() Date: Sun, 1 Aug 2021 15:00:23 -0600 Message-Id: <20210801150024.v3.6.Ieb772c007c48b64bcd9e162f57191522edf964ba@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210801210032.2203104-1-sjg@chromium.org> References: <20210801210032.2203104-1-sjg@chromium.org> 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 At present this function is full of preprocessor macros. Adjust it to check for an unsupported algorithm after the switch(). This will allow us to drop the macros. Fix up the return-value path and an extra blank line while we are here. Signed-off-by: Simon Glass --- (no changes since v1) common/image.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/image.c b/common/image.c index 062e08886fd..6c38211efce 100644 --- a/common/image.c +++ b/common/image.c @@ -444,7 +444,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, void *load_buf, void *image_buf, ulong image_len, uint unc_len, ulong *load_end) { - int ret = 0; + int ret = -ENOSYS; *load_end = load; print_decomp_msg(comp, type, load == image_start); @@ -456,6 +456,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, */ switch (comp) { case IH_COMP_NONE: + ret = 0; if (load == image_start) break; if (image_len <= unc_len) @@ -537,22 +538,23 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, } image_len = ret; - break; } #endif /* CONFIG_ZSTD */ #endif - default: + } + if (ret == -ENOSYS) { printf("Unimplemented compression type %d\n", comp); - return -ENOSYS; + return ret; } + if (ret) + return ret; *load_end = load + image_len; - return ret; + return 0; } - #ifndef USE_HOSTCC #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT) /**