diff --git a/arch/arm/src/cxd56xx/cxd56_rtc.c b/arch/arm/src/cxd56xx/cxd56_rtc.c index cd7e4338992..b83b8b1bcc0 100644 --- a/arch/arm/src/cxd56xx/cxd56_rtc.c +++ b/arch/arm/src/cxd56xx/cxd56_rtc.c @@ -75,7 +75,7 @@ /* convert seconds to 64bit counter value running at 32kHz */ -#define SEC_TO_CNT(sec) ((uint64_t)(((uint64_t)(sec)) << 15)) +#define SEC_TO_CNT(sec) (((uint64_t)(sec)) << 15) /* convert nano-seconds to 32kHz counter less than 1 second */ @@ -157,7 +157,7 @@ static void rtc_dumptime(const struct timespec *tp, const char *msg) gmtime_r(&tp->tv_sec, &tm); rtcinfo("%s:\n", msg); - rtcinfo("RTC %u.%09u\n", tp->tv_sec, tp->tv_nsec); + rtcinfo("RTC %jd.%09ld\n", (intmax_t)tp->tv_sec, tp->tv_nsec); rtcinfo("%4d/%02d/%02d %02d:%02d:%02d\n", tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); diff --git a/arch/arm/src/cxd56xx/cxd56_timer.c b/arch/arm/src/cxd56xx/cxd56_timer.c index 11e29835d79..e851f268b8c 100644 --- a/arch/arm/src/cxd56xx/cxd56_timer.c +++ b/arch/arm/src/cxd56xx/cxd56_timer.c @@ -336,7 +336,7 @@ static int cxd56_getstatus(struct timer_lowerhalf_s *lower, /* Get the time remaining until the timer expires (in microseconds). */ - remaining = (uint64_t)getreg32(priv->base + CXD56_TIMER_VALUE); + remaining = getreg32(priv->base + CXD56_TIMER_VALUE); status->timeleft = (uint32_t)(remaining * 1000000ULL * TIMER_DIVIDER / priv->clkticks); diff --git a/arch/arm/src/cxd56xx/cxd56_wdt.c b/arch/arm/src/cxd56xx/cxd56_wdt.c index cb668e93145..62207f47a10 100644 --- a/arch/arm/src/cxd56xx/cxd56_wdt.c +++ b/arch/arm/src/cxd56xx/cxd56_wdt.c @@ -391,7 +391,7 @@ static int cxd56_getstatus(struct watchdog_lowerhalf_s *lower, /* Get the time remaining until the watchdog expires (in milliseconds) */ - remain = (uint64_t)cxd56_getreg(CXD56_WDT_WDOGVALUE); + remain = cxd56_getreg(CXD56_WDT_WDOGVALUE); status->timeleft = (uint32_t)(remain * 1000 / cxd56_get_cpu_baseclk()); if (cxd56_getreg(CXD56_WDT_WDOGRIS) != WDOGRIS_RAWINT) { diff --git a/arch/arm/src/efm32/efm32_rtc_burtc.c b/arch/arm/src/efm32/efm32_rtc_burtc.c index c3f8a128cbd..c3b2f55f821 100644 --- a/arch/arm/src/efm32/efm32_rtc_burtc.c +++ b/arch/arm/src/efm32/efm32_rtc_burtc.c @@ -431,7 +431,7 @@ int up_rtc_gettime(struct timespec *tp) tp->tv_nsec = (val % CONFIG_RTC_FREQUENCY) * (NSEC_PER_SEC / CONFIG_RTC_FREQUENCY); - rtcinfo("Get RTC %u.%09u\n", tp->tv_sec, tp->tv_nsec); + rtcinfo("Get RTC %jd.%09ld\n", (intmax_t)tp->tv_sec, tp->tv_nsec); return OK; } @@ -481,8 +481,8 @@ int up_rtc_settime(const struct timespec *tp) cnt_carry = val / __CNT_TOP; cnt = val % __CNT_TOP; - rtcinfo("Set RTC %u.%09u carry %u zero %u reg %u\n", - tp->tv_sec, tp->tv_nsec, cnt_carry, cnt, cnt_reg); + rtcinfo("Set RTC %jd.%09ld carry %u zero %u reg %u\n", + (intmax_t)tp->tv_sec, tp->tv_nsec, cnt_carry, cnt, cnt_reg); putreg32(cnt_carry, __CNT_CARRY_REG); putreg32(cnt , __CNT_ZERO_REG); diff --git a/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c b/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c index c2ec3cdc908..e2e5fc39548 100644 --- a/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c +++ b/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c @@ -515,8 +515,7 @@ static int kinetis_rdalarm(struct rtc_lowerhalf_s *lower, flags = enter_critical_section(); ret = kinetis_rtc_rdalarm(&ts); - localtime_r((const time_t *)&ts.tv_sec, - (struct tm *)alarminfo->time); + localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time); leave_critical_section(flags); } diff --git a/arch/arm/src/lc823450/lc823450_timer.c b/arch/arm/src/lc823450/lc823450_timer.c index b56562b48be..cea75ec495b 100644 --- a/arch/arm/src/lc823450/lc823450_timer.c +++ b/arch/arm/src/lc823450/lc823450_timer.c @@ -727,6 +727,6 @@ int up_rtc_gettime(struct timespec *tp) tp->tv_sec = secs; tp->tv_nsec = nsecs; - tmrinfo("Returning tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec); + tmrinfo("Returning tp=(%jd,%ld)\n", (intmax_t)tp->tv_sec, tp->tv_nsec); return OK; } diff --git a/arch/arm/src/lpc31xx/lpc31_timerisr.c b/arch/arm/src/lpc31xx/lpc31_timerisr.c index 4e5e99ec6d2..8bd8ea2247a 100644 --- a/arch/arm/src/lpc31xx/lpc31_timerisr.c +++ b/arch/arm/src/lpc31xx/lpc31_timerisr.c @@ -97,7 +97,7 @@ void up_timer_initialize(void) * of the timer0 module clock (in the AHB0APB1_BASE domain (2)). */ - freq = (uint64_t)lpc31_clkfreq(CLKID_TIMER0PCLK, DOMAINID_AHB0APB1); + freq = lpc31_clkfreq(CLKID_TIMER0PCLK, DOMAINID_AHB0APB1); /* If the clock is >1MHz, use pre-dividers */ diff --git a/arch/arm/src/nrf52/nrf52_wdt_lowerhalf.c b/arch/arm/src/nrf52/nrf52_wdt_lowerhalf.c index a2aefa4fa82..c53e2312089 100644 --- a/arch/arm/src/nrf52/nrf52_wdt_lowerhalf.c +++ b/arch/arm/src/nrf52/nrf52_wdt_lowerhalf.c @@ -362,7 +362,7 @@ static int nrf52_settimeout(struct watchdog_lowerhalf_s *lower, nrf52_wdt_behaviour_set(priv->mode); - nrf52_wdt_reload_value_set(((uint64_t) timeout * 32768) / 1000); + nrf52_wdt_reload_value_set(((uint64_t)timeout * 32768) / 1000); up_enable_irq(NRF52_IRQ_WDT); diff --git a/arch/arm/src/rp2040/rp2040_clock.c b/arch/arm/src/rp2040/rp2040_clock.c index 65883397339..cba8946fd5d 100644 --- a/arch/arm/src/rp2040/rp2040_clock.c +++ b/arch/arm/src/rp2040/rp2040_clock.c @@ -118,7 +118,7 @@ bool rp2040_clock_configure(int clk_index, * (left shift by 8) */ - div = (uint32_t) (((uint64_t) src_freq << 8) / freq); + div = (uint32_t)(((uint64_t)src_freq << 8) / freq); /* If increasing divisor, set divisor before source. Otherwise set source * before divisor. This avoids a momentary overspeed when e.g. switching diff --git a/arch/arm/src/rp23xx/rp23xx_clock.c b/arch/arm/src/rp23xx/rp23xx_clock.c index fadc48f2a27..e1e41904782 100644 --- a/arch/arm/src/rp23xx/rp23xx_clock.c +++ b/arch/arm/src/rp23xx/rp23xx_clock.c @@ -124,7 +124,7 @@ bool rp23xx_clock_configure(int clk_index, * (left shift by 16) */ - div = (uint32_t) (((uint64_t) src_freq << 16) / freq); + div = (uint32_t)(((uint64_t)src_freq << 16) / freq); /* If increasing divisor, set divisor before source. Otherwise set source * before divisor. This avoids a momentary overspeed when e.g. switching diff --git a/arch/arm/src/rtl8720c/amebaz_depend.c b/arch/arm/src/rtl8720c/amebaz_depend.c index 6ba9241ec4f..ac81473c3dc 100644 --- a/arch/arm/src/rtl8720c/amebaz_depend.c +++ b/arch/arm/src/rtl8720c/amebaz_depend.c @@ -518,7 +518,7 @@ static unsigned int __div64_32(uint64_t *n, unsigned int base) if (high >= base) { high /= base; - res = (uint64_t) high << 32; + res = (uint64_t)high << 32; rem -= (uint64_t)(high * base) << 32; } diff --git a/arch/arm/src/s32k3xx/s32k3xx_pinirq.c b/arch/arm/src/s32k3xx/s32k3xx_pinirq.c index b7b7cb87174..7392b4669dd 100644 --- a/arch/arm/src/s32k3xx/s32k3xx_pinirq.c +++ b/arch/arm/src/s32k3xx/s32k3xx_pinirq.c @@ -157,7 +157,7 @@ static int s32k3xx_wkpuinterrupt(int irq, void *context, void *arg) wisr_64 = getreg32(S32K3XX_WKPU_WISR_64); irer_64 = getreg32(S32K3XX_WKPU_IRER_64); - eif = (wisr & irer) | (((uint64_t) (wisr_64 & irer_64)) << 32); + eif = (wisr & irer) | (((uint64_t)(wisr_64 & irer_64)) << 32); /* Examine each WKPU source */ diff --git a/arch/arm/src/sam34/sam4cm_freerun.c b/arch/arm/src/sam34/sam4cm_freerun.c index df76aae6d94..06579ba8903 100644 --- a/arch/arm/src/sam34/sam4cm_freerun.c +++ b/arch/arm/src/sam34/sam4cm_freerun.c @@ -276,8 +276,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/arm/src/sam34/sam4cm_oneshot.c b/arch/arm/src/sam34/sam4cm_oneshot.c index 7a5c1bcbbcc..abb19a70abb 100644 --- a/arch/arm/src/sam34/sam4cm_oneshot.c +++ b/arch/arm/src/sam34/sam4cm_oneshot.c @@ -233,7 +233,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec) { DEBUGASSERT(oneshot && usec); *usec = (0xffffull * USEC_PER_SEC) / - (uint64_t)sam_tc_divfreq(oneshot->tch); + sam_tc_divfreq(oneshot->tch); return OK; } @@ -266,9 +266,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot, uint64_t regval; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); /* Was the oneshot already running? */ @@ -500,8 +499,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot, ts->tv_nsec = nsec; } - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/arm/src/sama5/sam_freerun.c b/arch/arm/src/sama5/sam_freerun.c index 07f8e5e7c96..a38149f4eb0 100644 --- a/arch/arm/src/sama5/sam_freerun.c +++ b/arch/arm/src/sama5/sam_freerun.c @@ -277,8 +277,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/arm/src/sama5/sam_oneshot.c b/arch/arm/src/sama5/sam_oneshot.c index 12fd473aca9..9cc75c83ffe 100644 --- a/arch/arm/src/sama5/sam_oneshot.c +++ b/arch/arm/src/sama5/sam_oneshot.c @@ -243,7 +243,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec) { DEBUGASSERT(oneshot != NULL && usec != NULL); *usec = (0xffffull * USEC_PER_SEC) / - (uint64_t)sam_tc_divfreq(oneshot->tch); + sam_tc_divfreq(oneshot->tch); return OK; } @@ -276,9 +276,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot, uint64_t regval; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); /* Was the oneshot already running? */ @@ -511,8 +510,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot, ts->tv_nsec = nsec; } - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/arm/src/sama5/sam_tickless.c b/arch/arm/src/sama5/sam_tickless.c index cf497896013..27dd87b39e7 100644 --- a/arch/arm/src/sama5/sam_tickless.c +++ b/arch/arm/src/sama5/sam_tickless.c @@ -265,7 +265,7 @@ void up_timer_initialize(void) /* Convert this to configured clock ticks for use by the OS timer logic */ max_delay /= CONFIG_USEC_PER_TICK; - if (max_delay > (uint64_t)UINT32_MAX) + if (max_delay > UINT32_MAX) { g_oneshot_maxticks = UINT32_MAX; } diff --git a/arch/arm/src/samd5e5/sam_freerun.c b/arch/arm/src/samd5e5/sam_freerun.c index 0992557d5b2..5aaf5946759 100644 --- a/arch/arm/src/samd5e5/sam_freerun.c +++ b/arch/arm/src/samd5e5/sam_freerun.c @@ -213,8 +213,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/arm/src/samd5e5/sam_oneshot.c b/arch/arm/src/samd5e5/sam_oneshot.c index b55b72c862a..cf4e9ae814d 100644 --- a/arch/arm/src/samd5e5/sam_oneshot.c +++ b/arch/arm/src/samd5e5/sam_oneshot.c @@ -178,7 +178,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec) { DEBUGASSERT(oneshot != NULL && usec != NULL); *usec = (0xffffull * USEC_PER_SEC) / - (uint64_t)sam_tc_divfreq(oneshot->tch); + sam_tc_divfreq(oneshot->tch); return OK; } @@ -211,8 +211,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot, uint64_t regval; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); /* Was the oneshot already running? */ @@ -445,8 +445,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot, ts->tv_nsec = nsec; } - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/arm/src/samd5e5/sam_tickless.c b/arch/arm/src/samd5e5/sam_tickless.c index 7629bdab14b..7f8191279f1 100644 --- a/arch/arm/src/samd5e5/sam_tickless.c +++ b/arch/arm/src/samd5e5/sam_tickless.c @@ -263,7 +263,7 @@ void up_timer_initialize(void) /* Convert this to configured clock ticks for use by the OS timer logic */ max_delay /= CONFIG_USEC_PER_TICK; - if (max_delay > (uint64_t)UINT32_MAX) + if (max_delay > UINT32_MAX) { g_oneshot_maxticks = UINT32_MAX; } @@ -398,8 +398,7 @@ int up_timer_cancel(struct timespec *ts) int up_timer_start(const struct timespec *ts) { - tmrinfo("ts=(%lu, %lu)\n", (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("ts=(%jd, %ld)\n", (intmax_t)ts->tv_sec, ts->tv_nsec); return ONESHOT_INITIALIZED(&g_tickless.oneshot) ? sam_oneshot_start(&g_tickless.oneshot, &g_tickless.freerun, sam_oneshot_handler, NULL, ts) : diff --git a/arch/arm/src/samv7/sam_freerun.c b/arch/arm/src/samv7/sam_freerun.c index 2b6b582a913..716e3b88eb7 100644 --- a/arch/arm/src/samv7/sam_freerun.c +++ b/arch/arm/src/samv7/sam_freerun.c @@ -277,8 +277,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/arm/src/samv7/sam_oneshot.c b/arch/arm/src/samv7/sam_oneshot.c index 71abe873208..853dd67472c 100644 --- a/arch/arm/src/samv7/sam_oneshot.c +++ b/arch/arm/src/samv7/sam_oneshot.c @@ -244,7 +244,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec) { DEBUGASSERT(oneshot != NULL && usec != NULL); *usec = (0xffffull * USEC_PER_SEC) / - (uint64_t)sam_tc_divfreq(oneshot->tch); + sam_tc_divfreq(oneshot->tch); return OK; } @@ -277,9 +277,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot, uint64_t regval; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); /* Was the oneshot already running? */ @@ -510,8 +509,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot, ts->tv_nsec = nsec; } - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/arm/src/stm32/stm32_bbsram.c b/arch/arm/src/stm32/stm32_bbsram.c index 9d914aff6c7..b595b377611 100644 --- a/arch/arm/src/stm32/stm32_bbsram.c +++ b/arch/arm/src/stm32/stm32_bbsram.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -177,7 +178,8 @@ static void stm32_bbsram_dump(struct bbsramfh_s *bbf, char *op) _info(" fileno:%d\n", (int) bbf->fileno); _info(" dirty:%d\n", (int) bbf->dirty); _info(" length:%d\n", (int) bbf->len); - _info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec); + _info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec, + bbf->lastwrite.tv_nsec); _info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n", bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]); } diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index e68e5a00dd2..3f1fdf514a3 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -3582,7 +3582,7 @@ static int stm32_eth_ptp_adjust(long ppb) if (ppb != 0) { - addend += (int64_t)addend * ppb / NSEC_PER_SEC; + addend += addend * ppb / NSEC_PER_SEC; } /* Check for overflows */ diff --git a/arch/arm/src/stm32/stm32_freerun.c b/arch/arm/src/stm32/stm32_freerun.c index 59437493b1f..af5599a9314 100644 --- a/arch/arm/src/stm32/stm32_freerun.c +++ b/arch/arm/src/stm32/stm32_freerun.c @@ -247,7 +247,7 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun, ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%ju, %lu)\n", + tmrinfo("usec=%llu ts=(%jd, %ld)\n", usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; @@ -257,7 +257,7 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun, int stm32_freerun_counter(struct stm32_freerun_s *freerun, uint64_t *counter) { - *counter = (uint64_t)STM32_TIM_GETCOUNTER(freerun->tch); + *counter = STM32_TIM_GETCOUNTER(freerun->tch); return OK; } diff --git a/arch/arm/src/stm32/stm32_oneshot.c b/arch/arm/src/stm32/stm32_oneshot.c index f05832e3d2a..b80df41e762 100644 --- a/arch/arm/src/stm32/stm32_oneshot.c +++ b/arch/arm/src/stm32/stm32_oneshot.c @@ -259,9 +259,8 @@ int stm32_oneshot_start(struct stm32_oneshot_s *oneshot, uint64_t period; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); DEBUGASSERT(oneshot->tch); @@ -449,8 +448,8 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot, ts->tv_nsec = nsec; } - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/arm/src/stm32/stm32_rtcounter.c b/arch/arm/src/stm32/stm32_rtcounter.c index aed46394773..a93fcb4f890 100644 --- a/arch/arm/src/stm32/stm32_rtcounter.c +++ b/arch/arm/src/stm32/stm32_rtcounter.c @@ -832,8 +832,8 @@ int stm32_rtc_rdalarm(FAR struct alm_rdalarm_s *alminfo) regvals.cnth = getreg16(STM32_RTC_ALRH); regvals.cntl = getreg16(STM32_RTC_ALRL); tp.tv_sec = regvals.cnth << 16 | regvals.cntl; - memcpy(alminfo->ar_time, (FAR struct tm *)gmtime(&tp.tv_sec), - sizeof(FAR struct tm)); + memcpy(alminfo->ar_time, gmtime(&tp.tv_sec), + sizeof(struct tm)); ret = OK; } break; diff --git a/arch/arm/src/stm32/stm32_tickless.c b/arch/arm/src/stm32/stm32_tickless.c index 0d3634c8bda..3cd076bf1d7 100644 --- a/arch/arm/src/stm32/stm32_tickless.c +++ b/arch/arm/src/stm32/stm32_tickless.c @@ -686,8 +686,8 @@ int up_timer_gettime(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } @@ -872,8 +872,8 @@ int up_timer_cancel(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = nsec; - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; @@ -911,8 +911,8 @@ int up_timer_start(const struct timespec *ts) uint32_t count; irqstate_t flags; - tmrinfo("ts=(%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("ts=(%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(ts); DEBUGASSERT(g_tickless.tch); diff --git a/arch/arm/src/stm32f0l0g0/stm32_tim_lowerhalf.c b/arch/arm/src/stm32f0l0g0/stm32_tim_lowerhalf.c index 2923e1b1235..25e82579604 100644 --- a/arch/arm/src/stm32f0l0g0/stm32_tim_lowerhalf.c +++ b/arch/arm/src/stm32f0l0g0/stm32_tim_lowerhalf.c @@ -417,7 +417,7 @@ static int stm32_getstatus(struct timer_lowerhalf_s *lower, } else { - timeout = ((uint64_t) period * 1000000) / clock; + timeout = ((uint64_t)period * 1000000) / clock; } status->timeout = timeout; @@ -425,7 +425,7 @@ static int stm32_getstatus(struct timer_lowerhalf_s *lower, /* Get the time remaining until the timer expires (in microseconds) */ counter = STM32_TIM_GETCOUNTER(priv->tim); - status->timeleft = ((uint64_t) (timeout - counter) * clock) / 1000000; + status->timeleft = ((uint64_t)(timeout - counter) * clock) / 1000000; tmrinfo("timeout=%" PRIu32 " counter=%" PRIu32 "\n", timeout, counter); tmrinfo("timeleft=%" PRIu32 "\n", status->timeleft); return OK; diff --git a/arch/arm/src/stm32f7/stm32_bbsram.c b/arch/arm/src/stm32f7/stm32_bbsram.c index 06b418f36d7..36d92cc7de3 100644 --- a/arch/arm/src/stm32f7/stm32_bbsram.c +++ b/arch/arm/src/stm32f7/stm32_bbsram.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -177,7 +178,8 @@ static void stm32_bbsram_dump(struct bbsramfh_s *bbf, char *op) _info(" fileno:%d\n", (int) bbf->fileno); _info(" dirty:%d\n", (int) bbf->dirty); _info(" length:%d\n", (int) bbf->len); - _info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec); + _info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec, + bbf->lastwrite.tv_nsec); _info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n", bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]); } diff --git a/arch/arm/src/stm32f7/stm32_tickless.c b/arch/arm/src/stm32f7/stm32_tickless.c index d809b623c5d..52ddb0e04bd 100644 --- a/arch/arm/src/stm32f7/stm32_tickless.c +++ b/arch/arm/src/stm32f7/stm32_tickless.c @@ -727,8 +727,8 @@ int up_timer_gettime(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } @@ -914,8 +914,8 @@ int up_timer_cancel(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = nsec; - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; @@ -955,8 +955,8 @@ int up_timer_start(const struct timespec *ts) uint32_t count; irqstate_t flags; - tmrinfo("ts=(%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("ts=(%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(ts); DEBUGASSERT(g_tickless.tch); diff --git a/arch/arm/src/stm32h7/stm32_bbsram.c b/arch/arm/src/stm32h7/stm32_bbsram.c index 7bea7fd69eb..a4666960d31 100644 --- a/arch/arm/src/stm32h7/stm32_bbsram.c +++ b/arch/arm/src/stm32h7/stm32_bbsram.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -198,7 +199,8 @@ static void stm32_bbsram_dump(struct bbsramfh_s *bbf, char *op) _info(" fileno:%d\n", (int) bbf->fileno); _info(" dirty:%d\n", (int) bbf->dirty); _info(" length:%d\n", (int) bbf->len); - _info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec); + _info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec, + bbf->lastwrite.tv_nsec); _info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n", bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]); } diff --git a/arch/arm/src/stm32h7/stm32_oneshot.c b/arch/arm/src/stm32h7/stm32_oneshot.c index fe56cfdbe58..078d6efe502 100644 --- a/arch/arm/src/stm32h7/stm32_oneshot.c +++ b/arch/arm/src/stm32h7/stm32_oneshot.c @@ -263,8 +263,8 @@ int stm32_oneshot_start(struct stm32_oneshot_s *oneshot, uint64_t period; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", handler, arg, - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", handler, arg, + (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); DEBUGASSERT(oneshot->tch); diff --git a/arch/arm/src/stm32h7/stm32_tickless.c b/arch/arm/src/stm32h7/stm32_tickless.c index 3a9896b14e6..1de1d5abf73 100644 --- a/arch/arm/src/stm32h7/stm32_tickless.c +++ b/arch/arm/src/stm32h7/stm32_tickless.c @@ -701,8 +701,8 @@ int up_timer_gettime(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } @@ -888,8 +888,8 @@ int up_timer_cancel(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = nsec; - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; @@ -929,8 +929,8 @@ int up_timer_start(const struct timespec *ts) uint32_t count; irqstate_t flags; - tmrinfo("ts=(%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("ts=(%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(ts); DEBUGASSERT(g_tickless.tch); diff --git a/arch/arm/src/stm32l4/stm32l4_freerun.c b/arch/arm/src/stm32l4/stm32l4_freerun.c index 54be46f5409..433a55288f2 100644 --- a/arch/arm/src/stm32l4/stm32l4_freerun.c +++ b/arch/arm/src/stm32l4/stm32l4_freerun.c @@ -231,8 +231,8 @@ int stm32l4_freerun_counter(struct stm32l4_freerun_s *freerun, ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%u, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/arm/src/stm32l4/stm32l4_oneshot.c b/arch/arm/src/stm32l4/stm32l4_oneshot.c index 41c6e5dc83c..0b70b905db8 100644 --- a/arch/arm/src/stm32l4/stm32l4_oneshot.c +++ b/arch/arm/src/stm32l4/stm32l4_oneshot.c @@ -260,9 +260,8 @@ int stm32l4_oneshot_start(struct stm32l4_oneshot_s *oneshot, uint64_t period; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); DEBUGASSERT(oneshot->tch); @@ -451,8 +450,8 @@ int stm32l4_oneshot_cancel(struct stm32l4_oneshot_s *oneshot, ts->tv_nsec = nsec; } - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/arm/src/stm32wb/stm32wb_freerun.c b/arch/arm/src/stm32wb/stm32wb_freerun.c index 9b3a195f701..a4168046aa4 100644 --- a/arch/arm/src/stm32wb/stm32wb_freerun.c +++ b/arch/arm/src/stm32wb/stm32wb_freerun.c @@ -245,7 +245,7 @@ int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun, ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%ju, %lu)\n", + tmrinfo("usec=%llu ts=(%jd, %ld)\n", usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; @@ -256,7 +256,7 @@ int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun, int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun, uint64_t *counter) { - *counter = (uint64_t)STM32WB_TIM_GETCOUNTER(freerun->tch); + *counter = STM32WB_TIM_GETCOUNTER(freerun->tch); return OK; } diff --git a/arch/arm/src/stm32wb/stm32wb_oneshot.c b/arch/arm/src/stm32wb/stm32wb_oneshot.c index 612ec69f93e..ed0d899531c 100644 --- a/arch/arm/src/stm32wb/stm32wb_oneshot.c +++ b/arch/arm/src/stm32wb/stm32wb_oneshot.c @@ -260,9 +260,8 @@ int stm32wb_oneshot_start(struct stm32wb_oneshot_s *oneshot, uint64_t period; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); DEBUGASSERT(oneshot->tch); @@ -450,8 +449,8 @@ int stm32wb_oneshot_cancel(struct stm32wb_oneshot_s *oneshot, ts->tv_nsec = nsec; } - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/arm/src/stm32wb/stm32wb_tickless.c b/arch/arm/src/stm32wb/stm32wb_tickless.c index c27c9790af4..ef5e64b5f60 100644 --- a/arch/arm/src/stm32wb/stm32wb_tickless.c +++ b/arch/arm/src/stm32wb/stm32wb_tickless.c @@ -552,8 +552,8 @@ int up_timer_gettime(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } @@ -738,8 +738,8 @@ int up_timer_cancel(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = nsec; - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; @@ -777,8 +777,8 @@ int up_timer_start(const struct timespec *ts) uint32_t count; irqstate_t flags; - tmrinfo("ts=(%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("ts=(%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(ts); DEBUGASSERT(g_tickless.tch); diff --git a/arch/arm/src/xmc4/xmc4_tickless.c b/arch/arm/src/xmc4/xmc4_tickless.c index 1e8caebe04c..6d82734096e 100644 --- a/arch/arm/src/xmc4/xmc4_tickless.c +++ b/arch/arm/src/xmc4/xmc4_tickless.c @@ -375,8 +375,8 @@ int up_timer_gettime(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } @@ -412,8 +412,8 @@ int up_timer_start(const struct timespec *ts) uint64_t period; irqstate_t flags; - tmrinfo("ts=(%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("ts=(%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(ts); /* Was an interval already running? */ @@ -566,8 +566,8 @@ int up_timer_cancel(struct timespec *ts) ts->tv_sec = sec; ts->tv_nsec = nsec; - tmrinfo("remaining count : %lu (%lu, %lu)\n", count, - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining count : %lu (%jd, %ld)\n", count, + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/arm64/src/common/arm64_fatal.c b/arch/arm64/src/common/arm64_fatal.c index 2051c9d574e..a4e5800d83c 100644 --- a/arch/arm64/src/common/arm64_fatal.c +++ b/arch/arm64/src/common/arm64_fatal.c @@ -666,7 +666,7 @@ uint64_t *arm64_fatal_handler(uint64_t *regs) tcb->flags |= TCB_FLAG_FORCED_CANCEL; - regs[REG_ELR] = (uint64_t) _exit; + regs[REG_ELR] = (uint64_t)_exit; regs[REG_X0] = SIGSEGV; regs[REG_SPSR] &= ~SPSR_MODE_MASK; regs[REG_SPSR] |= SPSR_MODE_EL1H; diff --git a/arch/arm64/src/imx9/imx9_usdhc.c b/arch/arm64/src/imx9/imx9_usdhc.c index a2a4be45773..3e2eaaee7e3 100644 --- a/arch/arm64/src/imx9/imx9_usdhc.c +++ b/arch/arm64/src/imx9/imx9_usdhc.c @@ -2441,7 +2441,7 @@ static int imx9_recvsetup(struct sdio_dev_s *dev, uint8_t *buffer, { struct imx9_dev_s *priv = (struct imx9_dev_s *)dev; DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0); - DEBUGASSERT(((uint64_t) buffer & 3) == 0); + DEBUGASSERT(((uint64_t)buffer & 3) == 0); /* Reset the DPSM configuration */ @@ -2492,7 +2492,7 @@ static int imx9_sendsetup(struct sdio_dev_s *dev, { struct imx9_dev_s *priv = (struct imx9_dev_s *)dev; DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0); - DEBUGASSERT(((uint64_t) buffer & 3) == 0); + DEBUGASSERT(((uint64_t)buffer & 3) == 0); /* Reset the DPSM configuration */ @@ -3230,12 +3230,12 @@ static int imx9_dmarecvsetup(struct sdio_dev_s *dev, imx9_configxfrints(priv, USDHC_DMADONE_INTS); if (priv->unaligned_rx) { - putreg32((uint64_t) priv->rxbuffer, + putreg32((uint64_t)priv->rxbuffer, priv->addr + IMX9_USDHC_DSADDR_OFFSET); } else { - putreg32((uint64_t) priv->buffer, + putreg32((uint64_t)priv->buffer, priv->addr + IMX9_USDHC_DSADDR_OFFSET); } @@ -3271,7 +3271,7 @@ static int imx9_dmasendsetup(struct sdio_dev_s *dev, { struct imx9_dev_s *priv = (struct imx9_dev_s *)dev; DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0); - DEBUGASSERT(((uint64_t) buffer & 3) == 0); + DEBUGASSERT(((uint64_t)buffer & 3) == 0); /* Begin sampling register values */ @@ -3297,7 +3297,7 @@ static int imx9_dmasendsetup(struct sdio_dev_s *dev, /* Configure the TX DMA */ - putreg32((uint64_t) buffer, priv->addr + IMX9_USDHC_DSADDR_OFFSET); + putreg32((uint64_t)buffer, priv->addr + IMX9_USDHC_DSADDR_OFFSET); /* Sample the register state */ diff --git a/arch/mips/src/pic32mz/pic32mz_freerun.c b/arch/mips/src/pic32mz/pic32mz_freerun.c index a20367971fa..e764c143269 100644 --- a/arch/mips/src/pic32mz/pic32mz_freerun.c +++ b/arch/mips/src/pic32mz/pic32mz_freerun.c @@ -260,8 +260,8 @@ int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun, ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%u, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } @@ -271,8 +271,8 @@ int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun, int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun, uint64_t *counter) { - *counter = (uint64_t)PIC32MZ_TIMER_GETCOUNTER(freerun->timer) & - freerun->counter_mask; + *counter = PIC32MZ_TIMER_GETCOUNTER(freerun->timer) & + freerun->counter_mask; return OK; } diff --git a/arch/mips/src/pic32mz/pic32mz_oneshot.c b/arch/mips/src/pic32mz/pic32mz_oneshot.c index 34d5f89a83c..1d58ef03b15 100644 --- a/arch/mips/src/pic32mz/pic32mz_oneshot.c +++ b/arch/mips/src/pic32mz/pic32mz_oneshot.c @@ -277,9 +277,8 @@ int pic32mz_oneshot_start(struct pic32mz_oneshot_s *oneshot, uint64_t period; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); DEBUGASSERT(oneshot->timer); @@ -437,8 +436,8 @@ int pic32mz_oneshot_cancel(struct pic32mz_oneshot_s *oneshot, ts->tv_nsec = nsec; } - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/renesas/src/rx65n/rx65n_sbram.c b/arch/renesas/src/rx65n/rx65n_sbram.c index 5702f9707a8..486626b5949 100644 --- a/arch/renesas/src/rx65n/rx65n_sbram.c +++ b/arch/renesas/src/rx65n/rx65n_sbram.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -170,7 +171,8 @@ static void rx65n_sbram_dump(struct sbramfh_s *bbf, char *op) _info(" fileno:%d\n", (int) bbf->fileno); _info(" dirty:%d\n", (int) bbf->dirty); _info(" length:%d\n", (int) bbf->len); - _info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec); + _info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec, + bbf->lastwrite.tv_nsec); _info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n", bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]); } diff --git a/arch/risc-v/src/common/espressif/esp_ets_timer_legacy.c b/arch/risc-v/src/common/espressif/esp_ets_timer_legacy.c index c892926185b..c2981660f9b 100644 --- a/arch/risc-v/src/common/espressif/esp_ets_timer_legacy.c +++ b/arch/risc-v/src/common/espressif/esp_ets_timer_legacy.c @@ -203,7 +203,7 @@ void IRAM_ATTR ets_timer_arm(ets_timer *ptimer, uint32_t time_ms, bool repeat_flag) { - uint64_t time_us = 1000LL * (uint64_t) time_ms; + uint64_t time_us = 1000LL * (uint64_t)time_ms; assert(timer_initialized(ptimer)); diff --git a/arch/risc-v/src/common/espressif/esp_rtc.c b/arch/risc-v/src/common/espressif/esp_rtc.c index 7c404e028d5..ed76d633527 100644 --- a/arch/risc-v/src/common/espressif/esp_rtc.c +++ b/arch/risc-v/src/common/espressif/esp_rtc.c @@ -630,8 +630,7 @@ static int esp_rtc_rdalarm(struct rtc_lowerhalf_s *lower, ts.tv_nsec = ((esp_hr_timer_time_us() + g_rtc_save->offset + cbinfo->deadline_us) % USEC_PER_SEC) * NSEC_PER_USEC; - localtime_r((const time_t *)&ts.tv_sec, - (struct tm *)alarminfo->time); + localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time); spin_unlock_irqrestore(&priv->lock, flags); diff --git a/arch/risc-v/src/common/supervisor/riscv_sbi.c b/arch/risc-v/src/common/supervisor/riscv_sbi.c index 81780dd8fd3..42ab3c452ee 100644 --- a/arch/risc-v/src/common/supervisor/riscv_sbi.c +++ b/arch/risc-v/src/common/supervisor/riscv_sbi.c @@ -131,7 +131,7 @@ uint64_t riscv_sbi_get_time(void) } while (hi != READ_CSR(CSR_TIMEH)); - return (((uint64_t) hi) << 32) | lo; + return (((uint64_t)hi) << 32) | lo; #endif } diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_ble_adapter.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_ble_adapter.c index 87591b02948..2fef2b25e2d 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_ble_adapter.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_ble_adapter.c @@ -1399,7 +1399,7 @@ static uint32_t IRAM_ATTR btdm_lpcycles_2_hus(uint32_t cycles, static uint32_t IRAM_ATTR btdm_hus_2_lpcycles(uint32_t us) { uint64_t cycles; - cycles = ((uint64_t)(us) << g_btdm_lpcycle_us_frac) / g_btdm_lpcycle_us; + cycles = ((uint64_t)us << g_btdm_lpcycle_us_frac) / g_btdm_lpcycle_us; return (uint32_t)cycles; } diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_freerun.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_freerun.c index d0063550d7b..06811346300 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_freerun.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_freerun.c @@ -301,8 +301,8 @@ int esp32c3_freerun_counter(struct esp32c3_freerun_s *freerun, ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo(" usec=%" PRIu64 " ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo(" usec=%" PRIu64 " ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_oneshot.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_oneshot.c index 7b799a49b62..e7b214f4247 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_oneshot.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_oneshot.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -258,9 +259,8 @@ int esp32c3_oneshot_start(struct esp32c3_oneshot_s *oneshot, uint64_t timeout_us; int ret = OK; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot != NULL); DEBUGASSERT(handler != NULL); DEBUGASSERT(ts != NULL); diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_rtc.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_rtc.c index 3d97fb6a7c8..0db475b59c5 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_rtc.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_rtc.c @@ -735,7 +735,7 @@ static uint32_t IRAM_ATTR esp32c3_rtc_clk_cal_internal( expected_freq = RTC_SLOW_CLK_FREQ_90K; } - us_time_estimate = (uint32_t) (((uint64_t) slowclk_cycles) * + us_time_estimate = (uint32_t)(((uint64_t)slowclk_cycles) * MHZ / expected_freq); /* Start calibration */ @@ -2509,7 +2509,7 @@ uint64_t IRAM_ATTR esp32c3_rtc_time_get(void) modifyreg32(RTC_CNTL_TIME_UPDATE_REG, 0, RTC_CNTL_TIME_UPDATE); rtc_time = getreg32(RTC_CNTL_TIME0_REG); - rtc_time |= ((uint64_t) getreg32(RTC_CNTL_TIME1_REG)) << 32; + rtc_time |= ((uint64_t)getreg32(RTC_CNTL_TIME1_REG)) << 32; return rtc_time; } diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_rtc_lowerhalf.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_rtc_lowerhalf.c index 180ea68e1c5..762ba07651d 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_rtc_lowerhalf.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_rtc_lowerhalf.c @@ -483,8 +483,7 @@ static int rtc_lh_rdalarm(struct rtc_lowerhalf_s *lower, flags = spin_lock_irqsave(&priv->lock); ret = up_rtc_rdalarm(&ts, alarminfo->id); - localtime_r((const time_t *)&ts.tv_sec, - (struct tm *)alarminfo->time); + localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time); spin_unlock_irqrestore(&priv->lock, flags); diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_sha.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_sha.c index 83cd10350c6..ecf8e919889 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_sha.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_sha.c @@ -47,36 +47,36 @@ * Pre-processor Definitions ****************************************************************************/ -#define PUT_UINT32_BE(n,b,i) \ -{ \ - (b)[(i)] = (unsigned char) ((n) >> 24); \ - (b)[(i) + 1] = (unsigned char) ((n) >> 16); \ - (b)[(i) + 2] = (unsigned char) ((n) >> 8); \ - (b)[(i) + 3] = (unsigned char) ((n)); \ +#define PUT_UINT32_BE(n,b,i) \ +{ \ + (b)[(i)] = (unsigned char)((n) >> 24); \ + (b)[(i) + 1] = (unsigned char)((n) >> 16); \ + (b)[(i) + 2] = (unsigned char)((n) >> 8); \ + (b)[(i) + 3] = (unsigned char)((n)); \ } -#define GET_UINT64_BE(n,b,i) \ -{ \ - (n) = ((uint64_t) (b)[(i)] << 56) \ - | ((uint64_t) (b)[(i) + 1] << 48) \ - | ((uint64_t) (b)[(i) + 2] << 40) \ - | ((uint64_t) (b)[(i) + 3] << 32) \ - | ((uint64_t) (b)[(i) + 4] << 24) \ - | ((uint64_t) (b)[(i) + 5] << 16) \ - | ((uint64_t) (b)[(i) + 6] << 8) \ - | ((uint64_t) (b)[(i) + 7]); \ +#define GET_UINT64_BE(n,b,i) \ +{ \ + (n) = ((uint64_t)(b)[(i)] << 56) \ + | ((uint64_t)(b)[(i) + 1] << 48) \ + | ((uint64_t)(b)[(i) + 2] << 40) \ + | ((uint64_t)(b)[(i) + 3] << 32) \ + | ((uint64_t)(b)[(i) + 4] << 24) \ + | ((uint64_t)(b)[(i) + 5] << 16) \ + | ((uint64_t)(b)[(i) + 6] << 8) \ + | ((uint64_t)(b)[(i) + 7]); \ } -#define PUT_UINT64_BE(n,b,i) \ -{ \ - (b)[(i)] = (uint8_t) ((n) >> 56); \ - (b)[(i) + 1] = (uint8_t) ((n) >> 48); \ - (b)[(i) + 2] = (uint8_t) ((n) >> 40); \ - (b)[(i) + 3] = (uint8_t) ((n) >> 32); \ - (b)[(i) + 4] = (uint8_t) ((n) >> 24); \ - (b)[(i) + 5] = (uint8_t) ((n) >> 16); \ - (b)[(i) + 6] = (uint8_t) ((n) >> 8); \ - (b)[(i) + 7] = (uint8_t) ((n)); \ +#define PUT_UINT64_BE(n,b,i) \ +{ \ + (b)[(i)] = (uint8_t)((n) >> 56); \ + (b)[(i) + 1] = (uint8_t)((n) >> 48); \ + (b)[(i) + 2] = (uint8_t)((n) >> 40); \ + (b)[(i) + 3] = (uint8_t)((n) >> 32); \ + (b)[(i) + 4] = (uint8_t)((n) >> 24); \ + (b)[(i) + 5] = (uint8_t)((n) >> 16); \ + (b)[(i) + 6] = (uint8_t)((n) >> 8); \ + (b)[(i) + 7] = (uint8_t)((n)); \ } #define SHR(x,n) ((x) >> (n)) diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_tickless.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_tickless.c index eb0a37a9254..5828687edf4 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_tickless.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_tickless.c @@ -191,7 +191,7 @@ static inline uint64_t up_tmr_getcounter(void) static inline uint64_t up_tmr_getalarmvalue(void) { - return ((uint64_t) getreg32(SYS_TIMER_SYSTIMER_TARGET0_HI_REG) << 32) \ + return ((uint64_t)getreg32(SYS_TIMER_SYSTIMER_TARGET0_HI_REG) << 32) \ | getreg32(SYS_TIMER_SYSTIMER_TARGET0_LO_REG); } diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_tim.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_tim.c index 27baa0a7ef1..5cb08585501 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_tim.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_tim.c @@ -384,10 +384,10 @@ static void esp32c3_tim_getcounter(struct esp32c3_tim_dev_s *dev, /* Discard the top 12 bits */ value_32 &= LOW_20_MASK; - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(SYS_TIMER_SYSTIMER_UNIT1_VALUE_LO_REG); - *value |= (uint64_t)value_32; + *value |= value_32; } else { @@ -402,10 +402,10 @@ static void esp32c3_tim_getcounter(struct esp32c3_tim_dev_s *dev, /* Discard the top 10 bits */ value_32 &= LOW_22_MASK; - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T0LO_REG(priv->id)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } } @@ -521,10 +521,10 @@ static void esp32c3_tim_getalarmvalue(struct esp32c3_tim_dev_s *dev, /* Get only the 20 low bits. */ value_32 &= LOW_20_MASK; - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(SYS_TIMER_SYSTIMER_TARGET2_LO_REG); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } else { @@ -535,10 +535,10 @@ static void esp32c3_tim_getalarmvalue(struct esp32c3_tim_dev_s *dev, /* Get only the 22 low bits. */ value_32 &= LOW_22_MASK; - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T0ALARMLO_REG(priv->id)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } } diff --git a/arch/risc-v/src/mpfs/mpfs_ddr.c b/arch/risc-v/src/mpfs/mpfs_ddr.c index 10f1719beb7..b28038e543f 100644 --- a/arch/risc-v/src/mpfs/mpfs_ddr.c +++ b/arch/risc-v/src/mpfs/mpfs_ddr.c @@ -2090,7 +2090,7 @@ static inline uint64_t rotl(uint64_t x, int k) return (x << k) | (x >> (-k & 0x3f)); } -static int mpfs_ddr_rand(void) +static uint32_t mpfs_ddr_rand(void) { uint64_t s0 = prng_state[0]; uint64_t s1 = prng_state[1]; @@ -2099,7 +2099,7 @@ static int mpfs_ddr_rand(void) prng_state[0] = s0 ^ rotl(s1, 29); prng_state[1] = s0 ^ (s1 << 9); - return (int)result; + return (uint32_t)result; } /**************************************************************************** @@ -2145,7 +2145,7 @@ static void mpfs_ddr_write(struct mpfs_ddr_priv_s *priv, break; case PATTERN_RANDOM: - data = (uint64_t)mpfs_ddr_rand(); + data = mpfs_ddr_rand(); break; case PATTERN_CCCCCCCC: @@ -2212,7 +2212,7 @@ static void mpfs_ddr_write(struct mpfs_ddr_priv_s *priv, break; case PATTERN_RANDOM: - data = (uint64_t)mpfs_ddr_rand(); + data = mpfs_ddr_rand(); break; case PATTERN_CCCCCCCC: @@ -2287,7 +2287,7 @@ uint32_t mpfs_ddr_read(struct mpfs_ddr_priv_s *priv, break; case PATTERN_RANDOM: - data = (uint64_t)mpfs_ddr_rand(); + data = mpfs_ddr_rand(); *ddr_word_ptr = data; *ddr_32_pt_t = (uint32_t)data; break; @@ -2366,8 +2366,8 @@ uint32_t mpfs_ddr_read(struct mpfs_ddr_priv_s *priv, break; case PATTERN_RANDOM: - data = (uint64_t)mpfs_ddr_rand(); - mpfs_ddr_rand_addr_offset = (uint32_t)(mpfs_ddr_rand() & + data = mpfs_ddr_rand(); + mpfs_ddr_rand_addr_offset = (mpfs_ddr_rand() & 0xffffc); ddr_word_ptr = first_ddr_word_pt_t + mpfs_ddr_rand_addr_offset; diff --git a/arch/risc-v/src/rp23xx-rv/rp23xx_clock.c b/arch/risc-v/src/rp23xx-rv/rp23xx_clock.c index d68033efb89..d1203c678d6 100644 --- a/arch/risc-v/src/rp23xx-rv/rp23xx_clock.c +++ b/arch/risc-v/src/rp23xx-rv/rp23xx_clock.c @@ -124,7 +124,7 @@ bool rp23xx_clock_configure(int clk_index, * (left shift by 16) */ - div = (uint32_t) (((uint64_t) src_freq << 16) / freq); + div = (uint32_t)(((uint64_t)src_freq << 16) / freq); /* If increasing divisor, set divisor before source. Otherwise set source * before divisor. This avoids a momentary overspeed when e.g. switching diff --git a/arch/sparc/src/bm3803/bm3803_freerun.c b/arch/sparc/src/bm3803/bm3803_freerun.c index aa10a9370ba..5ed69de022a 100644 --- a/arch/sparc/src/bm3803/bm3803_freerun.c +++ b/arch/sparc/src/bm3803/bm3803_freerun.c @@ -232,8 +232,8 @@ int bm3803_freerun_counter(struct bm3803_freerun_s *freerun, ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%lld, %ld)\n", - usec, ts->tv_sec, ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/sparc/src/bm3803/bm3803_oneshot.c b/arch/sparc/src/bm3803/bm3803_oneshot.c index 4c7f9bba616..9eff78c46a3 100644 --- a/arch/sparc/src/bm3803/bm3803_oneshot.c +++ b/arch/sparc/src/bm3803/bm3803_oneshot.c @@ -206,8 +206,8 @@ int bm3803_oneshot_start(struct bm3803_oneshot_s *oneshot, uint64_t period; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", handler, arg, - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", handler, arg, + (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); DEBUGASSERT(oneshot->tch); @@ -393,8 +393,8 @@ int bm3803_oneshot_cancel(struct bm3803_oneshot_s *oneshot, ts->tv_nsec = nsec; } - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/x86_64/src/intel64/intel64_oneshot.c b/arch/x86_64/src/intel64/intel64_oneshot.c index 62f562698a2..a98b8cea555 100644 --- a/arch/x86_64/src/intel64/intel64_oneshot.c +++ b/arch/x86_64/src/intel64/intel64_oneshot.c @@ -290,9 +290,8 @@ int intel64_oneshot_start(struct intel64_oneshot_s *oneshot, uint64_t compare = 0; irqstate_t flags; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot && handler && ts); DEBUGASSERT(oneshot->tch); @@ -464,8 +463,8 @@ int intel64_oneshot_cancel(struct intel64_oneshot_s *oneshot, ts->tv_sec = sec; ts->tv_nsec = nsec; - tmrinfo("remaining (%lu, %lu)\n", - (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("remaining (%jd, %ld)\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); } return OK; diff --git a/arch/xtensa/src/common/espressif/esp_rtc.c b/arch/xtensa/src/common/espressif/esp_rtc.c index c47ac898d57..2d08b1d056e 100644 --- a/arch/xtensa/src/common/espressif/esp_rtc.c +++ b/arch/xtensa/src/common/espressif/esp_rtc.c @@ -629,8 +629,7 @@ static int esp_rtc_rdalarm(struct rtc_lowerhalf_s *lower, ts.tv_nsec = ((esp_hr_timer_time_us() + g_rtc_save->offset + cbinfo->deadline_us) % USEC_PER_SEC) * NSEC_PER_USEC; - localtime_r((const time_t *)&ts.tv_sec, - (struct tm *)alarminfo->time); + localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time); spin_unlock_irqrestore(&priv->lock, flags); diff --git a/arch/xtensa/src/esp32/esp32_freerun.c b/arch/xtensa/src/esp32/esp32_freerun.c index 11098f19f2c..65f07cb0669 100644 --- a/arch/xtensa/src/esp32/esp32_freerun.c +++ b/arch/xtensa/src/esp32/esp32_freerun.c @@ -292,8 +292,8 @@ int esp32_freerun_counter(struct esp32_freerun_s *freerun, ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo("usec=%llu ts=(%" PRIu32 ", %" PRIu32 ")\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo("usec=%llu ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/xtensa/src/esp32/esp32_oneshot.c b/arch/xtensa/src/esp32/esp32_oneshot.c index d182188e55b..b13c22468a2 100644 --- a/arch/xtensa/src/esp32/esp32_oneshot.c +++ b/arch/xtensa/src/esp32/esp32_oneshot.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -249,9 +250,8 @@ int esp32_oneshot_start(struct esp32_oneshot_s *oneshot, uint64_t timeout_us; int ret = OK; - tmrinfo("handler=%p arg=%p, ts=(%" PRIu32 ", %" PRIu32 ")\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot != NULL); DEBUGASSERT(handler != NULL); DEBUGASSERT(ts != NULL); diff --git a/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c b/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c index 8a5452ddb7e..96edf50c243 100644 --- a/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c +++ b/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c @@ -154,8 +154,8 @@ static int esp32_max_lh_delay(struct oneshot_lowerhalf_s *lower, ts->tv_sec = UINT32_MAX; ts->tv_nsec = NSEC_PER_SEC - 1; - tmrinfo("max sec=%" PRId64 "\n", ts->tv_sec); - tmrinfo("max nsec=%" PRId32 "\n", ts->tv_nsec); + tmrinfo("max sec=%jd\n", (intmax_t)ts->tv_sec); + tmrinfo("max nsec=%ld\n", ts->tv_nsec); return OK; } diff --git a/arch/xtensa/src/esp32/esp32_tim.c b/arch/xtensa/src/esp32/esp32_tim.c index 4c07e919246..f0740bcd7b7 100644 --- a/arch/xtensa/src/esp32/esp32_tim.c +++ b/arch/xtensa/src/esp32/esp32_tim.c @@ -351,10 +351,10 @@ static void esp32_tim_getcounter(struct esp32_tim_dev_s *dev, /* Read value */ value_32 = esp32_tim_getreg(dev, TIM_HI_OFFSET); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = esp32_tim_getreg(dev, TIM_LO_OFFSET); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } /**************************************************************************** @@ -420,10 +420,10 @@ static void esp32_tim_getalarmvalue(struct esp32_tim_dev_s *dev, /* Read value */ value_32 = esp32_tim_getreg(dev, TIMG_ALARM_HI_OFFSET); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = esp32_tim_getreg(dev, TIMG_ALARM_LO_OFFSET); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } /**************************************************************************** diff --git a/arch/xtensa/src/esp32s2/esp32s2_freerun.c b/arch/xtensa/src/esp32s2/esp32s2_freerun.c index 57ed96fbe1f..2de1102e8d0 100644 --- a/arch/xtensa/src/esp32s2/esp32s2_freerun.c +++ b/arch/xtensa/src/esp32s2/esp32s2_freerun.c @@ -296,8 +296,8 @@ int esp32s2_freerun_counter(struct esp32s2_freerun_s *freerun, ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo(" usec=%" PRIu64 " ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo(" usec=%" PRIu64 " ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/xtensa/src/esp32s2/esp32s2_oneshot.c b/arch/xtensa/src/esp32s2/esp32s2_oneshot.c index 2ee16c5722e..f820027eb84 100644 --- a/arch/xtensa/src/esp32s2/esp32s2_oneshot.c +++ b/arch/xtensa/src/esp32s2/esp32s2_oneshot.c @@ -263,9 +263,8 @@ int esp32s2_oneshot_start(struct esp32s2_oneshot_s *oneshot, uint64_t timeout_us; int ret = OK; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot != NULL); DEBUGASSERT(handler != NULL); DEBUGASSERT(ts != NULL); diff --git a/arch/xtensa/src/esp32s2/esp32s2_oneshot_lowerhalf.c b/arch/xtensa/src/esp32s2/esp32s2_oneshot_lowerhalf.c index d2de715a5f8..c00f497a04f 100644 --- a/arch/xtensa/src/esp32s2/esp32s2_oneshot_lowerhalf.c +++ b/arch/xtensa/src/esp32s2/esp32s2_oneshot_lowerhalf.c @@ -155,7 +155,7 @@ static int oneshot_lh_max_delay(struct oneshot_lowerhalf_s *lower, ts->tv_sec = UINT32_MAX; ts->tv_nsec = NSEC_PER_SEC - 1; - tmrinfo("max sec=%" PRId64 "\n", ts->tv_sec); + tmrinfo("max sec=%jd\n", (intmax_t)ts->tv_sec); tmrinfo("max nsec=%ld\n", ts->tv_nsec); return OK; diff --git a/arch/xtensa/src/esp32s2/esp32s2_tim.c b/arch/xtensa/src/esp32s2/esp32s2_tim.c index 96857be68c1..5745e4dad33 100644 --- a/arch/xtensa/src/esp32s2/esp32s2_tim.c +++ b/arch/xtensa/src/esp32s2/esp32s2_tim.c @@ -487,10 +487,10 @@ static void esp32s2_tim_getcounter(struct esp32s2_tim_dev_s *dev, /* Read value */ value_32 = getreg32(SYSTIMER_VALUE_HI_REG); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(SYSTIMER_VALUE_LO_REG); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } else { @@ -503,10 +503,10 @@ static void esp32s2_tim_getcounter(struct esp32s2_tim_dev_s *dev, /* Read value */ value_32 = getreg32(TIMG_T0HI_REG(priv->gid)); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T0LO_REG(priv->gid)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } else { @@ -517,10 +517,10 @@ static void esp32s2_tim_getcounter(struct esp32s2_tim_dev_s *dev, /* Read value */ value_32 = getreg32(TIMG_T1HI_REG(priv->gid)); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T1LO_REG(priv->gid)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } } } @@ -639,28 +639,28 @@ static void esp32s2_tim_getalarmvalue(struct esp32s2_tim_dev_s *dev, if (priv->tid == SYSTIMER_COMP0) { value_32 = getreg32(SYSTIMER_TARGET0_HI_REG); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(SYSTIMER_TARGET0_LO_REG); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } else { if (priv->tid == TIMER0) { value_32 = getreg32(TIMG_T0ALARMHI_REG(priv->gid)); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T0ALARMLO_REG(priv->gid)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } else { value_32 = getreg32(TIMG_T1ALARMHI_REG(priv->gid)); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T1ALARMLO_REG(priv->gid)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } } } diff --git a/arch/xtensa/src/esp32s3/esp32s3_freerun.c b/arch/xtensa/src/esp32s3/esp32s3_freerun.c index d09e07b4ca2..ea0bced8482 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_freerun.c +++ b/arch/xtensa/src/esp32s3/esp32s3_freerun.c @@ -315,8 +315,8 @@ int esp32s3_freerun_counter(struct esp32s3_freerun_s *freerun, ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; - tmrinfo(" usec=%" PRIu64 " ts=(%lu, %lu)\n", - usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); + tmrinfo(" usec=%" PRIu64 " ts=(%jd, %ld)\n", + usec, (intmax_t)ts->tv_sec, ts->tv_nsec); return OK; } diff --git a/arch/xtensa/src/esp32s3/esp32s3_oneshot.c b/arch/xtensa/src/esp32s3/esp32s3_oneshot.c index ba45b5e2fde..53d2eee0414 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_oneshot.c +++ b/arch/xtensa/src/esp32s3/esp32s3_oneshot.c @@ -262,9 +262,8 @@ int esp32s3_oneshot_start(struct esp32s3_oneshot_s *oneshot, uint64_t timeout_us; int ret = OK; - tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", - handler, arg, (unsigned long)ts->tv_sec, - (unsigned long)ts->tv_nsec); + tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", + handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec); DEBUGASSERT(oneshot != NULL); DEBUGASSERT(handler != NULL); diff --git a/arch/xtensa/src/esp32s3/esp32s3_oneshot_lowerhalf.c b/arch/xtensa/src/esp32s3/esp32s3_oneshot_lowerhalf.c index ccc60ac5aaf..ac0e81e7343 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_oneshot_lowerhalf.c +++ b/arch/xtensa/src/esp32s3/esp32s3_oneshot_lowerhalf.c @@ -155,7 +155,7 @@ static int oneshot_lh_max_delay(struct oneshot_lowerhalf_s *lower, ts->tv_sec = UINT32_MAX; ts->tv_nsec = NSEC_PER_SEC - 1; - tmrinfo("max sec=%" PRId64 "\n", ts->tv_sec); + tmrinfo("max sec=%jd\n", (intmax_t)ts->tv_sec); tmrinfo("max nsec=%ld\n", ts->tv_nsec); return OK; diff --git a/arch/xtensa/src/esp32s3/esp32s3_tickless.c b/arch/xtensa/src/esp32s3/esp32s3_tickless.c index d2dffcc9f2b..3a3a1d7f5e7 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_tickless.c +++ b/arch/xtensa/src/esp32s3/esp32s3_tickless.c @@ -148,7 +148,7 @@ static inline uint64_t tickless_getcounter(void) } while (lo_start != lo); - counter = ((uint64_t) hi << 32) | lo; + counter = ((uint64_t)hi << 32) | lo; return counter; } @@ -171,7 +171,7 @@ static inline uint64_t tickless_getalarmvalue(void) { uint32_t hi = getreg32(SYSTIMER_TARGET0_HI_REG); uint32_t lo = getreg32(SYSTIMER_TARGET0_LO_REG); - uint64_t ticks = ((uint64_t) hi << 32) | lo; + uint64_t ticks = ((uint64_t)hi << 32) | lo; return ticks; } diff --git a/arch/xtensa/src/esp32s3/esp32s3_tim.c b/arch/xtensa/src/esp32s3/esp32s3_tim.c index 9e533b6d40d..336d05c50f8 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_tim.c +++ b/arch/xtensa/src/esp32s3/esp32s3_tim.c @@ -425,10 +425,10 @@ static void tim_getcounter(struct esp32s3_tim_dev_s *dev, uint64_t *value) /* Read value */ value_32 = getreg32(TIMG_T0HI_REG(priv->gid)); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T0LO_REG(priv->gid)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } else { @@ -439,10 +439,10 @@ static void tim_getcounter(struct esp32s3_tim_dev_s *dev, uint64_t *value) /* Read value */ value_32 = getreg32(TIMG_T1HI_REG(priv->gid)); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T1LO_REG(priv->gid)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } } @@ -545,18 +545,18 @@ static void tim_getalarmvalue(struct esp32s3_tim_dev_s *dev, uint64_t *value) if (priv->tid == ESP32S3_TIM_TIMER0) { value_32 = getreg32(TIMG_T0ALARMHI_REG(priv->gid)); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T0ALARMLO_REG(priv->gid)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } else { value_32 = getreg32(TIMG_T1ALARMHI_REG(priv->gid)); /* High 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; *value <<= SHIFT_32; value_32 = getreg32(TIMG_T1ALARMLO_REG(priv->gid)); /* Low 32 bits */ - *value |= (uint64_t)value_32; + *value |= value_32; } } diff --git a/crypto/random_pool.c b/crypto/random_pool.c index 2578edd391b..71d68311a51 100644 --- a/crypto/random_pool.c +++ b/crypto/random_pool.c @@ -433,7 +433,7 @@ void up_rngaddentropy(enum rnd_source_t kindof, FAR const uint32_t *buf, */ clock_systime_timespec(&ts); - tbuf[0] = ROTL_32((uint32_t)ts.tv_nsec, 17) ^ ROTL_32(ts.tv_sec, 3); + tbuf[0] = ROTL_32(ts.tv_nsec, 17) ^ ROTL_32(ts.tv_sec, 3); tbuf[0] += ROTL_32(kindof, 27); tbuf[0] += ROTL_32((uintptr_t)&tbuf[0], 11); diff --git a/drivers/misc/optee_rpc.c b/drivers/misc/optee_rpc.c index e3e8c6e39a5..1307ec97c24 100644 --- a/drivers/misc/optee_rpc.c +++ b/drivers/misc/optee_rpc.c @@ -80,8 +80,8 @@ static void optee_rpc_cmd_get_time(FAR struct optee_msg_arg *arg) return; } - arg->params[0].u.value.a = (uint32_t)ts.tv_sec; /* Seconds since epoch. */ - arg->params[0].u.value.b = (uint32_t)ts.tv_nsec; /* Nanoseconds. */ + arg->params[0].u.value.a = ts.tv_sec; /* Seconds since epoch. */ + arg->params[0].u.value.b = ts.tv_nsec; /* Nanoseconds. */ arg->ret = TEE_SUCCESS; } diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c index e64a48e6d47..ee5b4716320 100644 --- a/drivers/note/noteram_driver.c +++ b/drivers/note/noteram_driver.c @@ -817,9 +817,9 @@ static int noteram_dump_header(FAR struct lib_outstream_s *s, int cpu = 0; #endif - ret = lib_sprintf(s, "%8s-%-3u [%d] %3" PRIu64 ".%09ld: ", + ret = lib_sprintf(s, "%8s-%-3u [%d] %3jd.%09ld: ", note_get_taskname(pid, buf, TASK_NAME_SIZE), - get_pid(pid), cpu, ts.tv_sec, ts.tv_nsec); + get_pid(pid), cpu, (intmax_t)ts.tv_sec, ts.tv_nsec); return ret; } diff --git a/drivers/rpmsg/rpmsg_ping.c b/drivers/rpmsg/rpmsg_ping.c index 7784430e885..b20ff0a1afc 100644 --- a/drivers/rpmsg/rpmsg_ping.c +++ b/drivers/rpmsg/rpmsg_ping.c @@ -189,7 +189,8 @@ static void rpmsg_ping_logout(FAR const char *s, clock_t value) perf_convert(value, &ts); - syslog(LOG_EMERG, "%s: %" PRId64 " s, %ld ns\n", s, ts.tv_sec, ts.tv_nsec); + syslog(LOG_EMERG, "%s: %jd s, %ld ns\n", + s, (intmax_t)ts.tv_sec, ts.tv_nsec); } static void rpmsg_ping_logout_rate(uint64_t len, clock_t avg) diff --git a/drivers/sensors/mpl115a.c b/drivers/sensors/mpl115a.c index cb751ab3059..24cf7fa023c 100644 --- a/drivers/sensors/mpl115a.c +++ b/drivers/sensors/mpl115a.c @@ -281,7 +281,7 @@ static int mpl115a_getpressure(FAR struct mpl115a_dev_s *priv) /* These code are from Freescale AN3785 */ c12x2 = ((int32_t)priv->mpl115a_cal_c12 * tadc) >> 11; - a1 = (int32_t) (priv->mpl115a_cal_b1 + c12x2); + a1 = (int32_t)(priv->mpl115a_cal_b1 + c12x2); a1x1 = a1 * padc; y1 = (((int32_t)priv->mpl115a_cal_a0) << 10) + a1x1; a2x2 = (((int32_t)priv->mpl115a_cal_b2) * tadc) >> 1; diff --git a/drivers/sensors/ms56xx_uorb.c b/drivers/sensors/ms56xx_uorb.c index fa2753e2540..ce464c10766 100644 --- a/drivers/sensors/ms56xx_uorb.c +++ b/drivers/sensors/ms56xx_uorb.c @@ -491,11 +491,11 @@ static int32_t ms56xx_compensate_temp(FAR struct ms56xx_dev_s *priv, /* dt = d1 - c5 * 256 */ - dt = temp_raw - ((int32_t) c->c5 << 8); + dt = temp_raw - ((int32_t)c->c5 << 8); /* temp = 2000 + (dt * c6) / 8388608 */ - temp = 2000 + (((int64_t) (dt * c->c6)) >> 23); + temp = 2000 + (((int64_t)(dt * c->c6)) >> 23); /* Save dt that will be used for pressure calibration */ @@ -535,8 +535,8 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv, switch (priv->model) { case MS56XX_MODEL_MS5607: - off = ((int64_t) c->c2 << 17) + ((int64_t) (c->c4 * dt) >> 6); - sens = ((int64_t) c->c1 << 16) + ((int64_t) (c->c3 * dt) >> 7); + off = ((int64_t)c->c2 << 17) + ((int64_t)(c->c4 * dt) >> 6); + sens = ((int64_t)c->c1 << 16) + ((int64_t)(c->c3 * dt) >> 7); #if defined(CONFIG_MS56XX_SECOND_ORDER_COMPENSATE) if (*temp < 2000) { @@ -562,8 +562,8 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv, break; case MS56XX_MODEL_MS5611: - off = ((int64_t) c->c2 << 16) + ((int64_t) (c->c4 * dt) >> 7); - sens = ((int64_t) c->c1 << 15) + ((int64_t) (c->c3 * dt) >> 8); + off = ((int64_t)c->c2 << 16) + ((int64_t)(c->c4 * dt) >> 7); + sens = ((int64_t)c->c1 << 15) + ((int64_t)(c->c3 * dt) >> 8); #if defined(CONFIG_MS56XX_SECOND_ORDER_COMPENSATE) if (*temp < 2000) { diff --git a/drivers/sensors/scd30.c b/drivers/sensors/scd30.c index 3cee8495bed..2372b8e3084 100644 --- a/drivers/sensors/scd30.c +++ b/drivers/sensors/scd30.c @@ -440,12 +440,12 @@ static bool has_time_passed(struct timespec curr, struct timespec start, unsigned int secs_since_start) { - if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0) + if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0) { return start.tv_nsec <= curr.tv_nsec; } - return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0; + return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0; } /**************************************************************************** diff --git a/drivers/sensors/scd41.c b/drivers/sensors/scd41.c index 1127af0d4e7..e0912744602 100644 --- a/drivers/sensors/scd41.c +++ b/drivers/sensors/scd41.c @@ -430,12 +430,12 @@ static bool has_time_passed(struct timespec curr, struct timespec start, unsigned int secs_since_start) { - if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0) + if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0) { return start.tv_nsec <= curr.tv_nsec; } - return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0; + return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0; } /**************************************************************************** diff --git a/drivers/sensors/sgp30.c b/drivers/sensors/sgp30.c index c075566324a..d86565d48cf 100644 --- a/drivers/sensors/sgp30.c +++ b/drivers/sensors/sgp30.c @@ -460,12 +460,12 @@ static bool has_time_passed(FAR struct timespec *curr, FAR struct timespec *start, unsigned int secs_since_start) { - if ((long)((start->tv_sec + secs_since_start) - curr->tv_sec) == 0) + if ((start->tv_sec + secs_since_start) - curr->tv_sec == 0) { return start->tv_nsec <= curr->tv_nsec; } - return (long)((start->tv_sec + secs_since_start) - curr->tv_sec) <= 0; + return (start->tv_sec + secs_since_start) - curr->tv_sec <= 0; } /**************************************************************************** @@ -485,7 +485,7 @@ static bool time_has_passed_ms(FAR struct timespec *curr, if (start->tv_sec < curr->tv_sec) { - curr_msec += 1000 * ((long)(curr->tv_sec - start->tv_sec)); + curr_msec += 1000 * (curr->tv_sec - start->tv_sec); } return (start_msec + msecs_since_start) <= curr_msec; @@ -773,7 +773,7 @@ static ssize_t sgp30_read(FAR struct file *filep, FAR char *buffer, ts_sleep.tv_nsec += NSEC_PER_SEC; } - if ((long)ts_sleep.tv_sec >= 0) + if (ts_sleep.tv_sec >= 0) { ret = nxsig_nanosleep(&ts_sleep, NULL); if (ret == -EINTR) diff --git a/drivers/sensors/sht21.c b/drivers/sensors/sht21.c index c3213b5d280..1a9b7f0d9a0 100644 --- a/drivers/sensors/sht21.c +++ b/drivers/sensors/sht21.c @@ -263,12 +263,12 @@ static bool has_time_passed(struct timespec curr, struct timespec start, unsigned int secs_since_start) { - if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0) + if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0) { return start.tv_nsec <= curr.tv_nsec; } - return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0; + return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0; } /**************************************************************************** diff --git a/drivers/sensors/sht4x_uorb.c b/drivers/sensors/sht4x_uorb.c index 57265d452c8..75d22b216e2 100644 --- a/drivers/sensors/sht4x_uorb.c +++ b/drivers/sensors/sht4x_uorb.c @@ -523,12 +523,12 @@ static int sht4x_read(FAR struct sht4x_dev_s *priv, static bool has_time_passed(struct timespec curr, struct timespec start, unsigned int secs_since_start) { - if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0) + if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0) { return start.tv_nsec <= curr.tv_nsec; } - return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0; + return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0; } /**************************************************************************** diff --git a/drivers/sensors/sps30.c b/drivers/sensors/sps30.c index 960f808718b..883531b4677 100644 --- a/drivers/sensors/sps30.c +++ b/drivers/sensors/sps30.c @@ -452,12 +452,12 @@ static bool has_time_passed(struct timespec curr, struct timespec start, unsigned int secs_since_start) { - if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0) + if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0) { return start.tv_nsec <= curr.tv_nsec; } - return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0; + return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0; } /**************************************************************************** diff --git a/drivers/sensors/t67xx.c b/drivers/sensors/t67xx.c index a5750e31a81..f74308e24f7 100644 --- a/drivers/sensors/t67xx.c +++ b/drivers/sensors/t67xx.c @@ -406,12 +406,12 @@ static bool has_time_passed(struct timespec curr, struct timespec start, unsigned int secs_since_start) { - if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0) + if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0) { return start.tv_nsec <= curr.tv_nsec; } - return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0; + return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0; } /**************************************************************************** diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c index b930245a95e..668d70d8298 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -168,9 +168,9 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) # endif # else # if defined(CONFIG_SYSLOG_TIMESTAMP_MS) - "[%5ju.%03ld] " + "[%5jd.%03ld] " # else - "[%5ju.%06ld] " + "[%5jd.%06ld] " # endif # endif #endif @@ -216,10 +216,10 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) # endif # else # if defined(CONFIG_SYSLOG_TIMESTAMP_MS) - , (uintmax_t)ts.tv_sec + , (intmax_t)ts.tv_sec , ts.tv_nsec / NSEC_PER_MSEC # else - , (uintmax_t)ts.tv_sec + , (intmax_t)ts.tv_sec , ts.tv_nsec / NSEC_PER_USEC # endif # endif diff --git a/drivers/timers/ds3231.c b/drivers/timers/ds3231.c index 21b4d2b2f9e..eeec87bbb39 100644 --- a/drivers/timers/ds3231.c +++ b/drivers/timers/ds3231.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -405,7 +406,7 @@ int up_rtc_settime(FAR const struct timespec *tp) return -EAGAIN; } - rtcinfo("Setting time tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec); + rtcinfo("Setting time tp=(%jd,%ld)\n", (intmax_t)tp->tv_sec, tp->tv_nsec); /* Get the broken out time */ diff --git a/drivers/timers/mcp794xx.c b/drivers/timers/mcp794xx.c index 7d4d786ec73..872ccfba25b 100644 --- a/drivers/timers/mcp794xx.c +++ b/drivers/timers/mcp794xx.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -498,7 +499,7 @@ int up_rtc_settime(FAR const struct timespec *tp) return -EAGAIN; } - rtcinfo("Setting time tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec); + rtcinfo("Setting time tp=(%jd,%ld)\n", (intmax_t)tp->tv_sec, tp->tv_nsec); /* Get the broken out time */ diff --git a/drivers/timers/ptp_clock_dummy.c b/drivers/timers/ptp_clock_dummy.c index 80eacb3fb4c..fa5fe569769 100644 --- a/drivers/timers/ptp_clock_dummy.c +++ b/drivers/timers/ptp_clock_dummy.c @@ -24,6 +24,8 @@ #include +#include + #include #include @@ -116,8 +118,8 @@ static int ptp_clock_dummy_gettime(FAR struct ptp_lowerhalf_s *lower, sts->post_ts.tv_nsec = ts->tv_nsec; } - ptpinfo("ptp_clock_dummy_gettime sec:%ld, nsec:%ld\n", ts->tv_sec, - ts->tv_nsec); + ptpinfo("ptp_clock_dummy_gettime sec:%jd, nsec:%ld\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); return 0; } @@ -144,16 +146,16 @@ ptp_clock_dummy_getcrosststamp(FAR struct ptp_lowerhalf_s *lower, cts->monoraw.tv_sec = ts.tv_sec; cts->monoraw.tv_nsec = ts.tv_sec; - ptpinfo("ptp_clock_dummy_getcrosststamp sec:%ld, nsec:%ld\n", - (long)ts.tv_sec, ts.tv_nsec); + ptpinfo("ptp_clock_dummy_getcrosststamp sec:%jd, nsec:%ld\n", + (intmax_t)ts.tv_sec, ts.tv_nsec); return 0; } static int ptp_clock_dummy_settime(FAR struct ptp_lowerhalf_s *lower, FAR const struct timespec *ts) { - ptpinfo("ptp_clock_dummy_settime sec:%ld, nsec:%ld\n", (long)ts->tv_sec, - ts->tv_nsec); + ptpinfo("ptp_clock_dummy_settime sec:%jd, nsec:%ld\n", + (intmax_t)ts->tv_sec, ts->tv_nsec); return 0; } diff --git a/drivers/timers/rx8010.c b/drivers/timers/rx8010.c index b4189b663e7..b605a621523 100644 --- a/drivers/timers/rx8010.c +++ b/drivers/timers/rx8010.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -393,7 +394,7 @@ int up_rtc_settime(FAR const struct timespec *tp) return -EAGAIN; } - rtcinfo("Setting time tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec); + rtcinfo("Setting time tp=(%jd,%ld)\n", (intmax_t)tp->tv_sec, tp->tv_nsec); /* Get the broken out time */ diff --git a/fs/fat/fs_fat32util.c b/fs/fat/fs_fat32util.c index 9d97fe87fdf..1efcc009b53 100644 --- a/fs/fat/fs_fat32util.c +++ b/fs/fat/fs_fat32util.c @@ -390,7 +390,7 @@ uint32_t fat_systime2fattime(void) { /* Break done the seconds in date and time units */ - if (gmtime_r((FAR const time_t *)&ts.tv_sec, &tm) != NULL) + if (gmtime_r(&ts.tv_sec, &tm) != NULL) { /* FAT can only represent dates since 1980. struct tm can * represent dates since 1900. diff --git a/fs/nfs/nfs_vfsops.c b/fs/nfs/nfs_vfsops.c index c9912d6d249..1914b2d2bd9 100644 --- a/fs/nfs/nfs_vfsops.c +++ b/fs/nfs/nfs_vfsops.c @@ -2420,11 +2420,11 @@ static int nfs_statfs(FAR struct inode *mountpt, FAR struct statfs *sbp) sfp = (FAR struct rpc_reply_fsstat *)nmp->nm_iobuffer; sbp->f_bsize = NFS_FABLKSIZE; tquad = fxdr_hyper(&sfp->fsstat.sf_tbytes); - sbp->f_blocks = tquad / (uint64_t) NFS_FABLKSIZE; + sbp->f_blocks = tquad / NFS_FABLKSIZE; tquad = fxdr_hyper(&sfp->fsstat.sf_fbytes); - sbp->f_bfree = tquad / (uint64_t) NFS_FABLKSIZE; + sbp->f_bfree = tquad / NFS_FABLKSIZE; tquad = fxdr_hyper(&sfp->fsstat.sf_abytes); - sbp->f_bavail = tquad / (uint64_t) NFS_FABLKSIZE; + sbp->f_bavail = tquad / NFS_FABLKSIZE; tquad = fxdr_hyper(&sfp->fsstat.sf_tfiles); sbp->f_files = tquad; tquad = fxdr_hyper(&sfp->fsstat.sf_ffiles); diff --git a/fs/procfs/fs_procfscritmon.c b/fs/procfs/fs_procfscritmon.c index e2681b48f38..a87b2fc6a7c 100644 --- a/fs/procfs/fs_procfscritmon.c +++ b/fs/procfs/fs_procfscritmon.c @@ -235,9 +235,9 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr, /* Generate output for maximum time pre-emption disabled */ - linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%lu.%09lu", - (unsigned long)maxtime.tv_sec, - (unsigned long)maxtime.tv_nsec); + linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%jd.%09ld", + (intmax_t)maxtime.tv_sec, + maxtime.tv_nsec); copysize = procfs_memcpy(attr->line, linesize, buffer, buflen, offset); totalsize += copysize; @@ -269,9 +269,9 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr, /* Generate output for maximum time in a critical section */ - linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%lu.%09lu", - (unsigned long)maxtime.tv_sec, - (unsigned long)maxtime.tv_nsec); + linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%jd.%09ld", + (intmax_t)maxtime.tv_sec, + maxtime.tv_nsec); copysize = procfs_memcpy(attr->line, linesize, buffer, buflen, offset); totalsize += copysize; @@ -303,9 +303,9 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr, /* Generate output for max busywait time to enter csection(get spinlock) */ - linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%lu.%09lu", - (unsigned long)maxtime.tv_sec, - (unsigned long)maxtime.tv_nsec); + linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%jd.%09ld", + (intmax_t)maxtime.tv_sec, + maxtime.tv_nsec); copysize = procfs_memcpy(attr->line, linesize, buffer, buflen, offset); totalsize += copysize; @@ -335,10 +335,10 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr, /* Generate output for all busywait time to enter csection(get spinlock) */ - linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%lu.%09lu %2" + linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%jd.%09ld %2" PRId32 ".%04" PRId32 "%%", - (unsigned long)all_time.tv_sec, - (unsigned long)all_time.tv_nsec, + (intmax_t)all_time.tv_sec, + all_time.tv_nsec, rate / 10000, rate % 10000); copysize = procfs_memcpy(attr->line, linesize, buffer, buflen, offset); diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index 2cbf357ebbc..53398931fa6 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -791,9 +791,9 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile, /* Generate output for maximum time pre-emption disabled */ - linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%lu.%09lu %p,", - (unsigned long)maxtime.tv_sec, - (unsigned long)maxtime.tv_nsec, + linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%jd.%09ld %p,", + (intmax_t)maxtime.tv_sec, + maxtime.tv_nsec, tcb->preemp_max_caller); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); @@ -827,9 +827,9 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile, /* Generate output for maximum time in a critical section */ - linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%lu.%09lu %p,", - (unsigned long)maxtime.tv_sec, - (unsigned long)maxtime.tv_nsec, + linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%jd.%09ld %p,", + (intmax_t)maxtime.tv_sec, + maxtime.tv_nsec, tcb->crit_max_caller); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); @@ -863,9 +863,9 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile, /* Generate output for max busywait time */ - linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%lu.%09lu %p,", - (unsigned long)maxtime.tv_sec, - (unsigned long)maxtime.tv_nsec, + linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%jd.%09ld %p,", + (intmax_t)maxtime.tv_sec, + maxtime.tv_nsec, tcb->busywait_max_caller); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); @@ -891,9 +891,9 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile, /* Generate output for all busywait time */ - linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%lu.%09lu,", - (unsigned long)maxtime.tv_sec, - (unsigned long)maxtime.tv_nsec); + linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%jd.%09ld,", + (intmax_t)maxtime.tv_sec, + maxtime.tv_nsec); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); @@ -929,11 +929,11 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile, */ linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, - "%lu.%09lu,%lu.%09lu\n", - (unsigned long)maxtime.tv_sec, - (unsigned long)maxtime.tv_nsec, - (unsigned long)runtime.tv_sec, - (unsigned long)(runtime.tv_nsec)); + "%jd.%09ld,%jd.%09ld\n", + (intmax_t)maxtime.tv_sec, + maxtime.tv_nsec, + (intmax_t)runtime.tv_sec, + runtime.tv_nsec); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); diff --git a/libs/libc/time/lib_gethrtime.c b/libs/libc/time/lib_gethrtime.c index 930a8ebcafb..41be074815b 100644 --- a/libs/libc/time/lib_gethrtime.c +++ b/libs/libc/time/lib_gethrtime.c @@ -49,5 +49,5 @@ hrtime_t gethrtime(void) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - return (hrtime_t)1000000000 * ts.tv_sec + ts.tv_nsec; + return 1000000000 * ts.tv_sec + ts.tv_nsec; } diff --git a/mm/ubsan/ubsan.c b/mm/ubsan/ubsan.c index 63d8ee10511..f0b2944a04e 100644 --- a/mm/ubsan/ubsan.c +++ b/mm/ubsan/ubsan.c @@ -161,8 +161,7 @@ static int64_t get_signed_val(FAR struct type_descriptor *type, uint64_t mask = (1llu << bits) - 1; uint64_t ret = (uintptr_t)val & mask; - return (int64_t)(((ret & (1llu << (bits - 1))) != 0) ? - ret | ~mask : ret); + return ret & (1llu << (bits - 1)) != 0 ? ret | ~mask : ret; } return *(FAR int64_t *)val; diff --git a/sched/clock/clock_adjtime.c b/sched/clock/clock_adjtime.c index 0ab524fc5c9..b18ec321170 100644 --- a/sched/clock/clock_adjtime.c +++ b/sched/clock/clock_adjtime.c @@ -202,7 +202,7 @@ int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta) if (delta) { - adjust_usec = (long long)delta->tv_sec * USEC_PER_SEC + delta->tv_usec; + adjust_usec = delta->tv_sec * USEC_PER_SEC + delta->tv_usec; ret = adjtime_start(adjust_usec); } diff --git a/sched/clock/clock_getres.c b/sched/clock/clock_getres.c index 1348e93a0cc..53c88d57cd0 100644 --- a/sched/clock/clock_getres.c +++ b/sched/clock/clock_getres.c @@ -71,8 +71,8 @@ int clock_getres(clockid_t clock_id, struct timespec *res) res->tv_sec = 0; res->tv_nsec = NSEC_PER_TICK; - sinfo("Returning res=(%d,%d)\n", (int)res->tv_sec, - (int)res->tv_nsec); + sinfo("Returning res=(%jd,%ld)\n", + (intmax_t)res->tv_sec, res->tv_nsec); break; #ifdef CONFIG_PTP_CLOCK