Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2352638rbb; Tue, 27 Feb 2024 21:27:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVWQGqSsl4eYsgC0OkXQBbLDTv3J3CWExpKmfvlbcJ7/kinx1O4yiPHynZIZpDZ8QJKPUStqIDjlzaq5iE5YO6Wlczqe9YKnlhHss+C6w== X-Google-Smtp-Source: AGHT+IHVzQkvKkOVb+E9QuNkFxMyg2aCe8Cvxb71WeC43utMEsIjSN27mclhRWSWJt6PSfsUyku9 X-Received: by 2002:a05:622a:19a9:b0:42e:5a82:2965 with SMTP id u41-20020a05622a19a900b0042e5a822965mr13812845qtc.34.1709098059563; Tue, 27 Feb 2024 21:27:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709098059; cv=pass; d=google.com; s=arc-20160816; b=wxOYBU1VWG9iMosXQv33hndm+W7tEv6HNPlN3boh/Muyi1xsYtgbY05i5t50Yb1uwo TkTwpb2h0pHRlU70fDqT3nDG5+dq9yeFlHZQT2/BlVSVLQJzBL7DMDz4ELYv1NZ0Gka2 WNRVGOcLja3ILRkEyjrCs0R0vjJ4i28B/zRDjUg8cuZdMPxt9nXi565O1r0fkLJzoAKT iO2ybPIfzQfT4gvRNb5d7mmXSRz/smi9afZqel+CI4mPFBhV9J/lYCLmhe1gpf6wh+2c Bu66FbuN5PVmkwX7QX/4a7is4TmAo+nW2W823S7LkOJLnY4vE4CTpezu3Tw9ljDCz0BJ YQLw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:dkim-signature; bh=3qlQXkJNmXY3V9U5JrSaKD9CZoD39fkjGBycAj3A9pQ=; fh=Nc+ZZTM+RtEiSCKt7ixnh8r3GMXjSzAHSrky3BB+kNo=; b=BnT+NFW38/2MZPe3E6Xz7CJzUkRBR/TBJVvasl594lD1O66CIyfodyfnV+sjsDlodC BZoTV6FUeDf9DdaHUXa3+L+5V8bbMorvSUcc+PxXOu08IjeRBBbjeFx28FFMsg3UFdyG RLFyBUgAAYMsVg1RzY1QbnIKkbZivLnxWFkmCNXeN8YuKU/Hyum0jPyXkJtaXHR8SibR rpPQXkuTUv+9fS6lddSqwFE/XTEISjInX1C0jC6GvwbAvcCL1Q2scA2AMiEWo7WU0CGS meosIdQibYRXamkdoCj+u7jpfYr5JGrbldPmu0rbA56MdoaZpa52Um+m5v2HjQtVTfBb 7R5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=K8deY+mg; arc=pass (i=1 spf=pass spfdomain=flex--davidgow.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w10-20020ac8718a000000b0042e7f2d4bf8si6656550qto.163.2024.02.27.21.27.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 21:27:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=K8deY+mg; arc=pass (i=1 spf=pass spfdomain=flex--davidgow.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84535-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 45B511C230AA for ; Wed, 28 Feb 2024 05:27:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 906ED21101; Wed, 28 Feb 2024 05:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="K8deY+mg" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 03744210EC for ; Wed, 28 Feb 2024 05:27:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709098051; cv=none; b=UJohvyaOyEsL3l+tG19ROwQx2cUgzt7VuRVoWQsL/LKa5FVejudUSB3VOGk2vvmgZRVQYcpFzjzA+nU5s/0TfQsnxRsKfmvC0LpdkQKywP65/UNFRejz6ba3ObishUOMgw1/xRcN/YGkiLDXuonUKkKjSRiR4qjPSWAnnkSPQHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709098051; c=relaxed/simple; bh=f91w+0QC3qP9EU7d+4+laz201VJZGD/uwQ2hj2v9Y8s=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=oYiKIxUfmc6aABrKawzRqZktRnk1ULevNQ5n7Qo5Ilpqp6mTViD0MPaMPm+QBZU09l0fnzFGENqy4300ujAYUUkMsuai0uYp5N57EwYU+RcdqcAP2JSqr5nZyhyjIzYdGnIPa8XpxtOo9SyyKNygTy3J4afMW8JS2huGv/TG1Bs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=K8deY+mg; arc=none smtp.client-ip=209.85.219.202 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=flex--davidgow.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6b26845cdso7448595276.3 for ; Tue, 27 Feb 2024 21:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709098049; x=1709702849; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=3qlQXkJNmXY3V9U5JrSaKD9CZoD39fkjGBycAj3A9pQ=; b=K8deY+mgb02H7CYEmxZXBGFs4WVQKH/MEe+c3P5i+FDd8GJ6ua0QFFz9FdQT6ct8jR t9EV+hZp/q+xlJBJO+P+4HRhYC0x1eS9YebKf8EASYhp0zLdNGe6UDIKptVHUBbJ+XiG Gi9nYw5ptGX7bum5lMYyM3YP6WoTaY50Mjz58e+ykUyszNqtBk8dgI8SKmMKBOTDZU/M C7xPd1IPWVaXUvMSMvbrGDqEUNe7U/npR3pYKZSMFIt6DUy4MRtWhVxAHOtK24o9T17e L6o55kilsL/C6NcSLv/ZbjZsGYYmRtT7Wld7/KdcWkG8L+h/hl3+l9K8tLBa9JDJveV/ pRAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709098049; x=1709702849; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3qlQXkJNmXY3V9U5JrSaKD9CZoD39fkjGBycAj3A9pQ=; b=ZdA6XM0K2mITeOz/jSYa9kKaHmeSdg7phtcCi5YxoSHGVA8GYURnWESh05Bt4YP3vD r8j5nLqDwqigMTek6QUDacyBqyrrm9xOVcierWEzNQ1X/fpO3r6JAfoAQwvkysw86M+I nwAluQNkNw7IEjuG6OKBPAte4Cga/C94VkAT77Qkph2eEnB1Nd5bCBGjwGlnpehmah4L MHDOMeWoCuuy7EBCWNWi63mSvojaYIamtTcfob/AJP8O+v18fYXJa4KqwdtSmpxdd5OL do1/ooop7LBMkABwNtSMIMf77nNwQ6uL53DT3tiAr1XHgTGJz7zuJm1PPZVjqExaapbr Lrng== X-Forwarded-Encrypted: i=1; AJvYcCVXJTEbbA+Ddo6r8TKGo/IEi3Nw/3gc5vYwnb23TQ8IgcobcjFQYBeCHzl6LZN1vSooNisqQaiqHeYZiitIph9h4G4LJVlMu6S3UfsU X-Gm-Message-State: AOJu0YxvScBRx6O9naDtuZNzMQkEuffnR9s5Oj/t0i8nT58zIk0znTS+ 7EBj3h+oZYdywaL4JlcTujxzwsRsA6rI5/J14f6H0IT/ptrZZoRgKgbquBvBuVehfLsGD6mW+Ji mU+qnM5eqTg== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a25:b341:0:b0:dcb:bc80:8333 with SMTP id k1-20020a25b341000000b00dcbbc808333mr455657ybg.13.1709098049017; Tue, 27 Feb 2024 21:27:29 -0800 (PST) Date: Wed, 28 Feb 2024 13:27:20 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog Message-ID: <20240228052722.409679-1-davidgow@google.com> Subject: [PATCH v2] drm: tests: Fix invalid printf format specifiers in KUnit tests From: David Gow To: Linus Torvalds , Shuah Khan , Guenter Roeck , Rae Moar , Matthew Auld , Arunpravin Paneer Selvam , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , "=?UTF-8?q?Ma=C3=ADra=20Canal?=" , Rodrigo Vivi , Matthew Brost , Javier Martinez Canillas , Arthur Grillo Cc: David Gow , Brendan Higgins , Daniel Latypov , David Airlie , Maxime Ripard , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Justin Stitt Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 and clang warns if a printf format string is empty, 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 targ= ets") Fixes: fc8d29e298cf ("drm: selftest: convert drm_mm selftest to KUnit") Reviewed-by: Matthew Auld Acked-by: Christian K=C3=B6nig Tested-by: Guenter Roeck Reviewed-by: Justin Stitt Signed-off-by: David Gow --- Changes since v1: https://lore.kernel.org/linux-kselftest/20240221092728.1281499-8-davidgow@g= oogle.com/ - Split this patch out, as the others have been applied already. - Rebase on 6.8-rc6 - Add everyone's {Reviewed,Acked,Tested}-by tags. Thanks! --- 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 2f32fb2f12e7..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 kuni= t *test) KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size, ps, ps, list, 0), - "buddy_alloc hit an error size=3D%u\n", + "buddy_alloc hit an error size=3D%lu\n", ps); } while (++i < n_pages); =20 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=3D%u\n", 3 * ps); + "buddy_alloc didn't error size=3D%lu\n", 3 * ps); =20 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=3D%u\n", 3 * ps); + "buddy_alloc didn't error size=3D%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=3D%u\n", 2 * ps); + "buddy_alloc didn't error size=3D%lu\n", 2 * ps); =20 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=3D%u\n", 3 * ps); + "buddy_alloc didn't error size=3D%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 kuni= t *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=3D%u\n", 2 * ps); + "buddy_alloc hit an error size=3D%lu\n", 2 * ps); =20 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=3D%u\n", 3 * ps); + "buddy_alloc hit an error size=3D%lu\n", 3 * ps); =20 total =3D 0; list_for_each_entry(block, &allocated, link) diff --git a/drivers/gpu/drm/tests/drm_mm_test.c b/drivers/gpu/drm/tests/dr= m_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) =20 /* 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; } =20 @@ -171,14 +171,14 @@ static void drm_test_mm_init(struct kunit *test) =20 /* 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; } =20 /* 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; } =20 --=20 2.44.0.rc1.240.g4c46232300-goog