bsps/powerpc: 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 23:17:46 +00:00
committed by Gedare Bloom
parent 59ef829a34
commit 9c7666ba2d
37 changed files with 68 additions and 50 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ struct bankdesc *b;
return 0;
}
/* bank is unsigned and cannot be < 0 */
if ( bank >= b->size ) {
if ( (uint32_t)bank >= b->size ) {
if ( !quiet )
fprintf(stderr,"Invalid flash bank #: %i; (too big)\n", bank);
return 0;
+1 -1
View File
@@ -514,7 +514,7 @@ unsigned i,j;
int
BSP_setup_the_pic(rtems_irq_global_settings* config)
{
int i;
unsigned int i;
/*
* Store copy of configuration
*/
+1 -1
View File
@@ -276,7 +276,7 @@ static uint32_t rd_wdcnf(void)
* status locally (and hope we get the initial
* value right).
*/
if ( ~0 == cnf )
if ( ~0u == cnf )
cnf = wdog_on;
return cnf;
}
+1 -1
View File
@@ -60,7 +60,7 @@ unsigned BSP_pci_hose1_bus_base = (unsigned)-1;
#define MV64x60_PCI1_CONFIG_ADDR (BSP_MV64x60_BASE + 0xc78)
#define MV64x60_PCI1_CONFIG_DATA (BSP_MV64x60_BASE + 0xc7c)
#define PCI_BUS2HOSE(bus) (bus<BSP_pci_hose1_bus_base?0:1)
#define PCI_BUS2HOSE(bus) ((unsigned int)bus<BSP_pci_hose1_bus_base?0:1)
void detect_host_bridge(void)
{
@@ -47,7 +47,8 @@ void TaskSetup_BDTable(volatile uint32 *BasePtr, volatile uint32 *LastPtr, volat
int TaskNum, uint32 NumBD, uint16 MaxBD,
uint8 NumPtr, ApiConfig_t ApiConfig, uint32 Status)
{
int i, j;
uint16_t i;
int j;
uint32 *ptr;
/*
+1 -1
View File
@@ -531,7 +531,7 @@ static ssize_t mpc5200_uart_write(
/*
* Check tx fifo space
*/
if(len > (TX_FIFO_SIZE - psc->tfnum))
if(len > (size_t)(TX_FIFO_SIZE - psc->tfnum))
frame_len = TX_FIFO_SIZE - psc->tfnum;
#ifndef SINGLE_CHAR_MODE
+1 -1
View File
@@ -511,7 +511,7 @@ mpc5200mbus_poll(mpc5200mbus *bus)
rtems_status_code
mpc5200mbus_select_clock_divider(mpc5200mbus *bus, int divider)
{
int i;
size_t i;
int mbc;
struct {
int divider;
+1 -1
View File
@@ -70,7 +70,7 @@ mpc5200_pcf8563_probe(int minor)
i2c_bus_number bus;
i2c_address addr;
if (minor >= NUM_RTCS)
if ((size_t)minor >= NUM_RTCS)
return false;
rtc = RTC_Table + minor;
+1 -1
View File
@@ -82,7 +82,7 @@ static rtems_status_code mpc83xx_i2c_find_clock_divider
| o = ok or error code |
\*=========================================================================*/
{
int i;
size_t i;
int fdr_val;
rtems_status_code sc = RTEMS_SUCCESSFUL;
struct {
+1 -1
View File
@@ -37,7 +37,7 @@ int BSP_uart_set_break_cb(int uart, rtems_libio_ioctl_args_t *arg);
extern unsigned BSP_poll_char_via_serial(void);
extern void BSP_output_char_via_serial(const char val);
extern int BSPConsolePort;
extern rtems_device_minor_number BSPConsolePort;
extern int BSPBaseBaud;
/* Special IOCTLS to install a lowlevel 'BREAK' handler */
@@ -385,7 +385,7 @@ unsigned int accent_table_size = 68;
typedef struct _console_log {
struct _console_log *next;
int offset;
size_t offset;
u_char data[PAGE_LOG_CHARS];
} console_log;
@@ -65,7 +65,7 @@ PPC_DEVICE *residual_find_device(RESIDUAL *res,unsigned long BusMask,
int Interface,
int n)
{
int i;
unsigned long i;
if ( !res || !res->ResidualLength ) return NULL;
for (i=0; i<res->ActualNumDevices; i++) {
#define Dev res->Devices[i].DeviceId
+1 -1
View File
@@ -94,7 +94,7 @@ m8xx_get_brg(unsigned brgmask, int baud)
/* first try to find a BRG that is already at the right speed */
for ( i = 0; i < NUM_BRGS; i++ ) {
if ( (1 << i) & brgmask ) /* is this brg allowed? */
if ( brg_spd[i] == baud ) {
if ( brg_spd[i] == (unsigned long)baud ) {
break;
}
}
+3 -2
View File
@@ -394,6 +394,7 @@ uint8_t buf[2];
int l = 0;
uint8_t read_mask = rw ? 1 : 0;
rtems_status_code sc;
int xfer;
/* Make sure we are started; (i2c_start() didn't bother to wait
* so we do it here - some time already has expired.
@@ -423,8 +424,8 @@ rtems_status_code sc;
* the second byte]) to overcome the pipeline
* delay in the hardware (I don't like this design) :-(.
*/
sc = i2c_xfer( 0, buf, l );
if ( rw && l == sc ) {
xfer = i2c_xfer( 0, buf, l );
if ( rw && l == xfer ) {
sc = i2c_xfer( 1, buf, 1 );
}
return sc >=0 ? RTEMS_SUCCESSFUL : -sc;
+2 -2
View File
@@ -211,7 +211,7 @@ static void bsp_early( void )
{
unsigned char *stack;
char *chpt;
int i;
size_t i;
ppc_cpu_id_t myCpu;
ppc_cpu_revision_t myCpuRevision;
E500_tlb_va_cache_t *tlb;
@@ -293,7 +293,7 @@ VpdBufRec vpdData [] = {
*/
if ( tlb->att.v
&& 0xa != (tlb->att.wimge & 0xa)
&& (tlb->va.va_epn<<12) >= BSP_mem_size ) {
&& ((unsigned int)tlb->va.va_epn<<12) >= BSP_mem_size ) {
rtems_e500_clrtlb( E500_SELTLB_1 | i );
}
}
+1 -1
View File
@@ -359,7 +359,7 @@ static void TEXT add_pcie_regions(qoriq_mmu_context *context, const void *fdt)
continue;
}
while (len >= range_length) {
while ((size_t)len >= range_length) {
uint32_t pci_addr_flags;
uintptr_t pci_addr;
uintptr_t cpu_addr;
+3 -2
View File
@@ -45,7 +45,7 @@
* BSP_UART_COM1
* BSP_UART_COM2
*/
int BSPConsolePort = BSP_CONSOLE_PORT;
rtems_device_minor_number BSPConsolePort = BSP_CONSOLE_PORT;
int BSPBaseBaud = BSP_UART_BAUD_BASE;
@@ -159,7 +159,8 @@ static int console_first_open(int major, int minor, void *arg)
rtems_status_code status;
/* must not open a minor device we have no ISR for */
assert( minor>=0 && minor < sizeof(ttyS)/sizeof(ttyS[0]) && ttyS[minor].isr );
assert( minor>=0 && (size_t) minor < sizeof(ttyS)/sizeof(ttyS[0]) &&
ttyS[minor].isr );
/* BSP_CONSOLE_BAUD-8-N-1 */
BSP_uart_init(minor, BSP_CONSOLE_BAUD, 0);
+4 -4
View File
@@ -549,7 +549,7 @@ ssize_t
BSP_uart_termios_write_polled(int minor, const char *buf, size_t len)
{
int uart=minor; /* could differ, theoretically */
int nwrite;
size_t nwrite;
const char *b = buf;
for (nwrite=0 ; nwrite < len ; nwrite++) {
@@ -616,7 +616,7 @@ BSP_uart_termios_read_com(int uart)
rtems_interrupt_level l;
/* read bytes */
while (( off < sizeof(buf) ) && ( uread(uart, LSR) & DR )) {
while (( (size_t)off < sizeof(buf) ) && ( uread(uart, LSR) & DR )) {
buf[off++] = uread(uart, RBR);
}
@@ -725,8 +725,8 @@ BSP_uart_termios_isr_com(int uart)
else
{
/* RX data ready */
assert(off < sizeof(buf));
while ( off < sizeof(buf) && ( DR & uread(uart, LSR) ) )
assert((size_t)off < sizeof(buf));
while ( (size_t)off < sizeof(buf) && ( DR & uread(uart, LSR) ) )
buf[off++] = uread(uart, RBR);
}
break;
+1 -1
View File
@@ -98,7 +98,7 @@ ppc_cpu_id_t get_ppc_cpu_type(void)
};
unsigned int pvr;
int i;
size_t i;
if ( PPC_UNKNOWN != current_ppc_cpu )
return current_ppc_cpu;
+1 -1
View File
@@ -397,7 +397,7 @@ struct devdesc *dd;
STATIC uint32_t
BSP_flashProbeSize(struct bankdesc *b)
{
int max = b->max_size;
uint32_t max = b->max_size;
uint32_t rval;
struct devdesc *dd;
unsigned q;
+1 -1
View File
@@ -328,7 +328,7 @@ STATIC int
flash_erase_block_intel(struct bankdesc *b, uint32_t addr)
{
uint32_t sta;
int i;
size_t i;
rtems_interval p;
if ( (sta = flash_check_ready_intel(b, addr)) )
+1 -1
View File
@@ -248,7 +248,7 @@ void openpic_init(int main_pic, unsigned char *polarities, unsigned char *senses
/* Override if they desire */
if ( num_sources ) {
if ( NumSources != num_sources )
if ( NumSources != (unsigned int)num_sources )
printk("Overriding NumSources (%i) from configuration with %i\n",
NumSources, num_sources);
NumSources = num_sources;
+1 -1
View File
@@ -344,7 +344,7 @@ int C_dispatch_irq_handler (BSP_Exception_frame *frame, unsigned int excNum)
* it can re-enable the openpic while handling
* VME interrupts (-> VME priorities in software)
*/
if (_BSP_vme_bridge_irq != irq && OpenPIC)
if (_BSP_vme_bridge_irq != (int)irq && OpenPIC)
#endif
openpic_eoi(0);
#else
+2 -2
View File
@@ -87,7 +87,7 @@ static int C_dispatch_dec_handler_bookE (BSP_Exception_frame *frame, unsigned in
* is valid.
*/
static int isValidInterrupt(int irq)
static int isValidInterrupt(unsigned int irq)
{
if ( (irq < internal_config->irqBase) || (irq >= internal_config->irqBase + internal_config->irqNb))
return 0;
@@ -347,7 +347,7 @@ int BSP_rtems_int_disconnect(rtems_irq_number n, rtems_irq_hdl hdl, rtems_irq_hd
int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config)
{
int i;
size_t i;
rtems_interrupt_level level;
rtems_irq_connect_data* vchain;
+2 -2
View File
@@ -289,7 +289,7 @@ check_bat_size (unsigned long size)
} else {
__asm__ volatile (" cntlzw %0, %1":"=r" (bit):"r" (size));
bit = 31 - bit;
if (1 << bit != size)
if (1u << bit != size)
return -1;
}
/* bit < 17 is not really legal but we aliased it to 0 in the past */
@@ -309,7 +309,7 @@ check_bat_size (unsigned long size)
static int
check_overlap (int typ, unsigned long start, unsigned long size)
{
int i;
size_t i;
unsigned long limit = start + size - 1;
for (i = 0; i < sizeof (bat_addrs[typ]) / sizeof (bat_addrs[typ][0]); i++) {
if (!((1 << i) & bat_in_use[typ]))
+1 -1
View File
@@ -365,7 +365,7 @@ rtems_interrupt_level lvl;
/* Assume they literally specify a size */
msk = sz;
sz = 0;
while ( msk != (1024<<(2*sz)) ) {
while ( msk != (1024u<<(2u*sz)) ) {
if ( ++sz > 15 ) {
return -1;
}
+3 -2
View File
@@ -393,7 +393,7 @@ triv121PgTblLdMinSize (unsigned long size)
size >>= LD_PG_SIZE - LD_PTE_SIZE;
/* find the next power of 2 >= size */
for (i = 0; i < LD_PHYS_SIZE; i++) {
if ((1 << i) >= size)
if ((1u << i) >= size)
break;
}
/* pop up to the allowed minimum, if necessary */
@@ -481,7 +481,8 @@ triv121PgTblMap (Triv121PgTbl pt,
unsigned long numPages,
unsigned attributes, unsigned protection)
{
int i, pass;
size_t i;
int pass;
unsigned long pi;
APte pte;
long vsid;
+2 -2
View File
@@ -103,7 +103,7 @@ unsigned ldPtSize,tmp;
(PAGE_ALIGN((unsigned long)_etext) - 0) >> PG_SHIFT,
0, /* WIMG */
TRIV121_PP_RO_PAGE);
if (TRIV121_MAP_SUCCESS != tmp) {
if ((unsigned int)TRIV121_MAP_SUCCESS != tmp) {
printk("Unable to map page index %i; reverting to BAT0\n",
tmp);
pt = 0;
@@ -116,7 +116,7 @@ unsigned ldPtSize,tmp;
(*pmemsize - (1<<ldPtSize) - (unsigned long)__DATA_START__ )>> PG_SHIFT,
0, /* WIMG */
TRIV121_PP_RW_PAGE);
if (TRIV121_MAP_SUCCESS != tmp) {
if ((unsigned int)TRIV121_MAP_SUCCESS != tmp) {
printk("Unable to map page index %i; reverting to BAT0\n",
tmp);
pt = 0;
+3 -1
View File
@@ -146,7 +146,9 @@ void *sbrk(ptrdiff_t incr)
{
void *rval=(void*)-1;
if ( remaining_start != INVALID_REMAINING_START && incr <= remaining_size) {
if ( remaining_start != INVALID_REMAINING_START &&
(uintptr_t)incr <= remaining_size) {
remaining_size-=incr;
rval = (void *) remaining_start;
remaining_start += incr;
+3 -2
View File
@@ -130,7 +130,8 @@ BSP_vpdRetrieveFields(VpdBuf data)
{
VpdBuf b, b1;
VpdKey k;
int l,fd = -1, put, got;
size_t l;
int fd = -1, put, got;
int rval = -1;
unsigned char mot[9];
static int (*stop)(int fd);
@@ -188,7 +189,7 @@ static int (*stop)(int fd);
/* found 'instance' of field 'type' */
/* limit to buffer size */
put = b->buflen > l ? l : b->buflen;
put = (size_t)b->buflen > l ? l : (size_t)b->buflen;
if ( read_buf(fd, b->buf, put) < put )
goto bail;
+6 -3
View File
@@ -820,7 +820,7 @@ configTsiPort(
unsigned long long start, limit, offst;
unsigned long mode, mask, tat_reg, tsau_reg;
char *name = (isout ? "Outbound" : "Inbound");
int i,s,l;
unsigned long i,s,l;
CHECK_BASE(base,0,-1);
@@ -831,7 +831,7 @@ int i,s,l;
return -1;
}
if ( base == THEBASE && isout && vmeTsi148RegPort == port ) {
if ( base == THEBASE && isout && (unsigned long)vmeTsi148RegPort == port ) {
uprintf(stderr,"Tsi148 %s Port Cfg: invalid port; reserved by the interrupt manager for CRG\n", name);
return -1;
}
@@ -2102,7 +2102,10 @@ bail:
if ( q )
rtems_message_queue_delete(q);
return sc ? sc : err;
if ( sc ) {
return sc;
}
return err;
}
unsigned long
+4 -1
View File
@@ -2518,7 +2518,10 @@ bail:
if ( q )
rtems_message_queue_delete(q);
return sc ? sc : err;
if ( sc ) {
return sc;
}
return err;
}
#endif
+1 -1
View File
@@ -105,7 +105,7 @@ static int except_always_enabled(const rtems_raw_except_connect_data* ptr)
void initialize_exceptions(void)
{
int i;
size_t i;
/*
* Initialize all entries of the exception table with a description of the
+2 -1
View File
@@ -889,7 +889,8 @@ rtems_device_driver console_initialize(rtems_device_major_number major,
(void) arg;
rtems_status_code status = RTEMS_SUCCESSFUL;
int entry,ttynum;
size_t entry;
int ttynum;
char tty_name[] = "/dev/tty00";
/*
+4 -1
View File
@@ -488,7 +488,10 @@ static int m8xx_spi_read_write_bytes
#if defined(DEBUG)
printk("... exit OK, rc=%d\r\n",bc);
#endif
return (rc == RTEMS_SUCCESSFUL) ? bc : -rc;
if (rc == RTEMS_SUCCESSFUL) {
return bc;
}
return -rc;
}
/*=========================================================================*\
+2 -1
View File
@@ -38,7 +38,8 @@
*/
void mmu_init( void )
{
register uint32_t reg1, i;
register uint32_t reg1;
int i;
/*
* Initialize the TLBs
+1 -1
View File
@@ -354,7 +354,7 @@ bsp_mmu_write(bsp_tlb_idx_t idx, uint32_t ea, uint32_t pa, int sz,
/* Assume they literally specify a size */
msk = sz;
sz = 0;
while ( msk != (1024<<(sz+sz)) ) {
while ( msk != (1024u<<(sz+sz)) ) {
if ( ++sz > 15 ) {
return -1;
}