From ebc85e54c4d88fc67bd29fc1ce322c229f7cdae8 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Tue, 7 Aug 2012 13:10:16 +0200 Subject: [PATCH] libsys: resolve Coverity warnings --- lib/libsys/getidle.c | 2 -- lib/libsys/profile.c | 2 +- lib/libsys/sched_start.c | 1 - lib/libsys/sef.c | 7 ++++--- lib/libsys/ser_putc.c | 3 ++- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/libsys/getidle.c b/lib/libsys/getidle.c index af37d7b0d..989eac53a 100644 --- a/lib/libsys/getidle.c +++ b/lib/libsys/getidle.c @@ -84,6 +84,4 @@ double getidle(void) return rfp; } - - running = !running; } diff --git a/lib/libsys/profile.c b/lib/libsys/profile.c index 86032a9be..3acbbc8a7 100644 --- a/lib/libsys/profile.c +++ b/lib/libsys/profile.c @@ -146,7 +146,7 @@ void procentry (char *name) } /* Set values for new slot. */ cprof_slot = &cprof_tbl[control.slots_used++]; - strcpy(cprof_slot->cpath, cpath); + strlcpy(cprof_slot->cpath, cpath, sizeof(cprof_slot->cpath)); cprof_slot->calls = 1; /* Update index. */ diff --git a/lib/libsys/sched_start.c b/lib/libsys/sched_start.c index 2b49fc95f..ce0122670 100644 --- a/lib/libsys/sched_start.c +++ b/lib/libsys/sched_start.c @@ -21,7 +21,6 @@ int sched_inherit(endpoint_t scheduler_e, assert(_ENDPOINT_P(scheduler_e) >= 0); assert(_ENDPOINT_P(schedulee_e) >= 0); assert(_ENDPOINT_P(parent_e) >= 0); - assert(maxprio >= 0); assert(maxprio < NR_SCHED_QUEUES); assert(newscheduler_e); diff --git a/lib/libsys/sef.c b/lib/libsys/sef.c index c625ce1b7..e964fa70b 100644 --- a/lib/libsys/sef.c +++ b/lib/libsys/sef.c @@ -58,7 +58,7 @@ void sef_startup() &priv_flags); if ( r != OK) { sef_self_endpoint = SELF; - sprintf(sef_self_name, "%s", "Unknown"); + strlcpy(sef_self_name, "Unknown", sizeof(sef_self_name)); } sef_self_priv_flags = priv_flags; old_endpoint = NONE; @@ -302,8 +302,9 @@ char* sef_debug_header(void) { /* Build and return a SEF debug header. */ sef_debug_refresh_params(); - sprintf(sef_debug_header_buff, "%s: time = %ds %06dus", - sef_self_name, (int) sef_debug_time_sec, (int) sef_debug_time_us); + snprintf(sef_debug_header_buff, sizeof(sef_debug_header_buff), + "%s: time = %ds %06dus", sef_self_name, (int) sef_debug_time_sec, + (int) sef_debug_time_us); return sef_debug_header_buff; } diff --git a/lib/libsys/ser_putc.c b/lib/libsys/ser_putc.c index 133b713c1..87b12e858 100644 --- a/lib/libsys/ser_putc.c +++ b/lib/libsys/ser_putc.c @@ -18,7 +18,8 @@ void ser_putc(char c) thr= COM1_THR; for (i= 0; i<10000; i++) { - sys_inb(lsr, &b); + if (sys_inb(lsr, &b) != OK) + return; if (b & LSR_THRE) break; } -- 2.44.0