Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1100513ybf; Thu, 27 Feb 2020 05:05:24 -0800 (PST) X-Google-Smtp-Source: APXvYqwfBMwiwlTq6/3TRt7691kj/xOLi2B/mR04MPz9+nV47KoPX8MIRJtKMWVr646tW6HnGM8c X-Received: by 2002:a05:6830:1e6b:: with SMTP id m11mr3338050otr.293.1582808724043; Thu, 27 Feb 2020 05:05:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582808724; cv=none; d=google.com; s=arc-20160816; b=U5xBqtuDeSGTO123qucwfqm7gqphNHyi/zCdWlbTAivDqLAF2MY5BgBEXYzIEZrwus g3NNjM3B9l7rpAcD3wyVCjlhmVLVDNegSs4PkInUn+wQ1jAQyI3gmnSboGOhWzJRQMCZ wkE1WzZ7vRZH+GgXtBcMr6TSSvlICbUaZO8c5Z0G0c1muvmwXqUAAuLxWeiSmj6Xc02n 7WdjcTh+x5zbvG40Lkc5/LDuyFcFzwq/l39RDvIrSVJLvM+Ars9k47x33xFTbSSfcp+p Ufh+/81DxALQWMBS9ltyRte2Yohu/g/MQFR2JqYfx+3E5A+Q+20zoBzb/5cJAVh3367i PWNg== 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=tCQNkHqeY1vGH6aTTDsMEgGGbs0Ota+5GndMan2W7vs=; b=X5Xq84Ky5NCIHCm8khpd9WtFdBadqkmFnMOkMv6vJLU7FshHSyeoleTe+vDYPUP0oY TJ2DlYRpyeI2JOEMZRYqaZORwW7yjdLR/O1uKj70F72AaaDG42Tq5b09LoacZV9TYuK/ EJOq+/RA+I1y4djdTLRp9FfhMSd85wLRRE6oFffMDeQ0SGHiFjTQ6pCXGA103FqEw5ys uXkYiw2ceDJYKUrIkOx9U/EAaXcS3v0syVYrM842IhiIxBLbZR9QdcKTXNDFK4HPlUC0 /HxNXPRRgxyjDYfa+bXIqkNWZj+tcL8xVMnlaT3r/ujLy8lODwFJqSFUbgdPmX+1LYtC LeuQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si1509927otk.276.2020.02.27.05.05.11; Thu, 27 Feb 2020 05:05:24 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729163AbgB0NCb (ORCPT + 99 others); Thu, 27 Feb 2020 08:02:31 -0500 Received: from mx2.suse.de ([195.135.220.15]:37368 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729138AbgB0NC2 (ORCPT ); Thu, 27 Feb 2020 08:02:28 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F00D0B30D; Thu, 27 Feb 2020 13:02:26 +0000 (UTC) From: Petr Mladek To: Andy Shevchenko , Sergey Senozhatsky , Steven Rostedt Cc: Rasmus Villemoes , Sergey Senozhatsky , linux-kernel@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ilya Dryomov , Kees Cook , "Tobin C . Harding" , Petr Mladek Subject: [PATCH 2/3] lib/test_printf: Fix structure of basic pointer tests Date: Thu, 27 Feb 2020 14:01:22 +0100 Message-Id: <20200227130123.32442-3-pmladek@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200227130123.32442-1-pmladek@suse.com> References: <20200227130123.32442-1-pmladek@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pointer formatting tests have been originally split by the %p modifiers. For example, the function dentry() tested %pd and %pD handling. There were recently added tests that do not fit into the existing structure, namely: + hashed pointer testing + null and invalid pointer handling with various modifiers Reshuffle these tests to follow the original structure. For completeness, add a test for "%px" with some "random" pointer value. Note that it can't be tested with "%pE" because it would cause crash. Signed-off-by: Petr Mladek --- lib/test_printf.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 6fa6fb606554..1ee1bb703307 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -278,28 +278,22 @@ test_hashed(const char *fmt, const void *p) failed_tests++; } -static void __init -plain(void) -{ - test_hashed("%p", PTR); -} +#define PTR_INVALID ((void *)0x000000ab) static void __init -null_pointer(void) +plain_pointer(void) { + test_hashed("%p", PTR); test_hashed("%p", NULL); - test(ZEROS "00000000", "%px", NULL); - test("(null)", "%pE", NULL); + test_hashed("%p", PTR_INVALID); } -#define PTR_INVALID ((void *)0x000000ab) - static void __init -invalid_pointer(void) +real_pointer(void) { - test_hashed("%p", PTR_INVALID); + test(PTR_STR, "%px", PTR); + test(ZEROS "00000000", "%px", NULL); test(ZEROS "000000ab", "%px", PTR_INVALID); - test("(efault)", "%pE", PTR_INVALID); } static void __init @@ -326,6 +320,8 @@ addr(void) static void __init escaped_str(void) { + test("(null)", "%pE", NULL); + test("(efault)", "%pE", PTR_INVALID); } static void __init @@ -601,9 +597,8 @@ errptr(void) static void __init test_pointer(void) { - plain(); - null_pointer(); - invalid_pointer(); + plain_pointer(); + real_pointer(); symbol_ptr(); kernel_ptr(); struct_resource(); -- 2.16.4