Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp11618pxb; Mon, 8 Feb 2021 13:41:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFKkldfGmwyzDzGXrFuE7XAnPgnCnBoEoku6X47OelqA6zhA5T6N9yiSGRb+f4s30eGfSl X-Received: by 2002:a05:6402:3589:: with SMTP id y9mr19580460edc.344.1612820500492; Mon, 08 Feb 2021 13:41:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612820500; cv=none; d=google.com; s=arc-20160816; b=ksMCfJzFNE6oJUYuHPAXuL7MFmL1D95DlyOTN6OG2XLVqqNwV9rCuN28VobKfLDisH yeZVuVvYBIxWAVIlxil4TF/XuQ2aW3sgNxJZXNoYwb+xPGmx+DzZZFJBmoOBxPSFr6zj /vFNQTSukkXlMUZn/JYoV2lDA+HYYz4ru+AABQx2dh8ZrW/+YmnquC/tFD0dMCUFQ/nx em1qGcoOrjTlbqoJBAf66GI5iDgKVr5ymqcNR8wQdCMFUYxe2/+Lhx0DZsdYydR+7ODM BD1dcxmIgn6n+11tjOajmYbPVIxKJay7oBrmjXpGIFgJTFXpa5vpsUtrWBcreKEhwRwk LwTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=vx8jawVOBeVcKj9lNuliL9khJhu/LV/AGqktesSbKAw=; b=Ebv4TR555wqUHLWgdZkSnmFQjXBeKT24ENlG9PiGh8Ad+LFbsKtHqXBYNC1IkwWIzn fhdbOYh5dHGzaz+3P4rS+spdCBiDNn986GFjudaOWW7PpaU0dHXi4/KFCYR3qGOuZUbP /oSXpiGUDVHUVz4GIqisxoWqQ6N2qHSe9BJOwwMhpNabrG/VBaeTlrkkklq89qWVrjvt ANEILx2StV32F6NkDWXmtIeVHQONCzO/WMthpC7k3ir8hS1cTVYq3SxBst+UHqJbsvIY 2uJs+31V6Oxow3cDjtr6ywoEAspBG4wgHJZOjVLFAyLQ6LuTDEh1ATKFjNDexlSWE7R7 0JHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id z9si15018869edr.392.2021.02.08.13.41.17; Mon, 08 Feb 2021 13:41:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236857AbhBHVkB (ORCPT + 99 others); Mon, 8 Feb 2021 16:40:01 -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