git: 8e429142feaa - main - kobj: Avoid initializing pointer from boolean value
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 Nov 2026 19:29:44 UTC
The branch main has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=8e429142feaaf96456566d3111fa893e29e8fd53
commit 8e429142feaaf96456566d3111fa893e29e8fd53
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2026-11-04 19:28:30 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2026-11-04 19:28:30 +0000
kobj: Avoid initializing pointer from boolean value
Prior to change 477c594d9063, the struct kobj_class has six members but
the DEFINE_CLASS_[0..3] only initialize the first four of them. The
change 477c594d9063 intends to initialize the two new members but
actually acts on the wrong ones.
```
error: initialization of pointer of type 'kobj_ops_t' (aka 'struct kobj_ops *') to null from a
constant boolean expression [-Werror,-Wbool-conversion]
```
Fix by initializing the two new members implicitly.
Reported by: clang (-std=gnu23 -Wbool-conversion)
Reviewed by: mmel, kib
Fixes: 477c594d9063 kobj: allow multiple inheritance with per-class softc
MFC with: 477c594d9063
Differential Revision: https://reviews.freebsd.org/D61173
---
sys/sys/kobj.h | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h
index e248f9eafaf8..bcf3315d8fe0 100644
--- a/sys/sys/kobj.h
+++ b/sys/sys/kobj.h
@@ -33,7 +33,7 @@
/* XXX workaround for bool type for tools/build/test-includes */
#if !defined(_KERNEL) && !defined(_STANDALONE)
-#include <stdbool.h>
+#include <stdbool.h>
#endif
/*
@@ -131,7 +131,7 @@ DEFINE_CLASS_0(name, name ## _class, methods, size)
#define DEFINE_CLASS_0(name, classvar, methods, size) \
\
struct kobj_class classvar = { \
- #name, methods, size, NULL, 0, false \
+ #name, methods, size, NULL \
}
/*
@@ -146,8 +146,7 @@ struct kobj_class classvar = { \
static kobj_class_t name ## _baseclasses[] = \
{ &base1, NULL }; \
struct kobj_class classvar = { \
- #name, methods, size, name ## _baseclasses, 0, \
- false \
+ #name, methods, size, name ## _baseclasses \
}
/*
@@ -163,8 +162,7 @@ static kobj_class_t name ## _baseclasses[] = \
{ &base1, \
&base2, NULL }; \
struct kobj_class classvar = { \
- #name, methods, size, name ## _baseclasses, 0, \
- false \
+ #name, methods, size, name ## _baseclasses \
}
/*
@@ -181,8 +179,7 @@ static kobj_class_t name ## _baseclasses[] = \
&base2, \
&base3, NULL }; \
struct kobj_class classvar = { \
- #name, methods, size, name ## _baseclasses, 0, \
- false \
+ #name, methods, size, name ## _baseclasses \
}
/*