mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Maciej Wieczór-Retman" <maciej.wieczor-retman@intel.com>,
	Shuah <shuah@kernel.org>
Cc: Reinette Chatre <reinette.chatre@intel.com>,
	linux-kselftest@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 1/8] selftests: Add printf attribute to kselftest prints
Date: Thu, 12 Oct 2023 16:06:21 +0300 (EEST)	[thread overview]
Message-ID: <fe517843-8b27-99c5-99c-f4fba4f2d2@linux.intel.com> (raw)
In-Reply-To: <4h2eu6yhodrujbvem24v7cwal5tnk2agsqulpxwi4myk7n35uq@phbxlajivrpq>

[-- Attachment #1: Type: text/plain, Size: 2610 bytes --]

On Thu, 12 Oct 2023, Maciej Wieczór-Retman wrote:

> On 2023-10-11 at 13:40:48 -0600, Shuah wrote:
> >On 10/11/23 02:23, Maciej Wieczor-Retman wrote:
> >> Kselftest header defines multiple variadic functions that use printf
> >> along with other logic.
> >> 
> >> There is no format checking for the variadic functions that use
> >> printing inside kselftest.h. Because of this the compiler won't
> >> be able to catch instances of mismatched printf formats and debugging
> >> tests might be more difficult.
> >> 
> >> Add the common __printf attribute macro to kselftest.h.
> >> 
> >> Add __printf attribute to every function using formatted printing with
> >> variadic arguments.
> >> 
> >> Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
> >> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> >> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
> >> ---
> >> Changelog v4:
> >> - Fix typo in patch subject. (Reinette)
> >> - Add Reinette's reviewed-by tag.
> >> 
> >
> >I still need information on how you found these problems. Please
> >add it to change log for each of these patches.
> 
> Sure, I'll add notes on methodology to patches 2-8. I understand that
> this patch (1/8) message doesn't need that addition since the problems
> it exposes are in separate patches.
> 
> Or would you like me to also note here more specifically what effect it
> has in the rest of the series?
> 
> >I am seeing checkpatch warning:
> >
> >WARNING: Prefer __printf(a, b) over __attribute__((format(printf, a, b)))
> >#102: FILE: tools/testing/selftests/kselftest.h:81:
> >+#define __printf(a, b)   __attribute__((format(printf, a, b)))
> 
> Running checkpatch.pl with --show-types shows the
> PREFER_DEFINED_ATTRIBUTE_MACRO is raised. From looking at the error
> message in the script it looks like a false positive:
> 	"Prefer $new over __attribute__(($orig_attr$params))\n"
> 
> Please correct me if my train of thought is wrong but I think checkpatch
> sees __printf() macro defined and it sees it's raw version
> "__attribute__((format(printf, a, b)))" which it wants to replace with
> the macro. But since the raw version is found in the define line that is
> obviously not possible.

Yes, this is clearly a false positive from checkpatch. Checkpatch's logic 
cannot differentiate the definition from the use of __printf(), it just 
assumes __printf() is there already, which is not true for selftests.

The patch adds the capability to use __printf() elsewhere in the 
selftests code but of course the definition of __printf() itself has to 
use __attribute__().

-- 
 i.

  reply	other threads:[~2023-10-12 13:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11  8:23 [PATCH v5 0/8] Add printf attribute to kselftest functions Maciej Wieczor-Retman
2023-10-11  8:23 ` [PATCH v5 1/8] selftests: Add printf attribute to kselftest prints Maciej Wieczor-Retman
2023-10-11 19:40   ` Shuah
2023-10-12  7:32     ` Maciej Wieczór-Retman
2023-10-12 13:06       ` Ilpo Järvinen [this message]
2023-10-12 14:30       ` Shuah Khan
2023-10-13 11:41         ` Maciej Wieczór-Retman
2023-10-11  8:23 ` [PATCH v5 2/8] selftests/cachestat: Fix print_cachestat format Maciej Wieczor-Retman
2023-10-11  8:23 ` [PATCH v5 3/8] selftests/openat2: Fix wrong format specifier Maciej Wieczor-Retman
2023-10-11  8:24 ` [PATCH v5 4/8] selftests/pidfd: Fix ksft print formats Maciej Wieczor-Retman
2023-10-11  8:24 ` [PATCH v5 5/8] selftests/sigaltstack: Fix wrong format specifier Maciej Wieczor-Retman
2023-10-11  8:24 ` [PATCH v5 6/8] selftests/kvm: Replace attribute with macro Maciej Wieczor-Retman
2023-10-11  8:24 ` [PATCH v5 7/8] selftests/mm: Substitute attribute with a macro Maciej Wieczor-Retman
2023-10-11  8:24 ` [PATCH v5 8/8] selftests/resctrl: Fix wrong format specifier Maciej Wieczor-Retman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe517843-8b27-99c5-99c-f4fba4f2d2@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=reinette.chatre@intel.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®