Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1825212pxb; Mon, 20 Sep 2021 06:15:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTTwzbsRQNtQQ26zac7YBeDkdwUGJccDmqPUPHUIHEECaUgNyqWP0au+BzkvcVKLENyfd4 X-Received: by 2002:a50:d944:: with SMTP id u4mr16586164edj.327.1632143757051; Mon, 20 Sep 2021 06:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632143757; cv=none; d=google.com; s=arc-20160816; b=C58LUnyfjBm+LbL4b3xjSg34BGhTpFA7zkivNd1rgMQZcOPnhcOACNjWBcsCreSKj7 QBjpO4hg+NlsPMX5QFZVqaid8Uvm+4gB/VF4gHuBpV+EVjzl4geGKAOqrMmnxyVlVU1o dfrZpFZGYocRYUUwJnw1dBAAQdh1YpVjulOit8Mkicwy8kkf4a4fM64BpVdfOnDXCkB9 ksLxyMMARH56yJA19SJm66MXBVaYpBq0xOA7A1gXBkahzC8mWwOkq/c5En53gcdsoPb6 PBgjZLlH0PNgoGmrGojeHGGNa9Z/KjbqwWLwnQC8EZy7Ln2jJIQON+KKMMhyFkYcFjEX YA0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=2ZAOy3NDQ6LVX/GGng9vUoL7C80nYcKaJSkIIf/ejWg=; b=dFscIPEsQNlG5R5s1QUU8Vo1q1xlBEdU1ODCdkw0VUikIQIV/LY4VDA5K5JZgCWhfM TVhYF/WR4DnFx249EzZzeKn9qoQ3Z2gj3iFFMTZjvST4uzpQBoUPNb9GQMnVK0RDRWDv QJKqpLy7J57KxLawjsDp2Q1B8jhvrQhMe6dMRRWdBdTothe88gPYbLErVoVqOXxbmMu2 TW1t6ZItDtPfdzCJdU2i1h5onMIGEWSt3UgL3lTWlAWiF+sSvVGWJCH78gV44d1yT/Kc 8djRWQbGBtMoUgGYlJcfM7IG0H7ixiCyJcDiA7Odj+lrBtY9e5yeyvX70Qi4Xky1ELV5 oqhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si15646713edi.151.2021.09.20.06.15.30; Mon, 20 Sep 2021 06:15:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235991AbhITIs5 (ORCPT + 99 others); Mon, 20 Sep 2021 04:48:57 -0400 Received: from mx3.molgen.mpg.de ([141.14.17.11]:45299 "EHLO mx1.molgen.mpg.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231625AbhITIs4 (ORCPT ); Mon, 20 Sep 2021 04:48:56 -0400 Received: from [192.168.0.3] (ip5f5aef72.dynamic.kabel-deutschland.de [95.90.239.114]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 0FB6E61E5FE00; Mon, 20 Sep 2021 10:47:29 +0200 (CEST) Subject: Re: [PATCH v2] lib/zlib_inflate/inffast: Check config in C to avoid unused function warning To: Christophe Leroy , Nathan Chancellor , Nick Desaulniers Cc: Zhen Lei , Andrew Morton , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20210920074633.13089-1-pmenzel@molgen.mpg.de> <00f8d7d7-cb13-203e-5a37-aee34a3258ff@csgroup.eu> From: Paul Menzel Message-ID: Date: Mon, 20 Sep 2021 10:47:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <00f8d7d7-cb13-203e-5a37-aee34a3258ff@csgroup.eu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Christophe, Thank you for the review. Am 20.09.21 um 10:36 schrieb Christophe Leroy: > > > Le 20/09/2021 à 09:46, Paul Menzel a écrit : >> Building Linux for ppc64le with Ubuntu clang version 12.0.0-3ubuntu1~21.04.1 >> shows the warning below. >> >>      arch/powerpc/boot/inffast.c:20:1: warning: unused function 'get_unaligned16' [-Wunused-function] >>      get_unaligned16(const unsigned short *p) >>      ^ >>      1 warning generated. >> >> Fix it, by moving the check from the preprocessor to C, so the compiler >> sees the use. >> >> Signed-off-by: Paul Menzel >> --- >>   lib/zlib_inflate/inffast.c | 7 ++----- >>   1 file changed, 2 insertions(+), 5 deletions(-) >> >> diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c >> index f19c4fbe1be7..fb87a3120f0f 100644 >> --- a/lib/zlib_inflate/inffast.c >> +++ b/lib/zlib_inflate/inffast.c >> @@ -254,11 +254,8 @@ void inflate_fast(z_streamp strm, unsigned start) >>               sfrom = (unsigned short *)(from); >>               loops = len >> 1; >>               do >> -#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS >> -                *sout++ = *sfrom++; >> -#else >> -                *sout++ = get_unaligned16(sfrom++); >> -#endif >> +                *sout++ = >> IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ? >> +                *sfrom++ : get_unaligned16(sfrom++); > > I think it would be more readable as > > do { >         if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)) >                 *sout++ = *sfrom++; >         else >                 *sout++ = get_unaligned16(sfrom++); > } while (--loops); I prefer the ternary operator, as it’s less lines, and it’s clear, that only the variable assignment is affected by the condition. But as style is subjective, I sent v3. >>               while (--loops); >>               out = (unsigned char *)sout; >>               from = (unsigned char *)sfrom; Kind regards, Paul