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, URIBL_BLOCKED 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 E2B00C433DB for ; Mon, 8 Feb 2021 21:40:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F33864E9C for ; Mon, 8 Feb 2021 21:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235601AbhBHVkX (ORCPT ); Mon, 8 Feb 2021 16:40:23 -0500 Received: from mga01.intel.com ([192.55.52.88]:26363 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233030AbhBHVAt (ORCPT ); Mon, 8 Feb 2021 16:00:49 -0500 IronPort-SDR: WW9omUM8ga/juAx1MUrGgcXgWuh9rXI03rgPXfdQT7nqkyLnoVIj2Xtrey3ff/ynODhDpQUmJg Oh1q9Y3jgtBg== X-IronPort-AV: E=McAfee;i="6000,8403,9889"; a="200844088" X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="200844088" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 12:59:01 -0800 IronPort-SDR: xI+wR9shPytXsExmurvrnFJimgsZjNsYASJNJlJ/tIqUMmIipi+s6krvnVr/PH3Y6ShSXi12HR LkMo27ukJxJw== X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="418346627" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 12:58:58 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1l9DcV-0033nx-B3; Mon, 08 Feb 2021 22:58:55 +0200 Date: Mon, 8 Feb 2021 22:58:55 +0200 From: Andy Shevchenko To: Sakari Ailus Cc: Linux Kernel Mailing List , Linux Media Mailing List , Petr Mladek , Dave Stevenson , dri-devel , Hans Verkuil , Laurent Pinchart , Mauro Carvalho Chehab , Sergey Senozhatsky , Steven Rostedt , Joe Perches , Jani Nikula , Rasmus Villemoes Subject: Re: [PATCH v6 1/3] lib/vsprintf: Add support for printing V4L2 and DRM fourccs Message-ID: References: <20210208200903.28084-1-sakari.ailus@linux.intel.com> <20210208200903.28084-2-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 08, 2021 at 10:43:30PM +0200, Andy Shevchenko wrote: > On Mon, Feb 8, 2021 at 10:11 PM Sakari Ailus > wrote: ... > > +static noinline_for_stack > > +char *fourcc_string(char *buf, char *end, const u32 *fourcc, > > + struct printf_spec spec, const char *fmt) > > +{ > > > + char output[sizeof("(xx)(xx)(xx)(xx) little-endian (0x01234567)")]; > > Do we have any evidence / document / standard that the above format is > what people would find good? From existing practices (I consider other > printings elsewhere and users in this series) I find '(xx)' form for > hex numbers is weird. The standard practice is to use \xHH (without > parentheses). > > + val = *fourcc & ~BIT(31); > > + > > + for (i = 0; i < sizeof(*fourcc); i++) { > > + unsigned char c = val >> (i * 8); > > ... > > > + /* Weed out spaces */ > > + if (c == ' ') > > + continue; > > None of the existing users does that. Why? > > > + /* Print non-control ASCII characters as-is */ > > + if (isascii(c) && isprint(c)) { > > + *p++ = c; > > + continue; > > + } > > + > > + *p++ = '('; > > + p = hex_byte_pack(p, c); > > + *p++ = ')'; > > + } To be on constructive side, I would propose to replace above with something like: __le32 val; val = cpu_to_le32(*fourcc & ~BIT(31)); p += string_escape_mem(&val, sizeof(*fourcc), output, sizeof(output), ESCAPE_NP | ESCAPE_HEX, NULL); -- With Best Regards, Andy Shevchenko 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, URIBL_BLOCKED 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 EF0FCC433E0 for ; Mon, 8 Feb 2021 20:59:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A2BA64E45 for ; Mon, 8 Feb 2021 20:59:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A2BA64E45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA24F6E9FC; Mon, 8 Feb 2021 20:59:08 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id A4E9B6E9FC for ; Mon, 8 Feb 2021 20:59:07 +0000 (UTC) IronPort-SDR: r/d3ViLLVAz9yTjv9N128XoHfXPi5t0Clxw2kIpUdtJNw9+PagZsNENZyF8pDgVJSEP4OUVTTP czn3BqavJTeQ== X-IronPort-AV: E=McAfee;i="6000,8403,9889"; a="181924470" X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="181924470" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 12:59:03 -0800 IronPort-SDR: xI+wR9shPytXsExmurvrnFJimgsZjNsYASJNJlJ/tIqUMmIipi+s6krvnVr/PH3Y6ShSXi12HR LkMo27ukJxJw== X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="418346627" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 12:58:58 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1l9DcV-0033nx-B3; Mon, 08 Feb 2021 22:58:55 +0200 Date: Mon, 8 Feb 2021 22:58:55 +0200 From: Andy Shevchenko To: Sakari Ailus Subject: Re: [PATCH v6 1/3] lib/vsprintf: Add support for printing V4L2 and DRM fourccs Message-ID: References: <20210208200903.28084-1-sakari.ailus@linux.intel.com> <20210208200903.28084-2-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Dave Stevenson , Rasmus Villemoes , Linux Kernel Mailing List , dri-devel , Hans Verkuil , Sergey Senozhatsky , Steven Rostedt , Laurent Pinchart , Joe Perches , Mauro Carvalho Chehab , Linux Media Mailing List Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, Feb 08, 2021 at 10:43:30PM +0200, Andy Shevchenko wrote: > On Mon, Feb 8, 2021 at 10:11 PM Sakari Ailus > wrote: ... > > +static noinline_for_stack > > +char *fourcc_string(char *buf, char *end, const u32 *fourcc, > > + struct printf_spec spec, const char *fmt) > > +{ > > > + char output[sizeof("(xx)(xx)(xx)(xx) little-endian (0x01234567)")]; > > Do we have any evidence / document / standard that the above format is > what people would find good? From existing practices (I consider other > printings elsewhere and users in this series) I find '(xx)' form for > hex numbers is weird. The standard practice is to use \xHH (without > parentheses). > > + val = *fourcc & ~BIT(31); > > + > > + for (i = 0; i < sizeof(*fourcc); i++) { > > + unsigned char c = val >> (i * 8); > > ... > > > + /* Weed out spaces */ > > + if (c == ' ') > > + continue; > > None of the existing users does that. Why? > > > + /* Print non-control ASCII characters as-is */ > > + if (isascii(c) && isprint(c)) { > > + *p++ = c; > > + continue; > > + } > > + > > + *p++ = '('; > > + p = hex_byte_pack(p, c); > > + *p++ = ')'; > > + } To be on constructive side, I would propose to replace above with something like: __le32 val; val = cpu_to_le32(*fourcc & ~BIT(31)); p += string_escape_mem(&val, sizeof(*fourcc), output, sizeof(output), ESCAPE_NP | ESCAPE_HEX, NULL); -- With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel