public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.19-6.18] kselftest/kublk: include message in _Static_assert for C11 compatibility
       [not found] <20260210233123.2905307-1-sashal@kernel.org>
@ 2026-02-10 23:30 ` Sasha Levin
  0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2026-02-10 23:30 UTC (permalink / raw)
  To: patches, stable
  Cc: Clint George, Ming Lei, Shuah Khan, Sasha Levin, nathan,
	linux-block, llvm

From: Clint George <clintbgeorge@gmail.com>

[ Upstream commit 3e6ad272bb8b3199bad952e7b077102af2d8df03 ]

Add descriptive message in the _Static_assert to comply with the C11
standard requirement to prevent compiler from throwing out error. The
compiler throws an error when _Static_assert is used without a message as
that is a C23 extension.

[] Testing:
The diff between before and after of running the kselftest test of the
module shows no regression on system with x86 architecture

[] Error log:
~/Desktop/kernel-dev/linux-v1/tools/testing/selftests/ublk$ make LLVM=1 W=1
  CC       kublk
In file included from kublk.c:6:
./kublk.h:220:43: error: '_Static_assert' with no message is a C23 extension [-Werror,-Wc23-extensions]
  220 |         _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7);
      |                                                  ^
      |                                                  , ""
1 error generated.
In file included from null.c:3:
./kublk.h:220:43: error: '_Static_assert' with no message is a C23 extension [-Werror,-Wc23-extensions]
  220 |         _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7);
      |                                                  ^
      |                                                  , ""
1 error generated.
In file included from file_backed.c:3:
./kublk.h:220:43: error: '_Static_assert' with no message is a C23 extension [-Werror,-Wc23-extensions]
  220 |         _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7);
      |                                                  ^
      |                                                  , ""
1 error generated.
In file included from common.c:3:
./kublk.h:220:43: error: '_Static_assert' with no message is a C23 extension [-Werror,-Wc23-extensions]
  220 |         _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7);
      |                                                  ^
      |                                                  , ""
1 error generated.
In file included from stripe.c:3:
./kublk.h:220:43: error: '_Static_assert' with no message is a C23 extension [-Werror,-Wc23-extensions]
  220 |         _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7);
      |                                                  ^
      |                                                  , ""
1 error generated.
In file included from fault_inject.c:11:
./kublk.h:220:43: error: '_Static_assert' with no message is a C23 extension [-Werror,-Wc23-extensions]
  220 |         _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7);
      |                                                  ^
      |                                                  , ""
1 error generated.
make: *** [../lib.mk:225: ~/Desktop/kernel-dev/linux-v1/tools/testing/selftests/ublk/kublk] Error 1

Link: https://lore.kernel.org/r/20251215085022.7642-1-clintbgeorge@gmail.com
Signed-off-by: Clint George <clintbgeorge@gmail.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

Now I have all the information needed for a thorough analysis.

---

## Detailed Analysis

### 1. Commit Message Analysis

The commit fixes a C11/C23 compatibility issue in
`tools/testing/selftests/ublk/kublk.h`. The `_Static_assert()` macro is
used without a message string, which is only valid in C23. When
compiling with Clang/LLVM, this triggers the `-Wc23-extensions` warning,
which is promoted to a hard error by `-Werror`.

The commit message includes the full error log showing compilation
failure across 6 source files that include `kublk.h`. The fix is
reviewed by Ming Lei (ublk maintainer) and signed off by Shuah Khan
(kselftest maintainer).

### 2. Code Change Analysis

The change is a single-line modification:

```diff
- _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7);
+       _Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7,
"UBLK_MAX_QUEUES_SHIFT must be <= 7");
```

This is the most trivial kind of fix possible - adding a string literal
parameter to comply with C11 standard syntax. The runtime behavior is
completely unchanged since `_Static_assert` is a compile-time construct
that generates zero code.

### 3. Impact Assessment

**The build failure is worse than the error log suggests.** The ublk
selftest Makefile includes `-Werror` **by default** (`ifneq
($(WERROR),0)` means it's always on unless explicitly disabled). This
means **any user building the ublk selftest with Clang/LLVM will hit a
hard build error** - they don't need `W=1` to trigger it; that just adds
additional warning flags.

### 4. Affected Stable Trees

The buggy `_Static_assert` line was introduced by commit `bf098d72696db`
("selftests: ublk: kublk: plumb q_id in io_uring user_data") which first
appeared in the 6.16 cycle. The unfixed line exists in:
- **6.16.y** (line 252)
- **6.17.y** (line 223)
- **6.18.y** (line 223)
- **6.19.y** (line 226)

It does NOT exist in 6.15.y or earlier (6.12.y LTS, 6.6.y LTS, etc.).

### 5. Stable Criteria Evaluation

| Criterion | Assessment |
|-----------|-----------|
| Obviously correct and tested | YES - trivially obvious, tested by
author |
| Fixes a real bug | YES - hard compilation error |
| Important issue | YES - **build fix** (explicitly listed exception
category) |
| Small and contained | YES - one line, one file |
| No new features | YES - purely a build fix |
| Can apply cleanly | Likely YES with minor context adjustment per tree
|

### 6. Risk Assessment

**Risk: Essentially zero.** `_Static_assert` is a compile-time
construct. Adding a message string parameter cannot change runtime
behavior. The assertion condition itself is unchanged. This is the
safest possible type of change.

### 7. Dependency Check

No dependencies. The fix is entirely self-contained - it only modifies
the syntax of an existing assertion. No new includes, no new functions,
no changed behavior.

### 8. Classification

This is a **build fix** for a kselftest. Build fixes are explicitly
listed as an allowed exception category for stable ("These are critical
for users who need to build the kernel"). While this specifically
affects selftest infrastructure rather than the kernel itself, selftests
are integral to verifying stable kernel correctness, and CI systems
(KernelCI, 0-day) regularly run these tests on stable trees.

The fix prevents a **hard build failure** with the Clang/LLVM toolchain
(widely used, especially in Android and ChromeOS kernel development).
The `-Werror` flag is enabled by default in the ublk selftest Makefile,
making this a default-configuration failure, not an edge case.

### Conclusion

This is a trivial, zero-risk build fix that prevents a default-
configuration compilation error in the ublk kselftest when using
Clang/LLVM. It meets all stable kernel criteria: obviously correct,
fixes a real build failure, is tiny and self-contained, and introduces
no new features. The only limitation is that it only applies to stable
trees 6.16.y and later where the buggy `_Static_assert` line exists.

**YES**

 tools/testing/selftests/ublk/kublk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests/ublk/kublk.h
index 8a83b90ec603a..cae2e30f0cdd5 100644
--- a/tools/testing/selftests/ublk/kublk.h
+++ b/tools/testing/selftests/ublk/kublk.h
@@ -223,7 +223,7 @@ static inline __u64 build_user_data(unsigned tag, unsigned op,
 		unsigned tgt_data, unsigned q_id, unsigned is_target_io)
 {
 	/* we only have 7 bits to encode q_id */
-	_Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7);
+	_Static_assert(UBLK_MAX_QUEUES_SHIFT <= 7, "UBLK_MAX_QUEUES_SHIFT must be <= 7");
 	assert(!(tag >> 16) && !(op >> 8) && !(tgt_data >> 16) && !(q_id >> 7));
 
 	return tag | (op << 16) | (tgt_data << 24) |
-- 
2.51.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-02-10 23:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260210233123.2905307-1-sashal@kernel.org>
2026-02-10 23:30 ` [PATCH AUTOSEL 6.19-6.18] kselftest/kublk: include message in _Static_assert for C11 compatibility Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox