From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45A1DC43217 for ; Mon, 14 Nov 2022 16:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w8fRzPxNrKjh9MhpEF9S30hVWnFYm7YKaFJFvUQzMAc=; b=p99c+HjZQ81GA8 PulpZGkbusOuIxfzPHZiHGRwGdxZyURBXOYwJ/cyFHhdViP45y+E5/fjpEs+oCnKu2IC0PKpSZpzu C54xPiC7RuhfpfSaztRqAsli6ExZyPmlBUiIhSVA632l0TR0Q7gl0XBiPid5+c1BigW7PopeM4DM4 7azAVTG8IAC7ITaN07FDK+ekeLpsiZIoSSpayL3DCoeWSpymo02oHKndcBubSrPYc/40KxNcLfSMB xH/LVmq6IlchsGeBiywb4hVkLuorq3Ps47beovbHxOCocAOKDto5zcblOxixkj7d1PsmRL4DZ23Zu /ArEmrJlwQWLCRIzL4oQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouc8L-002d2K-1Q; Mon, 14 Nov 2022 16:16:29 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouc8H-002cv2-O2 for linux-arm-kernel@lists.infradead.org; Mon, 14 Nov 2022 16:16:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=znnsShYF3xMT+VtpHIRsweTjuKslFaebTs8rKcGhy3I=; b=NGUAJ3PUj4W0JFQSXxGJbcBUQ/ brGT1l6wHh1sn8UkG+adbRc1r/md9kAuUOyuoiYNhiMF3I9bAj6W/J8sz8zl9iW2n3AyilbK83oj8 sLiY1dHAeT/yqkV3pDilb7JLyvUm1ifJ7Uo9zzS5neCknjQO163obDLUM1D8yxpLg0HJYnwlYe0mA Kh/W/GfeEE7fYcxqJ7mBB9Mg/m2okIiKlpFm7MYsCRTQcLGyRn6uTu9oOYFxjDft1giaLeAm0a543 1NaB/+pX8T2qz+SUHEUklMrrabJ0L/LfN577N8YG6DVUXzagS06rcTwuxXMFTO3/iESar/IXZVSXC SimKFuMQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:35264) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ouc7o-00014G-14; Mon, 14 Nov 2022 16:15:56 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1ouc7i-0003wN-OK; Mon, 14 Nov 2022 16:15:50 +0000 Date: Mon, 14 Nov 2022 16:15:50 +0000 From: "Russell King (Oracle)" To: Petr Mladek Cc: Linus Walleij , Bartosz Golaszewski , Rob Herring , Lee Jones , Alyssa Rosenzweig , Andy Shevchenko , asahi@lists.linux.dev, devicetree@vger.kernel.org, Hector Martin , Jonathan Corbet , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-gpio@vger.kernel.org, Rasmus Villemoes , Sergey Senozhatsky , Steven Rostedt , Sven Peter Subject: Re: [PATCH v3 2/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221114_081625_803119_0F1EF386 X-CRM114-Status: GOOD ( 23.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Nov 14, 2022 at 04:34:07PM +0100, Petr Mladek wrote: > On Tue 2022-11-08 16:33:22, Russell King wrote: > > From: Hector Martin > > > > %p4cc is designed for DRM/V4L2 FOURCCs with their specific quirks, but > > it's useful to be able to print generic 4-character codes formatted as > > an integer. Extend it to add format specifiers for printing generic > > 32-bit FOURCCs with various endian semantics: > > > > %p4ch Host-endian > > %p4cl Little-endian > > %p4cb Big-endian > > %p4cr Reverse-endian > > > > The endianness determines how bytes are interpreted as a u32, and the > > FOURCC is then always printed MSByte-first (this is the opposite of > > V4L/DRM FOURCCs). This covers most practical cases, e.g. %p4cr would > > allow printing LSByte-first FOURCCs stored in host endian order > > (other than the hex form being in character order, not the integer > > value). > > > > Signed-off-by: Hector Martin > > Signed-off-by: Russell King (Oracle) > > Reviewed-by: Petr Mladek > > See one nit below. > > > --- a/lib/vsprintf.c > > +++ b/lib/vsprintf.c > > @@ -1762,27 +1762,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc, > > char output[sizeof("0123 little-endian (0x01234567)")]; > > char *p = output; > > unsigned int i; > > + bool pixel_fmt = false; > > u32 orig, val; > > > > - if (fmt[1] != 'c' || fmt[2] != 'c') > > + if (fmt[1] != 'c') > > return error_string(buf, end, "(%p4?)", spec); > > > > if (check_pointer(&buf, end, fourcc, spec)) > > return buf; > > > > orig = get_unaligned(fourcc); > > - val = orig & ~BIT(31); > > + switch (fmt[2]) { > > + case 'h': > > + val = orig; > > + break; > > + case 'r': > > + val = orig = swab32(orig); > > I do not like much these multi assignments. I think that the result > was not even defined in some older C standards. Though, I can't find > it now. And even make W=3 does not warn about it. Err. It's been supported for decades. I learnt about it back in 1992 when I was introduced to C by another experienced C programmer. It's been supported in ANSI C compilers. The Norcroft C compiler (which is strict ANSI) on Acorn platforms back in the late 1980s/1990s even supported it. I think you're a bit out of date. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel