From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ACDJmluh" 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: netdev@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; > } >