bsps/arm: Address -Wsign-compare warnings

This warning occurs when comparing a signed variable to an unsigned one.
This addresses warnings that only occurred on 64-bit targets.  For the
ones which only appeared on 64-bit targets, the cause was frequently
a mismatch when comparing a combination off_t, ssize_t, and int.
This commit is contained in:
Joel Sherrill
2026-02-05 08:18:27 -06:00
committed by Kinsey Moore
parent 92d281243e
commit 6de3352acb
19 changed files with 43 additions and 23 deletions
@@ -2044,7 +2044,11 @@ ALT_STATUS_CODE alt_qspi_erase_chip(void)
uint32_t die_count = qspi_device_size / ALT_QSPI_N25Q_DIE_SIZE;
#ifdef __rtems__
for (uint32_t i = 0; i < die_count; ++i)
#else
for (int i = 0; i < die_count; ++i)
#endif
{
if (status != ALT_E_SUCCESS)
{
@@ -2161,7 +2165,11 @@ static bool is_pow_2(uint32_t n)
static uint32_t log2u(uint32_t value)
{
uint32_t exp = 0;
#ifdef __rtems__
while ((exp < 32) && (value != (1U << exp)))
#else
while ((exp < 32) && (value != (1 << exp)))
#endif
{
++exp;
}
+5 -5
View File
@@ -269,7 +269,7 @@ static rtems_status_code ds1339_read(uint8_t addr, void* buf, size_t size)
if (sc == RTEMS_SUCCESSFUL)
{
rv = read(fd, buf, size);
if (rv != size)
if (rv != (ssize_t)size)
sc = RTEMS_IO_ERROR;
}
@@ -294,7 +294,7 @@ static rtems_status_code ds1339_write(uint8_t addr, void* buf, size_t size)
uint8_t local_buf[DS1339_MAX_WRITE_SIZE];
int write_size = size + 1;
assert(write_size <= DS1339_MAX_WRITE_SIZE);
assert(write_size <= (ssize_t)DS1339_MAX_WRITE_SIZE);
local_buf[0] = addr;
memcpy(&local_buf[1], buf, size);
@@ -649,14 +649,14 @@ static rtems_status_code m41st87_read(uint8_t addr, void* buf, size_t size)
if (sc == RTEMS_SUCCESSFUL)
{
rv = write(fd, &addr, sizeof(addr));
if (rv != sizeof(addr))
if (rv != (ssize_t)sizeof(addr))
sc = RTEMS_IO_ERROR;
}
if (sc == RTEMS_SUCCESSFUL)
{
rv = read(fd, buf, size);
if (rv != size)
if (rv != (ssize_t)size)
sc = RTEMS_IO_ERROR;
}
@@ -681,7 +681,7 @@ static rtems_status_code m41st87_write(uint8_t addr, void* buf, size_t size)
uint8_t local_buf[M41ST87_MAX_WRITE_SIZE];
int write_size = size + 1;
assert(write_size <= M41ST87_MAX_WRITE_SIZE);
assert(write_size <= (ssize_t)M41ST87_MAX_WRITE_SIZE);
local_buf[0] = addr;
memcpy(&local_buf[1], buf, size);
+1 -1
View File
@@ -508,7 +508,7 @@ void beagle_i2c_init(phandle_t node)
if (err < 0) {
/* No path was provided in the device tree therefore use the default one */
snprintf(bus_path, PATH_LEN, "/dev/i2c-%d", unit);
} else if (err >= PATH_LEN) {
} else if ((size_t)err >= PATH_LEN) {
/* Null terminate the string */
bus_path[PATH_LEN - 1] = 0;
printk("i2c: bus path too long, trucated %s\n", bus_path);
+1 -1
View File
@@ -315,7 +315,7 @@ static int imx_uart_poll_read(int minor)
static ssize_t imx_uart_poll_write(int minor, const char *buf, size_t len)
{
int i;
size_t i;
for (i = 0; i < len; i++) {
/* Wait for there to be room in the fifo */
while (!(imx_uart_data[minor].regs->sr2 & MC9328MXL_UART_SR2_TXDC)) {
+2 -1
View File
@@ -142,7 +142,8 @@ static int dbgu_read(int minor)
*/
static ssize_t dbgu_write(int minor, const char *buf, size_t len)
{
int i, x;
int x;
size_t i;
char c;
console_tbl *console_entry;
at91rm9200_dbgu_regs_t *dbgu;
+1 -1
View File
@@ -163,7 +163,7 @@ static void usart_write_polled(int minor, char c)
static ssize_t usart_write_polled_support(int minor, const char *buf, size_t len)
{
at91rm9200_usart_regs_t *usart;
int nwrite=0;
size_t nwrite=0;
/*
* Verify the minor number
@@ -944,7 +944,11 @@ void SMARTCARD_EMVSIM_IRQHandler(EMVSIM_Type *base, smartcard_context_t *context
/* To fifo will be written 2 or more bytes */
size_t getu_tail = (size_t)(base->TX_GETU > 0u);
while (((context->txFifoEntryCount - (uint8_t)((base->TX_STATUS & EMVSIM_TX_STATUS_TX_CNT_MASK) >>
#ifdef __rtems__
EMVSIM_TX_STATUS_TX_CNT_SHIFT)) > 0) &&
#else
EMVSIM_TX_STATUS_TX_CNT_SHIFT)) > 0u) &&
#endif
(context->xSize > getu_tail))
{
/* Write data to fifo */
+7 -1
View File
@@ -99,9 +99,15 @@ static void imxrt_lpspi_find_clockdivs(
int best_sckdif;
int best_prescale;
#ifdef __rtems__
unsigned check_baud_hz;
unsigned check_sckdif;
unsigned check_prescale;
#else
int check_baud_hz;
int check_sckdif;
int check_prescale;
#endif
/* Start with slowest possible */
best_sckdif = max_sckdif;
@@ -425,7 +431,7 @@ static int imxrt_lpspi_check_howmany(
uint32_t max
)
{
int i;
uint32_t i;
if (max == 0) {
return max;
+2 -1
View File
@@ -87,7 +87,8 @@
#define OMAP3_INTR_ILR(base,m) \
(base + OMAP3_INTCPS_ILR0 + 0x4 * (m))
#define OMAP3_INTR_SPURIOUSIRQ_MASK (0x1FFFFFF << 7) /* Spurious IRQ mask for SIR_IRQ */
#define OMAP3_INTR_SPURIOUSIRQ_MASK \
(uint32_t) (0x1FFFFFF << 7) /* Spurious IRQ mask for SIR_IRQ */
#define OMAP3_INTR_ACTIVEIRQ_MASK 0x7F /* Active IRQ mask for SIR_IRQ */
#define OMAP3_INTR_NEWIRQAGR 0x1 /* New IRQ Generation */
+1 -1
View File
@@ -141,7 +141,7 @@ static ssize_t write_support_polled(
size_t n
)
{
ssize_t i = 0;
size_t i = 0;
for (i = 0; i < n; ++i) {
write_polled(minor, s [i]);
+1 -1
View File
@@ -526,7 +526,7 @@ rtems_status_code can_register_isr(
rtems_status_code create_can_message(
can_message *const msg,
const int _id,
const unsigned int _id,
const char *const _data,
const char _len
)
+1 -1
View File
@@ -169,7 +169,7 @@ rtems_status_code can_register_isr(
*/
rtems_status_code create_can_message(
can_message *const msg,
const int _id,
const unsigned int _id,
const char *const _data,
const char _len
);
+1 -1
View File
@@ -100,7 +100,7 @@ static void fbcons_write_support_polled(
size_t len
)
{
int nwrite = 0;
size_t nwrite = 0;
/*
* poll each byte in the string out of the port.
+1 -1
View File
@@ -211,7 +211,7 @@ int bcm2835_mailbox_get_pitch( bcm2835_get_pitch_entries *_entries )
int bcm2835_mailbox_get_cmdline( bcm2835_get_cmdline_entries *_entries )
{
int i;
uint32_t i;
struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
bcm2835_mbox_buf_hdr hdr;
@@ -125,8 +125,8 @@ static uint32_t set_translation_table_entries(
* Multiprocessing Extensions register format and the U (bit 30)
* is 0.
*/
#define MPIDR_MX_FMT (1 << 31)
#define MPIDR_UP (1 << 30)
#define MPIDR_MX_FMT (uint32_t)(1 << 31)
#define MPIDR_UP (uint32_t)(1 << 30)
const uint32_t mpidr = arm_cp15_get_multiprocessor_affinity();
if ((mpidr & (MPIDR_MX_FMT | MPIDR_UP)) == MPIDR_MX_FMT) {
arm_cp15_tlb_invalidate_entry_all_asids_inner_shareable(mva);
+1 -1
View File
@@ -179,7 +179,7 @@ static int uart_read(int minor)
*/
static ssize_t uart_write(int minor, const char *buf, size_t len)
{
int i;
size_t i;
if (minor == 0) {
for (i = 0; i < len; i++) {
+1 -1
View File
@@ -336,7 +336,7 @@ smc_read(rtems_blkdev_request *req)
sg = req->bufs;
for (i = 0; (remains > 0) && (i < req->bufnum); i++, sg++)
{
int count = sg->length;
uint32_t count = sg->length;
if (count > remains)
count = remains;
smc_read_page(sg->block,sg->buffer);
+1 -1
View File
@@ -249,7 +249,7 @@ static ssize_t usart_write_support_polled(
size_t n
)
{
ssize_t i = 0;
size_t i = 0;
for (i = 0; i < n; ++i) {
usart_write_polled(minor, s [i]);
+2 -2
View File
@@ -555,7 +555,7 @@ static int stm32h7_spi_transfer(
{
stm32h7_spi_context *ctx = RTEMS_CONTAINER_OF(base, stm32h7_spi_context, bus);
for (int i = 0; i < msg_count; i++) {
for (uint32_t i = 0; i < msg_count; i++) {
const spi_ioc_transfer *msg = &msgs[i];
if (stm32h7_spi_apply_premessage_settings(ctx, msg)) {
@@ -718,7 +718,7 @@ static int stm32h7_register_spi_device(
void stm32h7_register_spi_devices(void)
{
int i;
size_t i;
for (i = 0; i < (RTEMS_ARRAY_SIZE(stm32h7_spi_instances)); i++) {
if (stm32h7_spi_instances[i] == NULL) {