From patchwork Wed Feb 21 09:27:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 13565195 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 A08AF47A5D for ; Wed, 21 Feb 2024 09:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708507724; cv=none; b=rEkTlGQxfKEL/dW82BBDV5KSj+BvgYy5JH+WnAZ+kdtngLMrMHFoOSJUad04e91lxGo9n1exmPqjELCQ0yJDjwWyICMXAKyGdZ8cZUBOjh/8yy5JHA7HkuGo9x0MwG5B6z5wCmndyQ7AUxfIwDSogTF+5K5LhEDYvOSwtS0AxDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708507724; c=relaxed/simple; bh=MALY8PY87om1B5rM9PQyZB962vp0AzyA5B9YGRQAQS4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=J/h+Ycg3VP+tYL3JtGuob9jXioQK6FsVUuuGKnRLuEWiP7oIwqMCFRsW2f/ncrqILXT12etve5xqIxUwcDnpEz1cFUpM4jhNb38OOp1Syt+jOvHCyIZHv+9PZNuE5bzdcjkFbPJ6vCYNDLqoCVE+H2j1Ho8LRFoVUvh6sYObJ5Q= 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=lGexlX5D; arc=none smtp.client-ip=209.85.219.201 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lGexlX5D" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dced704f17cso2525605276.1 for ; Wed, 21 Feb 2024 01:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708507721; x=1709112521; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=UtSX1a4twDclpP0XCHq3xRlg28EKI7v3CFBboD2ALTI=; b=lGexlX5DBntYPjEQG6RjJ0FVsKToWINsWjjn43Ml34EhA3IoPvQpeE+rqHUk3I1I/h YznQjIDQnf+vGqDW/kE++pZBmelMsM/USqvYQHr9gSb8/+c4pFYCh7xQghyqkqpDjBSJ CK6jy8ETBZ8fpAclaaj8ACUDL7WGn0N58iow8E2+Hu5NljOEGw0Ji+v+2zJS0XvqjevZ ddlYiladtiHjXz/w5QM5wsloX3M1b1R/10seHUoVMyoQsDzYexETHOm7y0xkt4FASDMm tweykBtRw4lxmqPktku7Bo0UQJ7if4UHTAXpEBAAJMdODHBZDVEyJBzLvszgVsi5PiM+ yf5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708507721; x=1709112521; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UtSX1a4twDclpP0XCHq3xRlg28EKI7v3CFBboD2ALTI=; b=dlcZw/j4cckClUUGlcyetStDl/9xsqYm97DPgovBZ5PgjhfLee6SPW7OUJW7431Phj xt69aTjP2PLEZrch051+RPakK5hicsoF1ZsbnFX99MMcfFIPXAvLxx+5NZyn+qv5/UlL YXupr7wrvngPwZVkcmIYYs32jtqMkE4C6cbYntFXFPERETQQXrGVxoki+rX3LrA9qr71 MxAzZXlh3lUxqhLzMRm+GOff02s3YObo+MxS7Ufe8L7aeXtB1o+HbBTlHOv2DdMlrCcn fOTKNiCw92HP5u2uEigjYLiXVt6Ndi5JMpBqdrngs/eFaXSh8Ybqb93m5oqhGWd8nl0H 7LbQ== X-Forwarded-Encrypted: i=1; AJvYcCUJsu2J3BWk5Hz9tDzYPAKicg0kp32nSoQv9MIOOm4QLlDy1UUeo1O8RZAkCTG6a1A7z2wKGhO0gxXAVIENYLe8qaRdwl5U X-Gm-Message-State: AOJu0YwGafihjivYp3xLXODV0118I0Tp+UXc5nE/GLAK5vmuS9+W5e0H 3KopBuNA0UGlnUxLTP2wcpgZy1oyMknVAQPrBkkEmtYQiDH6iyke7lq7+LYRmO+7W0voGg9qVtX KYQsJCn2NmQ== X-Google-Smtp-Source: AGHT+IE+u4BHsnTY4zBV9uwlLnSALfH2VACViqUl+6ZdsI4Ll1wRpv0qUeWfBww+/YNGvG/0sUR+LBCAIAUp6Q== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a05:6902:4ce:b0:dc7:865b:22c6 with SMTP id v14-20020a05690204ce00b00dc7865b22c6mr618682ybs.8.1708507721736; Wed, 21 Feb 2024 01:28:41 -0800 (PST) Date: Wed, 21 Feb 2024 17:27:22 +0800 In-Reply-To: <20240221092728.1281499-1-davidgow@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240221092728.1281499-1-davidgow@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221092728.1281499-10-davidgow@google.com> Subject: [PATCH 9/9] kunit: Annotate _MSG assertion variants with gnu printf specifiers From: David Gow To: Linus Torvalds , Shuah Khan , Guenter Roeck , Rae Moar , Matthew Auld , Arunpravin Paneer Selvam , " =?utf-8?q?C?= =?utf-8?q?hristian_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: David Gow , 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 KUnit's assertion macros have variants which accept a printf format string, to allow tests to specify a more detailed message on failure. These (and the related KUNIT_FAIL() macro) ultimately wrap the __kunit_do_failed_assertion() function, which accepted a printf format specifier, but did not have the __printf attribute, so gcc couldn't warn on incorrect agruments. It turns out there were quite a few tests with such incorrect arguments. Add the __printf() specifier now that we've fixed these errors, to prevent them from recurring. Suggested-by: Linus Torvalds Signed-off-by: David Gow Tested-by: Guenter Roeck Reviewed-by: Justin Stitt --- include/kunit/test.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/kunit/test.h b/include/kunit/test.h index fcb4a4940ace..61637ef32302 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -579,12 +579,12 @@ void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt, void __noreturn __kunit_abort(struct kunit *test); -void __kunit_do_failed_assertion(struct kunit *test, - const struct kunit_loc *loc, - enum kunit_assert_type type, - const struct kunit_assert *assert, - assert_format_t assert_format, - const char *fmt, ...); +void __printf(6, 7) __kunit_do_failed_assertion(struct kunit *test, + const struct kunit_loc *loc, + enum kunit_assert_type type, + const struct kunit_assert *assert, + assert_format_t assert_format, + const char *fmt, ...); #define _KUNIT_FAILED(test, assert_type, assert_class, assert_format, INITIALIZER, fmt, ...) do { \ static const struct kunit_loc __loc = KUNIT_CURRENT_LOC; \