Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151819497
D43426.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D43426.id.diff
View Options
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -326,6 +326,17 @@
#if __GNUC_PREREQ__(3, 4)
#define __fastcall __attribute__((__fastcall__))
#define __result_use_check __attribute__((__warn_unused_result__))
+#ifdef __clang__
+/*
+ * clang and gcc have different semantics for __warn_unused_result__: the latter
+ * does not permit the use of a void cast to suppress the warning. Use
+ * __result_use_or_ignore_check in places where a void cast is acceptable.
+ * This can be implemented by [[nodiscard]] from C23.
+ */
+#define __result_use_or_ignore_check __result_use_check
+#else
+#define __result_use_or_ignore_check
+#endif /* !__clang__ */
#else
#define __fastcall
#define __result_use_check
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -299,10 +299,11 @@
void * _Nonnull __restrict kaddr, size_t len);
int __result_use_check copyin_nofault(const void * __restrict udaddr,
void * _Nonnull __restrict kaddr, size_t len);
-int copyout(const void * _Nonnull __restrict kaddr,
- void * __restrict udaddr, size_t len);
-int copyout_nofault(const void * _Nonnull __restrict kaddr,
+int __result_use_or_ignore_check copyout(const void * _Nonnull __restrict kaddr,
void * __restrict udaddr, size_t len);
+int __result_use_or_ignore_check copyout_nofault(
+ const void * _Nonnull __restrict kaddr, void * __restrict udaddr,
+ size_t len);
#ifdef SAN_NEEDS_INTERCEPTORS
int SAN_INTERCEPTOR(copyin)(const void *, void *, size_t);
@@ -323,11 +324,11 @@
int __result_use_check fueword(volatile const void *base, long *val);
int __result_use_check fueword32(volatile const void *base, int32_t *val);
int __result_use_check fueword64(volatile const void *base, int64_t *val);
-int subyte(volatile void *base, int byte);
-int suword(volatile void *base, long word);
-int suword16(volatile void *base, int word);
-int suword32(volatile void *base, int32_t word);
-int suword64(volatile void *base, int64_t word);
+int __result_use_or_ignore_check subyte(volatile void *base, int byte);
+int __result_use_or_ignore_check suword(volatile void *base, long word);
+int __result_use_or_ignore_check suword16(volatile void *base, int word);
+int __result_use_or_ignore_check suword32(volatile void *base, int32_t word);
+int __result_use_or_ignore_check suword64(volatile void *base, int64_t word);
uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval);
u_long casuword(volatile u_long *p, u_long oldval, u_long newval);
int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 11, 9:19 PM (2 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31308282
Default Alt Text
D43426.id.diff (2 KB)
Attached To
Mode
D43426: cdefs: Introduce __result_use_or_ignore_check
Attached
Detach File
Event Timeline
Log In to Comment