sptests: Address -Wsign-compare warnings

Most of these warnings were between int or ssize_t and size_t.
In particular, various POSIX system calls like read() and write()
return ssize_t and comparing that value with the sizeof a buffer
is a common source of these warnings. Another common source is
using an int as the iterator in a for loop with the limit being
a size_t.

With the type change, some printf() specifiers needed to change also.
This commit is contained in:
Joel Sherrill
2026-01-22 23:19:32 +00:00
committed by Gedare Bloom
parent 38fa44e802
commit 3e0cf85d9c
14 changed files with 19 additions and 17 deletions
+2 -1
View File
@@ -48,7 +48,8 @@ void Fill_buffer(
)
{
char *p;
int i, j;
size_t i;
int j;
p = source;
for ( i = 0 ; i < MESSAGE_SIZE / sizeof(long) ; i++ ) {
+1 -1
View File
@@ -292,7 +292,7 @@ static void test_every_day(void)
for (every_day.year = 1988; every_day.year <= 2099; ++every_day.year) {
int leap_year = test_year_is_leap_year(every_day.year) ? 1 : 0;
for (every_day.month = 1; every_day.month <= 12; ++every_day.month) {
int days = days_per_month[leap_year][every_day.month - 1];
uint32_t days = days_per_month[leap_year][every_day.month - 1];
for (every_day.day = 1; every_day.day <= days; ++every_day.day) {
sc = rtems_clock_set(&every_day);
ASSERT_SC(sc);
+1 -1
View File
@@ -252,7 +252,7 @@ rtems_task Init (rtems_task_argument ignored)
__LINE__,
rtems_status_text (sc)
);
} else if (diff < (int) (2 * ticksPerSecond)) {
} else if (diff < (rtems_interval) (2 * ticksPerSecond)) {
printf(
"%d: Obtained obtain non-recursive-lock semaphore too quickly -- %"
PRIdrtems_interval " ticks not %" PRIdrtems_interval " ticks\n",
+1 -1
View File
@@ -66,7 +66,7 @@ static const rtems_task_priority Priorities_Low[MAX_TASKS] = {
12, 12, 12, 12, /* backward - multple on 2-n chain */
};
static const int Obtain_order[2][MAX_TASKS] = {
static const rtems_task_argument Obtain_order[2][MAX_TASKS] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 },
{ 4, 5, 6, 7, 9, 10, 11, 12, 13, 8, 16, 17, 18, 19, 0, 1, 2, 3, 15, 14 }
};
+2 -1
View File
@@ -111,7 +111,8 @@ void test_case_three(void)
#if 0
Heap_Resize_status hc;
#endif
int pg, al, alloc, sz;
size_t alloc;
int pg, al, sz;
puts( "Init - _Heap_Allocate_aligned - request impossible - not OK");
+1 -1
View File
@@ -50,7 +50,7 @@ rtems_task Init(
rtems_rate_monotonic_period_status period_status;
rtems_status_code status;
rtems_rate_monotonic_period_statistics statistics;
int i;
uint32_t i;
period_name = rtems_build_name('P','E','R','1');
+2 -2
View File
@@ -50,7 +50,7 @@ rtems_task Init(
rtems_status_code status;
rtems_id id;
long created;
size_t created;
TEST_BEGIN();
@@ -70,7 +70,7 @@ rtems_task Init(
} while (1);
printf(
"%ld ports created using %d per allocation -- need %ld\n",
"%zu ports created using %d per allocation -- need %ld\n",
created,
PER_ALLOCATION,
(long) OBJECTS_ID_FINAL_INDEX
@@ -36,7 +36,7 @@ rtems_task Tasks_Aperiodic(
)
{
rtems_status_code status;
int start, stop, now;
rtems_interval start, stop, now;
put_name( Task_name[ argument ], FALSE );
@@ -59,7 +59,7 @@ rtems_task Tasks_Periodic(
rtems_status_code status;
bool scenario_done = 0;
int start, stop, now;
rtems_interval start, stop, now;
rtems_cbs_server_id server_id, tsid;
rtems_cbs_parameters params, tparams;
+1 -1
View File
@@ -309,7 +309,7 @@ static rtems_task Init(rtems_task_argument ignored)
(void) ignored;
// rtems_status_code status;
int i;
size_t i;
TEST_BEGIN();
@@ -42,9 +42,9 @@ rtems_task Tasks_Aperiodic(
)
{
rtems_status_code status;
int start;
int stop;
int now;
rtems_interval start;
rtems_interval stop;
rtems_interval now;
put_name( Task_name[ argument ], FALSE );
@@ -51,7 +51,7 @@ rtems_task Tasks_Periodic(
rtems_task_priority prio_cur;
rtems_task_priority prio_max;
int start, stop, now;
rtems_interval start, stop, now;
status = rtems_rate_monotonic_create( argument, &rmid );
directive_failed( status, "rtems_rate_monotonic_create" );
+1 -1
View File
@@ -200,7 +200,7 @@ static void test_posix_init(test_context *ctx)
attr.mq_msgsize = sizeof(char);
ctx->pmq = mq_open("mq", O_CREAT | O_RDWR, 0x777, &attr);
rtems_test_assert(ctx->mq != -1);
rtems_test_assert(ctx->pmq != (mqd_t) -1);
}
static void test_context_init(test_context *ctx)
+1 -1
View File
@@ -48,7 +48,7 @@ static volatile uint32_t read_write_small = 0xdeadbeefUL;
static const volatile uint32_t read_only_small = 0x601dc0feUL;
static void check_tls_item(uint32_t expected)
static void check_tls_item(char expected)
{
printk("TLS item = %i\n", tls_item);
rtems_test_assert(tls_item == expected);