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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9BC3C2D0A3 for ; Tue, 3 Nov 2020 15:46:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 942E220780 for ; Tue, 3 Nov 2020 15:46:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728530AbgKCPqB (ORCPT ); Tue, 3 Nov 2020 10:46:01 -0500 Received: from mga07.intel.com ([134.134.136.100]:48981 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728474AbgKCPqB (ORCPT ); Tue, 3 Nov 2020 10:46:01 -0500 IronPort-SDR: lPsVTv1DvEzGzj8ypJvKA87mIsHLajIz9U9W80rsyhUL/8INyUdMeJU7BssL4IdrRX7AmIiwhA gD+ReM4k2Klg== X-IronPort-AV: E=McAfee;i="6000,8403,9794"; a="233239582" X-IronPort-AV: E=Sophos;i="5.77,448,1596524400"; d="scan'208";a="233239582" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:45:58 -0800 IronPort-SDR: 0N5GIaDzQLTkm+QI39DbxKEIqUgnz5PwMjSHGBBwSEp6ZtuJ/rWshE7S5SHGOl/RSjDs9/b9fO nsR9K8XyzagA== X-IronPort-AV: E=Sophos;i="5.77,448,1596524400"; d="scan'208";a="320484142" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:45:54 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kZyWN-003ZmP-UA; Tue, 03 Nov 2020 17:46:55 +0200 Date: Tue, 3 Nov 2020 17:46:55 +0200 From: Andy Shevchenko To: Sakari Ailus Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Petr Mladek , Dave Stevenson , dri-devel@lists.freedesktop.org, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, mchehab@kernel.org, Sergey Senozhatsky , Steven Rostedt , Joe Perches , Jani Nikula , Rasmus Villemoes Subject: Re: [PATCH v4 1/1] lib/vsprintf: Add support for printing V4L2 and DRM fourccs Message-ID: <20201103154655.GE4077@smile.fi.intel.com> References: <20201103133400.24805-1-sakari.ailus@linux.intel.com> <20201103144747.GD4077@smile.fi.intel.com> <20201103145616.GJ26150@paasikivi.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201103145616.GJ26150@paasikivi.fi.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 03, 2020 at 04:56:16PM +0200, Sakari Ailus wrote: > On Tue, Nov 03, 2020 at 04:47:47PM +0200, Andy Shevchenko wrote: > > On Tue, Nov 03, 2020 at 03:34:00PM +0200, Sakari Ailus wrote: > > > Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM > > > pixel formats denoted by fourccs. The fourcc encoding is the same for both > > > so the same implementation can be used. ... > > > + char output[sizeof("(xx)(xx)(xx)(xx) little-endian (0x01234567)")]; > > > > I would add a comment that there is another possibility, i.e. big-endian, but > > it occupies less space. > > This string is here to represent the longest possible output of the > function. Most of the time it's less. Saying that might make sense but it's > fairly clear already. Either way works for me though. It's not known by reading the above line. I would add a comment. ... > > > + p = special_hex_number(p, output + sizeof(output) - 2, *fourcc, > > > + sizeof(u32)); > > > > I would go with one line here. > > It's wrapped since the result would be over 80 otherwise. It will be not the first one breaking the limit in this module for the sake of readability. ... > > The (theoretical) problem is here that the case when buffer size is not enough > > to print a value will be like '(0xabc)' but should be rather '(0xabcd' like > > snprintf() does in general. Any comments here? Perhaps you need to add a comment to explain that the overflow is impossible. -- With Best Regards, Andy Shevchenko