Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2270476rdb; Wed, 21 Feb 2024 02:22:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWX3XaXAkANEIMAGLw18TULM1QVIqfnIpXcUwj/2UQJxMUMSjHZ3o0XUgI6PSNx3kRDXSb4T0aXyIQe3+G5rv6me1St25jQCcYgqv1yNQ== X-Google-Smtp-Source: AGHT+IGpp6dJ1A7O3hnrnKuY8ZUtP7ABILdgpoo1N+7AT1hlcCBKwnoGoEw7VBBS9drnPKHxOEDe X-Received: by 2002:ac8:7e89:0:b0:42e:3cd8:bb27 with SMTP id w9-20020ac87e89000000b0042e3cd8bb27mr615331qtj.29.1708510929933; Wed, 21 Feb 2024 02:22:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708510929; cv=pass; d=google.com; s=arc-20160816; b=kWPtWyO+/dEGni3oGyIzGLaJPyagRPLKEWWRggJ/kIoi1NaMLSGO8iSn90Uf03vzaa 9tzABqhX5kQY+iqiBjC8qwcd/zkpkcKGJ7AC2b5wLik2RZs9wDIAzfcy5aOnU1gGksK1 3wrC0lqf7y5iURx9lz6ZzXEERpww5U6Orahw03qYwXl46lsXyYLmaAeQklqoyr+pDCD1 VY35PK0CwcmCYH0RkMZJGwyx55wNATaRrT356krjq959ERcwLpYiiX/AFARM0KlPCt7v zlhKMERXkk1fJ7atTyxMTY9q3ptApi68zz4tY4qygaoiJiWlypJqPkY/LeRLZHO9yInr dizw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=gYTOzfiFF+5Xa9cOlb3iH0rrqfNNbcOf5RB2pPfh9X0=; fh=49Zoe3pVnMA4UpTaUDImfYD5pvDfeNwgck4e+zQ3FDk=; b=BgcBxfG6uEtaQ9B0EoWFhw0YG5g+07q2QhCONNsWCxQ1Dvwyemezrfm5V5U/Bj787R o8Xkw1SZquiYzX4B4/nSgdrktkdtCA4NcWeFTZWNg7cBntlIx1l/fdT67BE535G1ooS6 wnxvoWNFr+WEbEDXoapq575C07eJrIAdtUIoOn/BJYBz1tID+pyqFDvO0LrzPb/4k7zb A0mARlu25dhuGoiKo9icXfOQ6OikJshkRy65m8QycIzfC6HixNPq3BDjWzNXfyNWVSJu F34/GFw8GFUS2tuTGoxnA2fwOA38jDrXGvHI4OyMqjH9Tzk28r+OblaR+HBBha9cE30v jj2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ACDJmluh; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-74515-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74515-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y12-20020ac8708c000000b0042db680d768si6671463qto.646.2024.02.21.02.22.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 02:22:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74515-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ACDJmluh; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-74515-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74515-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A0A221C22AC7 for ; Wed, 21 Feb 2024 10:22:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A7893E46D; Wed, 21 Feb 2024 10:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ACDJmluh" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DD533D970; Wed, 21 Feb 2024 10:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708510916; cv=none; b=sOaL+Pp34ZKyRm2XF89aKyLnNejvLeV9KY+eLkekY8vj23K5h4F3UJwLJf7DWxXe2ILgY9T2CHKaJIFyO9ufnfuwWFA22mIUM0+to9xD4AJZ2cEL7M8EyBYDRkXzOt7W1LaP1njK5SxOsR+tFyVt0uX50S/5i132/lNL5Ipb8II= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708510916; c=relaxed/simple; bh=zLzzvJfbVa6ODHn00Dyc4JUBC3zDKDHRQgbVtNkryF0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MSBEwP77//24wNP0GrBt14XiFgyR6b4Lwd5cdiD2lAEkNDIA/Ls38b9+iE6ihw6/YNlSU8srw3IwJM+Nrl/MZI8CV1JNgLF4dX+Pnt8IWkRostRvRUUxnBq2NhxWHkAW08V9Si3J+rdGf5wUSjswkmX93Bjc6eU3FMmvUZa4iSA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ACDJmluh; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708510914; x=1740046914; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=zLzzvJfbVa6ODHn00Dyc4JUBC3zDKDHRQgbVtNkryF0=; b=ACDJmluhI/oB5lXEt1f3U9r+69PaaY4MEeN4rLmaT1lc4rbFsDX1pguT NWyL8xz6cDO6zSiN1j9YoQN2lIUKtSmlpp4mBSy83sTYvtnCCd9RIXSfK ifE25/9O+ycDYLiAED2lqo6cBKKFLeGAaSzKDfmMM9fwFYn6p3y2zKvit esDu1CqNosKOnLxtdt3nme6OXi98siT8XNwLGGNlh4bkR5z1bQhavlBdK mlRUddk/cX9PZubOjnI+tNouJIM5vxBeEi0LzNA3+yDGKL4dbA0NyP9f9 h/V2wwgXJfBamFTr/EqQECSZtRyAGrDMN5gXLXvyXrwiWBcAz9V7OwPTF w==; X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="3141145" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="3141145" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 02:21:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="9717365" Received: from conorwoo-mobl1.ger.corp.intel.com (HELO [10.252.22.137]) ([10.252.22.137]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 02:21:47 -0800 Message-ID: <391b3603-52bc-4b07-9a50-7261971ee39f@intel.com> Date: Wed, 21 Feb 2024 10:21:42 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 7/9] drm: tests: Fix invalid printf format specifiers in KUnit tests To: David Gow , Linus Torvalds , Shuah Khan , Guenter Roeck , Rae Moar , Arunpravin Paneer Selvam , =?UTF-8?Q?Christian_K=C3=B6nig?= , Kees Cook , =?UTF-8?Q?Ma=C3=ADra_Canal?= , Rodrigo Vivi , Matthew Brost , Willem de Bruijn , Florian Westphal , Cassio Neri , Javier Martinez Canillas , Arthur Grillo Cc: 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 References: <20240221092728.1281499-1-davidgow@google.com> <20240221092728.1281499-8-davidgow@google.com> Content-Language: en-GB From: Matthew Auld In-Reply-To: <20240221092728.1281499-8-davidgow@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 21/02/2024 09:27, 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 > 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 > --- > 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); There was also a fix for this in: 335126937753 ("drm/tests/drm_buddy: fix 32b build"), but there everything was made u32. Reviewed-by: Matthew Auld > > 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; > } >