From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67323320E for ; Tue, 7 Jun 2022 22:27:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADA80C3411C; Tue, 7 Jun 2022 22:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1654640864; bh=5S/z21z92weYsEvQ8sPPs+ir8hNQ+/Ya3+hZvDiMy5c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cKxKBVi5rytKhSUhsR1sqCXCIPzwkOTvcLJ8meC4RfrPuYgz0kOcW6FLaTsn9gAsw kjk7YBdIUHrogGL/Dmwl/6mCUF9e9kG4DwbeSFZRM3cOBE915bq7MpGq+iXo0YFhjC HxFo+7C7nQZE2NaMqwQoSBIupxQ/cbLiNi+Glvgo= Date: Tue, 7 Jun 2022 15:27:44 -0700 From: Andrew Morton To: Justin Stitt Cc: Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] include/uapi/linux/swab.h: add __u16 cast to __swab16 conditional Message-Id: <20220607152744.d7c801d092529309500ac9a6@linux-foundation.org> In-Reply-To: <20220607222006.22719-1-jstitt007@gmail.com> References: <20220607222006.22719-1-jstitt007@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 7 Jun 2022 15:20:06 -0700 Justin Stitt wrote: > if __HAVE_BUILTIN_BSWAP16__ is defined then __swab16 utilizes a __u16 cast. > This same cast should be used if __HAVE_BUILTIN_BSWAP16__ is not defined as > well. This should fix loads (at least a few) clang -Wformat warnings > specifically with `ntohs()` > > ... > > --- a/include/uapi/linux/swab.h > +++ b/include/uapi/linux/swab.h > @@ -102,7 +102,7 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val) > #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x)) > #else > #define __swab16(x) \ > - (__builtin_constant_p((__u16)(x)) ? \ > + (__u16)(__builtin_constant_p((__u16)(x)) ? \ > ___constant_swab16(x) : \ > __fswab16(x)) > #endif More explanation, please? Both ___constant_swab16() and __fswab16() return __u16, so why does this patch have any effect?