Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2365900rdb; Wed, 21 Feb 2024 05:41:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUkX8WJpR43NG3vtefZ+QfXj3izzxi5vVLvPyDO9fpWk5Og+fsAWyonCmhsgBMkA9lnYZZHlmKLt0Pi89y5wwxNQWELRh7J5i0f58z8VQ== X-Google-Smtp-Source: AGHT+IGg4HNQ37UF+hF0Ub523Hcc+m4yeWWnIvKTCQiifJhGAHQMJvGqB1Qw81/SvdD3RbFdEvjz X-Received: by 2002:a05:6358:57a8:b0:17b:5c7c:2801 with SMTP id m40-20020a05635857a800b0017b5c7c2801mr1647299rwf.14.1708522917497; Wed, 21 Feb 2024 05:41:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708522917; cv=pass; d=google.com; s=arc-20160816; b=xIff2nU8yLtiQLFtbW9NnHcOfcoJvvUV6Nnk2v3I/Zdst9+85pYMuhRacfIbuxdvaz nxG8JDx8G+OyTmA2wOtDl+y0Wl41Jy7OSmmeurN03/XF9hxl6cSBs8KYHztyBHRSw71M HNdw1wGhz3l9yBfHOZRDvGKd4FEfF2zRvIgijXQqWLkNfJYWeWkfpBTV2/U92Jkx0ggi K2xjR7yKARClIaS1UckmG8Y7972+2SOxrECNI+bebON56EnENAYawKUDKvpKDEKAx9Un rBbwYl8pzaf06V6L3nPbyz0ImPg75Tlu87v6ya1jJQuU7snbkhcm/3Irvl3P4XiSEuFE xmzQ== 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:sender:dkim-signature; bh=XoFhc6w6Or2jWzWThz9jNXXxehcO/WwM1R0QsjeWJp0=; fh=ponHxyjw9CeV5ZFQ8qEFGTqWROI/dUf682PjFLcx/qk=; b=DXa8iQRO5lguYVievqxl0uc1EqFM3P9UAWuXEkXz62JchvrATeNXBcDZFG2Ojxszgb MpDIbIkWcoe+29mob95UG3s+ui73jAoPVnjj5xjefJYZRbyIij8bVlKlKpH2v1MGi7YO TYezzFhAjy4PgFgRBZx+l5VS6WsIDcrhVWZCRP/Scs4KKi3iljjj5YmdftF187Pc8oj8 iua6Qslddh8TJwPAoZdNHejiCIVsA/f0MohBU8NdTwnHexcfNgklgOHnybRkLIBEhWT7 HFnYakFqd5g35Ig0PyxnNtpMZMjjpJZnkH38UJ7js3zRihqZ2HwTiJP+UvsOcFrz7vF+ tGMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ecyTr49F; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-74795-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74795-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i7-20020a639d07000000b005dc8372021bsi8449917pgd.464.2024.02.21.05.41.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 05:41:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74795-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ecyTr49F; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-74795-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74795-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 80225B21D00 for ; Wed, 21 Feb 2024 13:29:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DFC880028; Wed, 21 Feb 2024 13:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ecyTr49F" Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 A91BA79DAB; Wed, 21 Feb 2024 13:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708521988; cv=none; b=Io2+soarG0fWpF73WPNe1CGanTzKlBk87LtknVthBmqvIZdOKCbjqkAwjNY+EjAWe5Qsg+QfkEZ810uf4Te5BfHov+agrd6RbZfvQKCneVkmpnZGaT+apQTzgp0uMPgsMt56ZeznJU+iVNTK0g2+JwqntTfaZymY2KQ33aBIvGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708521988; c=relaxed/simple; bh=5V1bV3pAIFIuTSQWqdDobRb+DukBqlTZwfc7iDi3qX8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OYe16JDj5H0x9v5mOgDxdNgHO3m34yc8bq6TdE2KaVqqZPe4NRPcXB2KdFbWxFVWnMbFAGF4DvLViYDxQao6GUESUN1I8AsvPy0myCadFYbp1FCVm0UwIKXmSNUqDAU0yjSNJKRYArabRMGRpdbtUW1sy3I+/BQH+YoptH2aIP8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ecyTr49F; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5ca29c131ebso393992a12.0; Wed, 21 Feb 2024 05:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708521986; x=1709126786; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=XoFhc6w6Or2jWzWThz9jNXXxehcO/WwM1R0QsjeWJp0=; b=ecyTr49FxuypQizLCr7RmSPCyEVRsj3Dcmap/wy4p71bX61Zi8YX/4cNmrVXIYJ3zF qVXScHb9w0pjvfn0c8tpQlIDPAxy9Hgn775JvdjuX50x4xIw+Ic3//OLYdLTKZfeJtEt zAW2eAi84mzPItcwC6zZSG9j+Ri5H0gWEBUvidMVtmnxnYaEyfdXlPerSVNvRryEcXWL L78xgTjG6VrzayaGyrjfgYXRQc3vd3rPZl83h9MiLs+c1qfWlNOISL7nKIeelbDLgexq XvoLDCmfwPRG/ZX73vbX07//g3nupwDG4rvFzbcwD0OASBQgFf66mOBcVT539SqDueRY 4a6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708521986; x=1709126786; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XoFhc6w6Or2jWzWThz9jNXXxehcO/WwM1R0QsjeWJp0=; b=xAus5rky4eP+Buxu79wXPAcxrYpvfWgjokzGiRDZUCWZ2iCDKqb4+fr28L0Yd02oM7 FaHblEy54HDc21Xd+kHoFM1ZazpsTTFqgfVYw3xfi25QEDe+mBK65Cjw+x8AyhkGX3xu 9hjZGB9LyVDqAD5puvXfsnipurE3HX06BZovf3dNXXhWK7Jow/mOLoD5ywEZ52nHivcz oO9CdAW1NKqznYcaOIaH6Bn6e2W8oW8QUpxsoTsIxq/piiE4FzAs5XKnGKuAqbarGake YzYBHRMAhKs/IKZjtO2LriQFxstleykGKyYVqvW6sq8C9QhFTZnBfd49KVzu7kojv+Ai ey2Q== X-Forwarded-Encrypted: i=1; AJvYcCUottvNQcK0f0YsrCLV65xa7DWxFJF99zMejWIcQ8dYQz9miBc3qkQucTBegVM79ZvFsBZR+Ds9eAe5j1SnkF2eJvI7XMNeDmzT+UA7DuW+kcZdt6G8GVwnRAAYPcCuNLk8F5nEXCCWaRxkJ72RJbltE6QwnFyMschUca0mQq/0VhKqyzh26llJaZ7EM24zTo9KVSOOnhPG5rltoDWBC+wc+pkRZpwnWUnCuwimf1luk7Siz97bBzvg2wVAvOqqhmPh X-Gm-Message-State: AOJu0YxYAVpoQxL9MYQ5PVGQUNvf3z5uxwiJM9DPEq5buHVqIilfdZ+1 Za5OxHdtyW5eG6aCl2kwmgYVpmFiO3N8pXq60aMw74/wyws+CDCr X-Received: by 2002:a05:6a21:3409:b0:19e:4ed7:127a with SMTP id yn9-20020a056a21340900b0019e4ed7127amr22674991pzb.46.1708521985850; Wed, 21 Feb 2024 05:26:25 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h9-20020a62b409000000b006e448fa3d93sm6999855pfn.174.2024.02.21.05.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 05:26:25 -0800 (PST) Sender: Guenter Roeck Date: Wed, 21 Feb 2024 05:26:24 -0800 From: Guenter Roeck To: David Gow Cc: Linus Torvalds , Shuah Khan , Rae Moar , Matthew Auld , Arunpravin Paneer Selvam , Christian =?iso-8859-1?Q?K=F6nig?= , Kees Cook , =?iso-8859-1?Q?Ma=EDra?= 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: 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> 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 > 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 Tested-by: Guenter Roeck > --- > 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 >