Skip to contentSkip to conversation

copperplate/clockobj: prevent warning with -Wconversion

PATCH In review Mauro Salvini 2 participants 4 messages Oct 30, 2018 – Nov 5, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 copperplate/clockobj: prevent warning with -Wconversion

make cast explicit to avoid warning when user code is compiled with -Wconversion
---
 include/copperplate/clockobj.h | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/include/copperplate/clockobj.h
index 8568794d9..063bcce90 100644

include/copperplate/clockobj.h +0 -0
@@ -136,7 +136,7 @@ void clockobj_ns_to_timespec(ticks_t ns, struct

timespec *ts)
 {
  unsigned long rem;

- ts->tv_sec = cobalt_divrem_billion(ns, &rem);
+ ts->tv_sec = (__kernel_time_t)cobalt_divrem_billion(ns, &rem);
  ts->tv_nsec = rem;
 }

--
2.11.0

#1 lore raw
Quoted 2 lines · Mauro Salvini

make cast explicit to avoid warning when user code is compiled with -Wconversion

Please sign-off your patches, according to CONTRIBUTING.md.

include/copperplate/clockobj.h void clockobj_ns_to_timespec(ticks_t ns, struct · line 136

Quoted 11 lines
---
  include/copperplate/clockobj.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/copperplate/clockobj.h +0 -0
index 8568794d9..063bcce90 100644
@@ -136,7 +136,7 @@ void clockobj_ns_to_timespec(ticks_t ns, struct
 timespec *ts)

Something mangled this line, probably your mail client.

include/copperplate/clockobj.h void clockobj_ns_to_timespec(ticks_t ns, struct · line 140

Quoted 5 lines
include/copperplate/clockobj.h +1 -1
  {
  	unsigned long rem;
 
-	ts->tv_sec = cobalt_divrem_billion(ns, &rem);
+	ts->tv_sec = (__kernel_time_t)cobalt_divrem_billion(ns, &rem);

Why not time_t, the public target type?

Quoted 7 lines
include/copperplate/clockobj.h +0 -0
  	ts->tv_nsec = rem;
  }
Signature · 2 lines
-- 
2.11.0

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#2 lore raw

PATCH 1/1 copperplate/clockobj: prevent warning with -Wconversion

make cast explicit to avoid warning when user code is compiled with -Wconversion

---
 include/copperplate/clockobj.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/copperplate/clockobj.h +1 -1
index 8568794d9..24c748557 100644
@@ -136,7 +136,7 @@ void clockobj_ns_to_timespec(ticks_t ns, struct timespec *ts)
 {
 	unsigned long rem;
 
-	ts->tv_sec = cobalt_divrem_billion(ns, &rem);
+	ts->tv_sec = (time_t)cobalt_divrem_billion(ns, &rem);
 	ts->tv_nsec = rem;
 }
 
Signature · 1 line
2.11.0
Applied
#3 lore raw
Quoted 14 lines · Mauro Salvini via Xenomai

make cast explicit to avoid warning when user code is compiled with -Wconversion

---
  include/copperplate/clockobj.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/copperplate/clockobj.h +0 -0
index 8568794d9..24c748557 100644

include/copperplate/clockobj.h void clockobj_ns_to_timespec(ticks_t ns, struct timespec *ts) · line 142

Quoted 8 lines
include/copperplate/clockobj.h +1 -1
@@ -136,7 +136,7 @@ void clockobj_ns_to_timespec(ticks_t ns, struct timespec *ts)
  {
  	unsigned long rem;
 
-	ts->tv_sec = cobalt_divrem_billion(ns, &rem);
+	ts->tv_sec = (time_t)cobalt_divrem_billion(ns, &rem);
  	ts->tv_nsec = rem;
  }
 

Thanks, applied.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux