Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1457900ybe; Thu, 5 Sep 2019 16:04:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQnf2RWkn+btjis/M4SgD5o2VI+yzH5YK4ZruNigT5eBxcY0hYwOnen7Se1FF2Ix2UaxBw X-Received: by 2002:a17:90a:1150:: with SMTP id d16mr6816080pje.2.1567724687341; Thu, 05 Sep 2019 16:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567724687; cv=none; d=google.com; s=arc-20160816; b=ZvbCRqVTB0JrZaqls8ecxZt1Xw5MVmv77BhwF3FsNUBZgaCrNuJfJr+9Xb7ae9vkiz 4dv8iHh+ecYO0QCsSlGTMzfoPwMyoqelwmEAg1o4qV/kwUObd5iSodNS80U0OxOGKZOl K5g9ikJiY6k7uq4Ob5BNC062DabavGKvtg/EsRwQLKtF6X/PPaB7bxdXTNzN2uNSZvqt OLB32Nyr7EOEpYheqWaLR/lcPDCdK7lXlENigps2QUJH+WZ/D7sxQvZt4me/ACseqYxI 7CZOE6dQo4QBf2u9op89XHVFV0RsDMLr++wgeHhdLj2jpfHk/8Orr2O9jWUMnq4WJ5xU vy7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=8t2jJDEQsfSFFa7WX0bDk2lGSrgzg2RxDGeKDvQswYA=; b=MuZ5xkfoIQZxeKkLRwujtHxyxeM7UF2xQ5ZuhehdMP1s9Cc3et1BO0Gqj7Zq9p1ir1 HnavgdlLRuMkFpnBrUZ+62wvR3Xyy4Te5+UyPDCYDkpY9eu0vYpW0rxhwc5r8kqD3R0I BJIMizJopnGXoqhf3pdbOpFeXkkBE3i7gxgpTOhmBxui8+y8HFKFXuJdL/CcDYBMBwlN DXBcR1nECudLLCpienOYORRlXhP8gF7VpWuQilY6ZaBYw6G7PsPL3TECf9xk/KYmBYly d0JLJTc4mXxv9JhAW96Y2K4EJ+RMEvoBzdBM/hN1Gv451t5kR+KqeQq5+SF1ln2nGlfJ K5Wg== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z20si3293553plo.159.2019.09.05.16.04.31; Thu, 05 Sep 2019 16:04:47 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403953AbfIETo7 (ORCPT + 99 others); Thu, 5 Sep 2019 15:44:59 -0400 Received: from fieldses.org ([173.255.197.46]:56714 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389775AbfIETog (ORCPT ); Thu, 5 Sep 2019 15:44:36 -0400 Received: by fieldses.org (Postfix, from userid 2815) id D38384120; Thu, 5 Sep 2019 15:44:34 -0400 (EDT) From: "J. Bruce Fields" To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, Kees Cook , "J. Bruce Fields" Subject: [PATCH 5/9] Remove unused %*pE[achnops] formats Date: Thu, 5 Sep 2019 15:44:29 -0400 Message-Id: <1567712673-1629-5-git-send-email-bfields@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1567712673-1629-1-git-send-email-bfields@redhat.com> References: <20190905193604.GC31247@fieldses.org> <1567712673-1629-1-git-send-email-bfields@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "J. Bruce Fields" The [achnops] are confusing, and in practice the only one anyone seems to need is the bare %*pE. I think some set of modifiers here might actually be useful, but the ones we have are confusing and unused, so let's just toss these out and then rethink what we might want to add back later. Signed-off-by: J. Bruce Fields --- Documentation/core-api/printk-formats.rst | 23 ++--------- lib/vsprintf.c | 50 ++--------------------- 2 files changed, 7 insertions(+), 66 deletions(-) diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst index c6224d039bcb..4f9d20dfb342 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst @@ -180,35 +180,20 @@ Raw buffer as an escaped string :: - %*pE[achnops] + %*pE For printing raw buffer as an escaped string. For the following buffer:: 1b 62 20 5c 43 07 22 90 0d 5d -A few examples show how the conversion would be done (excluding surrounding +An example shows how the conversion would be done (excluding surrounding quotes):: %*pE "\eb \C\a"\220\r]" - %*pEhp "\x1bb \C\x07"\x90\x0d]" - %*pEa "\e\142\040\\\103\a\042\220\r\135" -The conversion rules are applied according to an optional combination -of flags (see :c:func:`string_escape_mem` kernel documentation for the -details): +See :c:func:`string_escape_mem` kernel documentation for the details. - - a - ESCAPE_ANY - - c - ESCAPE_SPECIAL - - h - ESCAPE_HEX - - n - ESCAPE_NULL - - o - ESCAPE_OCTAL - - p - ESCAPE_NP - - s - ESCAPE_SPACE - -By default ESCAPE_ANY_NP is used. - -ESCAPE_ANY_NP is the sane choice for many cases, in particularly for -printing SSIDs. +This is used, for example, for printing SSIDs. If field width is omitted then 1 byte only will be escaped. diff --git a/lib/vsprintf.c b/lib/vsprintf.c index b0967cf17137..5522d2a052e1 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1537,9 +1537,6 @@ static noinline_for_stack char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, const char *fmt) { - bool found = true; - int count = 1; - unsigned int flags = 0; int len; if (spec.field_width == 0) @@ -1548,38 +1545,6 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, if (check_pointer(&buf, end, addr, spec)) return buf; - do { - switch (fmt[count++]) { - case 'a': - flags |= ESCAPE_ANY; - break; - case 'c': - flags |= ESCAPE_SPECIAL; - break; - case 'h': - flags |= ESCAPE_HEX; - break; - case 'n': - flags |= ESCAPE_NULL; - break; - case 'o': - flags |= ESCAPE_OCTAL; - break; - case 'p': - flags |= ESCAPE_NP; - break; - case 's': - flags |= ESCAPE_SPACE; - break; - default: - found = false; - break; - } - } while (found); - - if (!flags) - flags = ESCAPE_ANY_NP; - len = spec.field_width < 0 ? 1 : spec.field_width; /* @@ -1587,7 +1552,8 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, * the given buffer, and returns the total size of the output * had the buffer been big enough. */ - buf += string_escape_mem(addr, len, buf, buf < end ? end - buf : 0, flags, NULL); + buf += string_escape_mem(addr, len, buf, buf < end ? end - buf : 0, + ESCAPE_ANY_NP, NULL); return buf; } @@ -2038,17 +2004,7 @@ static char *kobject_string(char *buf, char *end, void *ptr, * - '[Ii][4S][hnbl]' IPv4 addresses in host, network, big or little endian order * - 'I[6S]c' for IPv6 addresses printed as specified by * http://tools.ietf.org/html/rfc5952 - * - 'E[achnops]' For an escaped buffer, where rules are defined by combination - * of the following flags (see string_escape_mem() for the - * details): - * a - ESCAPE_ANY - * c - ESCAPE_SPECIAL - * h - ESCAPE_HEX - * n - ESCAPE_NULL - * o - ESCAPE_OCTAL - * p - ESCAPE_NP - * s - ESCAPE_SPACE - * By default ESCAPE_ANY_NP is used. + * - 'E[achnops]' For an escaped buffer (see string_escape_mem() * - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form * "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" * Options for %pU are: -- 2.21.0