Received: by 2002:a05:7412:d384:b0:fc:a2b0:25d7 with SMTP id bq4csp3928rdb; Wed, 21 Feb 2024 13:46:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW1uP//G6q6n3ApOA8trg2A+SWfd+M3Rdnvootyr+xbYcUJHv3BxbTweWeQo2B5khEgpf5yvdBHkIaV3gKMUpxM4OxBVWz7gPkHHHpzaQ== X-Google-Smtp-Source: AGHT+IE8NdzJw9U7LoESBmRgqVEpFtvkKz0Ohk3ut7xUf6ezqzvoC1b2vQ3sCN64EwxCYQPRULXT X-Received: by 2002:a05:6a21:2d8b:b0:19e:c32f:35fc with SMTP id ty11-20020a056a212d8b00b0019ec32f35fcmr25634871pzb.38.1708551972043; Wed, 21 Feb 2024 13:46:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708551972; cv=pass; d=google.com; s=arc-20160816; b=vVe0WI6OB9xury/EUmYSwSY/O1v2HRX9QKCoWfofaHg3/vgyANduStr5e5ZufxLObK a4P8HICFV7lUyqur81ZsFknZSqDDqsbKpFGW0wqhpqCWqmisXzxhnI4sx2tPXxPq+AeB Qiv4e/j/w2X5ov63mOTiSbyAX4BvKNMM0gfXIw1ceyf77H+LTZ7zHY0JuoDh44r90Q9Z IhFvXIOyrgahI9vRd8ds+L25NaTC8+sY6hkMkduidV0V21RekeHMB9H1O1JV8M9aW6Zz XodWgTpy63ziSkQbmRpEsNyzy0hxNt7fZyCyKC+YyGeqNk/FAAsuRDoc9QX3EQk+rd4S akxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fHJzWSZbaUVkrjgtkdycbYKuoIbcz4QqReZXQuIUTd8=; fh=Oxr3I9mrnBesTeUsYYvTqMWlnkgfEcwpfrrDGMVp5WQ=; b=VUkKqVFcUTWkAeABU1StbucscT5bZCPTzu1l2Z0SnDBL+VjqYYpasbh615REZOj8kb T+whxRh9DNoweRLIzbXO1Kzb8jT2YyOu0PobPtmTB3K46ver8cGzJy/uiNo9QK0pxnqd f5mHqr8xiHBMBXvSRp+0XWHNmc0qTS4g3tGJXvW5zcIwfEIaDB8zsEidK27ZpPFw0ql0 pQvbr+WSofrOt4mpN5i2PSLPMBpxfxeri9o0hj8ZrbXStCEdUkVYbKe8LMUrxJKyA4/U myKz5k1e7ZH2aBMOj1CTKQH4EV9LbS6QmSB6nnbKL5VHzcZZwpbB2cwcLCr9CcTJH+Lv wjzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=D0FOyXkc; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-75550-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g4-20020a056a000b8400b006e3fce37039si7336084pfj.351.2024.02.21.13.46.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 13:46:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75550-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=D0FOyXkc; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-75550-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 454E428AB90 for ; Wed, 21 Feb 2024 21:37:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6775312C809; Wed, 21 Feb 2024 21:29:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="D0FOyXkc" Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA1D912BEAA for ; Wed, 21 Feb 2024 21:29:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708550998; cv=none; b=JRHnhaLsXHtU/A55QPu/II8+KZ4xL5r2qOtxgAW5T8/y32jDYjj1N/lMrTC90XJVuvkL5b+yhcskJurDwlrT/Hh/szHPLotKcQK8MJg/hg+2hh5XC3dcEgFWN0W8rLuNjcsi39cWked2o4tEhrwTGvNmZADdgj8p3S8iW4LBi10= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708550998; c=relaxed/simple; bh=jhbT5Cr5KxXONXs4T6cwnDbtOKqKVBRtP9a65KT+oaM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YzedvxynxA2q992kFTScLjF9QfO838B/4lw7h2PqggjiT6Gz8GR4tB1wpUzphb0bErKrxIsc71Ho42NazzybmI8ukJfsIy33ZmMnUobXyXq0IAffNZBhszVMTu3NoQkoKQE5FXIDlR6W3s2wygVbTN2krKfooJMkaL3wipOGThc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=D0FOyXkc; arc=none smtp.client-ip=209.85.166.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-7c00128de31so202247639f.3 for ; Wed, 21 Feb 2024 13:29:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708550996; x=1709155796; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=fHJzWSZbaUVkrjgtkdycbYKuoIbcz4QqReZXQuIUTd8=; b=D0FOyXkcN99A8U2pypJobo/iI1rVmSj6DKFobDqrZr7YyzHGpvKpwcRQGEIDw6EbPC +T4++/maF4JeYetwSfFO1/M/uhMW1BA3g7/eQWpodAJUFczLM1SgEa/ggFfvp+ENwyEU 0UvCXNhbjPVfWedQ2lVqe+3tPm0k0dQq/2hEQJZlmUS9fOuiy9CKIKwPDyU0Bxi7qK4/ INhd6nuqer6EPWnAx+EQrbhjntKaiU84ERlIbiNO3i1oV7jrKMNXvYOznFFw1IAURQig UVDg6rHDUUQfu57sr5rpsWUSd0oP3nArNmCYR/OK43USKT7O5o2cfmCLOM4gtI4sGOJ7 XrfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708550996; x=1709155796; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fHJzWSZbaUVkrjgtkdycbYKuoIbcz4QqReZXQuIUTd8=; b=gZ4t/aoGzMRtRKUEhFOehyy7sKWZW34rT61VyYrCaVBusI1CteIqb8MMj6R/SEzE4B xSm6QgyTt8OD43SJjBQcLu1NpUbKEbhrmKeDm/SYWPKu0DRaghzdt9SJSh+5jCmHKgLz wGPmOvElTxmNzm4NnoiJAqm+TVWlzUE+Sj/Yk0zP+GkIrG5rSnmSQNscpA0T7+cBA7jU hHYRMgN4NKMKbYG57j+vR+mEtB1rwmRp+gzJy/06ZCF4/CQBDWLfwjmc4vQcJ2uNXAc6 b1qr9TgOo+Rl9PP1Rf5yh8gkfNpzt8f8A0dtYgHqtfgZRQH9RIzmS7c800ugLuhyQhhO Noig== X-Forwarded-Encrypted: i=1; AJvYcCU+QdgW55RXWAYrFE5zkhAJMewGjswq1gyaef2tZKvgvGIQNoSDf+K+2wpRPd7xpTkNji4bF787axfUoa5TL3u8YnPfdLqtQsy6sltO X-Gm-Message-State: AOJu0YzP9BB70dqFrXhSalvZ6iEg0+rtMA9yNpM+UJtWeB9uWrFn39L0 IeUHeg+hBNEupfsuk/a16QbPRkhZnZ+buVYwKjWagTdPot8NJIP5Pe4Y3rsbaw== X-Received: by 2002:a05:6602:3fd1:b0:7c7:397c:6690 with SMTP id fc17-20020a0566023fd100b007c7397c6690mr17957645iob.17.1708550995732; Wed, 21 Feb 2024 13:29:55 -0800 (PST) Received: from google.com (161.74.123.34.bc.googleusercontent.com. [34.123.74.161]) by smtp.gmail.com with ESMTPSA id h21-20020a02c735000000b004742bbf11c0sm1712244jao.120.2024.02.21.13.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 13:29:54 -0800 (PST) Date: Wed, 21 Feb 2024 21:29:52 +0000 From: Justin Stitt To: David Gow Cc: Linus Torvalds , Shuah Khan , Guenter Roeck , Rae Moar , Matthew Auld , Arunpravin Paneer Selvam , Christian =?utf-8?B?S8O2bmln?= , Kees Cook , =?utf-8?B?TWHDrXJh?= Canal , Rodrigo Vivi , Matthew Brost , Willem de Bruijn , Florian Westphal , Cassio Neri , Javier Martinez Canillas , Arthur Grillo , Brendan Higgins , Daniel Latypov , Stephen Boyd , David Airlie , Maxime Ripard , "David S . Miller" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-xe@lists.freedesktop.org, linux-rtc@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-hardening@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 7/9] drm: tests: Fix invalid printf format specifiers in KUnit tests Message-ID: <20240221212952.bqw4rdz2i2yf3now@google.com> References: <20240221092728.1281499-1-davidgow@google.com> <20240221092728.1281499-8-davidgow@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240221092728.1281499-8-davidgow@google.com> Hi, On Wed, Feb 21, 2024 at 05:27:20PM +0800, David Gow wrote: > The drm_buddy_test's alloc_contiguous test used a u64 for the page size, > which was then updated to be an 'unsigned long' to avoid 64-bit > multiplication division helpers. > > However, the variable is logged by some KUNIT_ASSERT_EQ_MSG() using the > '%d' or '%llu' format specifiers, the former of which is always wrong, > and the latter is no longer correct now that ps is no longer a u64. Fix > these to all use '%lu'. > > Also, drm_mm_test calls KUNIT_FAIL() with an empty string as the > message. gcc warns if a printf format string is empty (apparently), so clang does too; under -Wformat-zero-length > give these some more detailed error messages, which should be more > useful anyway. > > Fixes: a64056bb5a32 ("drm/tests/drm_buddy: add alloc_contiguous test") > Fixes: fca7526b7d89 ("drm/tests/drm_buddy: fix build failure on 32-bit targets") > Fixes: fc8d29e298cf ("drm: selftest: convert drm_mm selftest to KUnit") > Signed-off-by: David Gow Reviewed-by: Justin Stitt > --- > drivers/gpu/drm/tests/drm_buddy_test.c | 14 +++++++------- > drivers/gpu/drm/tests/drm_mm_test.c | 6 +++--- > 2 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c > index 8a464f7f4c61..3dbfa3078449 100644 > --- a/drivers/gpu/drm/tests/drm_buddy_test.c > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c > @@ -55,30 +55,30 @@ static void drm_test_buddy_alloc_contiguous(struct kunit *test) > KUNIT_ASSERT_FALSE_MSG(test, > drm_buddy_alloc_blocks(&mm, 0, mm_size, > ps, ps, list, 0), > - "buddy_alloc hit an error size=%d\n", > + "buddy_alloc hit an error size=%lu\n", > ps); > } while (++i < n_pages); > > KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size, > 3 * ps, ps, &allocated, > DRM_BUDDY_CONTIGUOUS_ALLOCATION), > - "buddy_alloc didn't error size=%d\n", 3 * ps); > + "buddy_alloc didn't error size=%lu\n", 3 * ps); > > drm_buddy_free_list(&mm, &middle); > KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size, > 3 * ps, ps, &allocated, > DRM_BUDDY_CONTIGUOUS_ALLOCATION), > - "buddy_alloc didn't error size=%llu\n", 3 * ps); > + "buddy_alloc didn't error size=%lu\n", 3 * ps); > KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size, > 2 * ps, ps, &allocated, > DRM_BUDDY_CONTIGUOUS_ALLOCATION), > - "buddy_alloc didn't error size=%llu\n", 2 * ps); > + "buddy_alloc didn't error size=%lu\n", 2 * ps); > > drm_buddy_free_list(&mm, &right); > KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size, > 3 * ps, ps, &allocated, > DRM_BUDDY_CONTIGUOUS_ALLOCATION), > - "buddy_alloc didn't error size=%llu\n", 3 * ps); > + "buddy_alloc didn't error size=%lu\n", 3 * ps); > /* > * At this point we should have enough contiguous space for 2 blocks, > * however they are never buddies (since we freed middle and right) so > @@ -87,13 +87,13 @@ static void drm_test_buddy_alloc_contiguous(struct kunit *test) > KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size, > 2 * ps, ps, &allocated, > DRM_BUDDY_CONTIGUOUS_ALLOCATION), > - "buddy_alloc hit an error size=%d\n", 2 * ps); > + "buddy_alloc hit an error size=%lu\n", 2 * ps); > > drm_buddy_free_list(&mm, &left); > KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size, > 3 * ps, ps, &allocated, > DRM_BUDDY_CONTIGUOUS_ALLOCATION), > - "buddy_alloc hit an error size=%d\n", 3 * ps); > + "buddy_alloc hit an error size=%lu\n", 3 * ps); > > total = 0; > list_for_each_entry(block, &allocated, link) > diff --git a/drivers/gpu/drm/tests/drm_mm_test.c b/drivers/gpu/drm/tests/drm_mm_test.c > index 1eb0c304f960..f37c0d765865 100644 > --- a/drivers/gpu/drm/tests/drm_mm_test.c > +++ b/drivers/gpu/drm/tests/drm_mm_test.c > @@ -157,7 +157,7 @@ static void drm_test_mm_init(struct kunit *test) > > /* After creation, it should all be one massive hole */ > if (!assert_one_hole(test, &mm, 0, size)) { > - KUNIT_FAIL(test, ""); > + KUNIT_FAIL(test, "mm not one hole on creation"); > goto out; > } > > @@ -171,14 +171,14 @@ static void drm_test_mm_init(struct kunit *test) > > /* After filling the range entirely, there should be no holes */ > if (!assert_no_holes(test, &mm)) { > - KUNIT_FAIL(test, ""); > + KUNIT_FAIL(test, "mm has holes when filled"); > goto out; > } > > /* And then after emptying it again, the massive hole should be back */ > drm_mm_remove_node(&tmp); > if (!assert_one_hole(test, &mm, 0, size)) { > - KUNIT_FAIL(test, ""); > + KUNIT_FAIL(test, "mm does not have single hole after emptying"); > goto out; > } > > -- > 2.44.0.rc0.258.g7320e95886-goog > Thanks Justin