Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp303533ybb; Fri, 3 Apr 2020 03:04:55 -0700 (PDT) X-Google-Smtp-Source: APiQypKdzZIzS2YZyz+T4S3+3RGQ9gZZqSIGvMw0DTp82le9cxA1FkrRpoquzttAcG8ZoLPdOoV7 X-Received: by 2002:a9d:798a:: with SMTP id h10mr5548219otm.367.1585908295152; Fri, 03 Apr 2020 03:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585908295; cv=none; d=google.com; s=arc-20160816; b=DzyJJYbaRag5Ca9mrQfGiu0DZCdNIptFDg7VLBTrblRnjDBshdyTGy0sW763tB5saN rtE2jMbyM24YlL2iD6hDuWbnundi+/wqZh7MlkfBWCJcPxQe6prpt6PlDjndC8+xko/3 BNarKgvA+JDg5G6Fur6ZvHJaWskiAwSX76fyt+s0AP+fpDuhZDh7XCyHJpJO0P52JdBe VO4EiTxYxCN10JSh1LUkbHG2l+Ayf/RTn9zLmvMFN8+U2Ev6KytzVNZd9ftJCoa/b6oh aRn2xR7fR9MPOfOhKcU1xUDt3gnLHTYmDShUHlutmqospQ+2N5g6AlZzJ8k4nzIDccEd PAAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=3LE7onh2Rv0FVrpSEcTooWbPMACdUgOzY6vJch95dc8=; b=zGZHZKeDL+No81QZyh3GEypXSZvzGeioy3vPPijgH+RZDSfji7sl1/6ubraCH8/Roe aSIAyED1za03H2Ez1LKHxFtvNSadP1JXv2Gmm0uNhcO77tSzaalz7znZfzgZxQ4/IUkJ PbX9oTPX+P+k+fzfvgUY0WcJZ2xJxA9hBbpzNQXb8Sj2IOprUPvSn3ev0U1re4te2zx1 XaewZVTnJulPXwFIxqq6rDQ6yRmIM1UKBNcx6/3IkyIyc4+YWCR5mtSpcx4iFoZEw4sG yJkVw1auqqZHJKlbp32Rpt07m/E1vNR8oAsXtldjq6MNytzmHFSpppKjCirGj5JTxs5V rXsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si3577782otq.21.2020.04.03.03.04.40; Fri, 03 Apr 2020 03:04:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390597AbgDCJym (ORCPT + 99 others); Fri, 3 Apr 2020 05:54:42 -0400 Received: from mga05.intel.com ([192.55.52.43]:14660 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727887AbgDCJym (ORCPT ); Fri, 3 Apr 2020 05:54:42 -0400 IronPort-SDR: s7fiAwGSu3tCOZ4+fPyJX9xpXOK15q0HQ+nmqVKsTH6CdQ8DHXQzaWwX88il6UNjm9mBl/lb9v VOOL612HIxCw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 02:54:42 -0700 IronPort-SDR: /JHJxofgBSmxS0oCUImrgYtMCzYiO4lwVOTovp1y7Ruk+Zestd60dWvsEfrDINB4oPZaB/gtCs 83IZA9JNL2Cw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,339,1580803200"; d="scan'208";a="295954969" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by FMSMGA003.fm.intel.com with ESMTP; 03 Apr 2020 02:54:39 -0700 Received: from andy by smile with local (Exim 4.93) (envelope-from ) id 1jKJ29-00FOn5-8k; Fri, 03 Apr 2020 12:54:41 +0300 Date: Fri, 3 Apr 2020 12:54:41 +0300 From: Andy Shevchenko To: Sakari Ailus Cc: Petr Mladek , linux-media@vger.kernel.org, Dave Stevenson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, mchehab@kernel.org, Sergey Senozhatsky , Steven Rostedt , Joe Perches , Jani Nikula Subject: Re: [PATCH v2 1/1] lib/vsprintf: Add support for printing V4L2 and DRM fourccs Message-ID: <20200403095441.GL1922688@smile.fi.intel.com> References: <20200403091156.7814-1-sakari.ailus@linux.intel.com> <20200403093103.GI1922688@smile.fi.intel.com> <20200403093916.GA3172@kekkonen.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200403093916.GA3172@kekkonen.localdomain> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 03, 2020 at 12:39:16PM +0300, Sakari Ailus wrote: > On Fri, Apr 03, 2020 at 12:31:03PM +0300, Andy Shevchenko wrote: > > On Fri, Apr 03, 2020 at 12:11:56PM +0300, Sakari Ailus wrote: > > > Add a printk modifier %ppf (for pixel format) for printing V4L2 and DRM > > > pixel formats denoted by 4ccs. The 4cc encoding is the same for both so > > > the same implementation can be used. > > > > ... > > > > > +static noinline_for_stack > > > +char *fourcc_string(char *buf, char *end, const u32 *fourcc, > > > + struct printf_spec spec, const char *fmt) > > > +{ > > > > > +#define FOURCC_STRING_BE "-BE" > > > + char s[sizeof(*fourcc) + sizeof(FOURCC_STRING_BE)] = { 0 }; > > > > I guess it makes it too complicated. > > The above also clearly binds the size to the data that is expected to > contain there. I'd prefer keeping it as-is. And yes, 8 would be correct, > too. OK. > > char s[8]; > > > > > + if (check_pointer(&buf, end, fourcc, spec)) > > > + return buf; > > > + > > > + if (fmt[1] != 'c' || fmt[2] != 'c') > > > + return error_string(buf, end, "(%p4?)", spec); > > > + > > > > > + put_unaligned_le32(*fourcc & ~BIT(31), s); > > > > Can you elaborate what the difference in output with this bit set over cleared? > > I.o.w. why don't we need to put it as BE and for LE case addd "-LE"? > > The established practice is that big endian formats have "-BE" suffix > whereas the little endian ones have nothing. (At least when it comes to > V4L2.) What I meant by the first part of the question is ordering of the characters. That ordering of characters is not related to that flag, correct? So, bit actually defines the endianess of the data in the certain fourcc. Probably you need to put a comment to explain this. > > > + if (*fourcc & BIT(31)) > > > + strscpy(s + sizeof(*fourcc), FOURCC_STRING_BE, > > > + sizeof(FOURCC_STRING_BE)); > > > > We know the size, and we may put '\0' as well > > if (*fourcc & BIT(31)) > > strscpy(&s[4], "-BE", sizeof("-BE")); > > else > > strscpy(&s[4], "", sizeof("")); > > The rest of the struct memory has already been set to zero in variable > declaration. Which is bogus in my opinion. strscpy() or direct '\0' termination will put it more explicit. -- With Best Regards, Andy Shevchenko