From: sashiko-bot@kernel.org
To: "Alejandro Colomar" <alx@kernel.org>
Cc: devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 4/5] string: Add [C]QChar_of() and QVoid_of()
Date: Tue, 10 Nov 2026 15:45:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-207285@kernel.org> (raw)
In-Reply-To: <415453a31ebf1aed3b41da1a28913f5cbe58f175.1794323750.git.alx@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] string: void pointer subscript in QVoid_of() breaks Clang
builds
- [Medium] string: QChar_of() fails to compile when pointee has
qualifiers other than Q
--
commit cea37634307d89ede7b6ca6128f006d50a90391c
Author: Alejandro Colomar <alx@kernel.org>
string: Add [C]QChar_of() and QVoid_of()
This commit introduces the QVoid_of(), QChar_of(), and CQChar_of() helper
macros in include/linux/string.h to support qualifier-generic string macros.
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 3a70ba9ed3021..cb096e9eb9835 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -14,6 +14,36 @@
> #include <linux/stdarg.h>
> #include <uapi/linux/string.h>
>
> +/**
> + * QVoid_of - qualified void of
> + *
> + * @p: Pointer to test for qualifiers
> + *
> + * This macro produces the type name 'void',
> + * qualified with any qualifiers present in the element of @p.
> + */
> +#define QVoid_of(p) typeof((__QVoidptr_of(p)){0}[0])
> +#define __QVoidptr_of(p) typeof(1?(p):(void*){0})
[Severity: High]
Does applying the array subscript [0] to a void pointer in QVoid_of()
break Clang builds?
__QVoidptr_of(p) produces a pointer to (qualified) void. Because array
subscripting requires a pointer to a complete object type, Clang rejects
(__QVoidptr_of(p)){0}[0] even inside typeof() with an incomplete type
error, and GCC emits a -Wpointer-arith warning when pointer arithmetic
warnings are enabled. Using unary * instead of [0], such as
typeof(*(__QVoidptr_of(p)){0}), avoids both issues.
> +
> +/**
> + * QChar_of - qualified char of
> + *
> + * @Q: Qualifier to test.
> + * @p: Pointer to test for the @Q qualifier
> + *
> + * This macro produces the type name 'char',
> + * @Q-qualified iff the input pointer points to a @Q-qualified element.
> + */
> +#define QChar_of(Q, p) typeof \
> +( \
> + _Generic((QVoid_of(p) *){0}, \
> + Q void *: (Q char){0}, \
> + void *: ( char){0} \
> + ) \
> +)
[Severity: Medium]
Can QChar_of() fail to compile when the pointed-to type of p carries a
qualifier other than Q?
QVoid_of(p) preserves all qualifiers on the target of p, but the _Generic
selection only matches exact Q void * and unqualified void *. Passing a
volatile char * or const volatile char * to CQChar_of(p) produces a
volatile void * or const volatile void * controlling expression, which
matches neither association and fails at compile time. Matching against
Q QVoid_of(p) *: (Q char){0} and default: (char){0} would test specifically
for Q regardless of other qualifiers.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794323750.git.alx@kernel.org?part=4
next prev parent reply other threads:[~2026-11-10 15:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 15:33 [PATCH v3 0/5] Add strprefix() and fix a bug with it Alejandro Colomar
2026-11-10 15:33 ` [PATCH v3 1/5] string: Add strprefix(), and deprecate str_has_prefix() Alejandro Colomar
2026-11-10 15:47 ` Joe Perches
2026-11-10 16:14 ` Alejandro Colomar
2026-11-11 8:43 ` Steven Rostedt
2026-11-10 15:33 ` [PATCH v3 2/5] device property: Fix fwnode_name_eq() for empty node names Alejandro Colomar
2026-11-10 15:33 ` [PATCH v3 3/5] stddef: Add const_cast() Alejandro Colomar
2026-11-11 10:25 ` David Laight
2026-11-11 10:51 ` Alejandro Colomar
2026-11-10 15:33 ` [PATCH v3 4/5] string: Add [C]QChar_of() and QVoid_of() Alejandro Colomar
2026-11-10 15:45 ` sashiko-bot [this message]
2026-11-11 0:03 ` Alejandro Colomar
2026-11-10 15:33 ` [PATCH v3 5/5] string: Make strprefix() const-qualifier-generic Alejandro Colomar
2026-11-10 15:44 ` sashiko-bot
2026-11-11 0:27 ` Alejandro Colomar
2026-11-10 16:32 ` Joe Perches
2026-11-10 23:27 ` Alejandro Colomar
2026-11-11 10:28 ` David Laight
2026-11-11 10:59 ` Alejandro Colomar
2026-11-11 10:34 ` David Laight
2026-11-11 11:28 ` Alejandro Colomar
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=sashiko-outbox-207285@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alx@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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