xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Fix several sign-conversion warnings in interface headers
@ 2023-01-10  9:59 Jan Kiszka
  0 siblings, 0 replies; only message in thread
From: Jan Kiszka @ 2023-01-10  9:59 UTC (permalink / raw)
  To: Xenomai

From: Jan Kiszka <jan.kiszka@siemens.com>

This includes can trigger warnings when -Wsign-conversion is set. All
conversions are fine, so silence them by explicit casts.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Changes in v2:
 - restore original logic of bad_pointer

 include/boilerplate/debug.h        | 3 ++-
 include/cobalt/uapi/kernel/synch.h | 4 ++--
 include/copperplate/clockobj.h     | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/include/boilerplate/debug.h b/include/boilerplate/debug.h
index d3ab0ef80a..248cb908a2 100644
--- a/include/boilerplate/debug.h
+++ b/include/boilerplate/debug.h
@@ -135,7 +135,8 @@ struct backtrace_data {
 
 static inline int bad_pointer(const void *ptr)
 {
-	return ptr == NULL || ((intptr_t)ptr & (sizeof(intptr_t)-1)) != 0;
+	return ptr == NULL ||
+		((intptr_t)ptr & (intptr_t)(sizeof(intptr_t)-1)) != 0;
 }
 
 #endif /* _BOILERPLATE_DEBUG_H */
diff --git a/include/cobalt/uapi/kernel/synch.h b/include/cobalt/uapi/kernel/synch.h
index a21eb965e7..a7cb9fb099 100644
--- a/include/cobalt/uapi/kernel/synch.h
+++ b/include/cobalt/uapi/kernel/synch.h
@@ -48,7 +48,7 @@ static inline xnhandle_t xnsynch_fast_ceiling(xnhandle_t handle)
 static inline int
 xnsynch_fast_owner_check(atomic_t *fastlock, xnhandle_t ownerh)
 {
-	return (xnhandle_get_id(atomic_read(fastlock)) == ownerh) ?
+	return (xnhandle_get_id((xnhandle_t)atomic_read(fastlock)) == ownerh) ?
 		0 : -EPERM;
 }
 
@@ -57,7 +57,7 @@ int xnsynch_fast_acquire(atomic_t *fastlock, xnhandle_t new_ownerh)
 {
 	xnhandle_t h;
 
-	h = atomic_cmpxchg(fastlock, XN_NO_HANDLE, new_ownerh);
+	h = (xnhandle_t)atomic_cmpxchg(fastlock, XN_NO_HANDLE, new_ownerh);
 	if (h != XN_NO_HANDLE) {
 		if (xnhandle_get_id(h) == new_ownerh)
 			return -EBUSY;
diff --git a/include/copperplate/clockobj.h b/include/copperplate/clockobj.h
index 58ec56652f..dde18bda87 100644
--- a/include/copperplate/clockobj.h
+++ b/include/copperplate/clockobj.h
@@ -143,7 +143,7 @@ void clockobj_ns_to_timespec(ticks_t ns, struct timespec *ts)
 	unsigned long rem;
 
 	ts->tv_sec = (time_t)cobalt_divrem_billion(ns, &rem);
-	ts->tv_nsec = rem;
+	ts->tv_nsec = (long)rem;
 }
 
 #else /* CONFIG_XENO_MERCURY */
-- 
2.35.3

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

only message in thread, other threads:[~2023-01-10 10:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10  9:59 [PATCH v2] Fix several sign-conversion warnings in interface headers Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).