From: David van Moolenbroek Date: Wed, 15 Aug 2012 11:12:11 +0000 (+0000) Subject: Kernel: resolve Coverity warnings X-Git-Tag: v3.2.1~369 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.dnssec-dsfromkey.html?a=commitdiff_plain;h=8e116b71a16ebc20d995e4186cb3f9c38d764210;p=minix.git Kernel: resolve Coverity warnings --- diff --git a/kernel/arch/i386/apic.c b/kernel/arch/i386/apic.c index ffbbdb98c..597650020 100644 --- a/kernel/arch/i386/apic.c +++ b/kernel/arch/i386/apic.c @@ -594,6 +594,7 @@ static u32_t lapic_errstatus(void) return lapic_read(LAPIC_ESR); } +#ifdef CONFIG_SMP static int lapic_disable_in_msr(void) { u32_t msr_hi, msr_lo; @@ -605,6 +606,7 @@ static int lapic_disable_in_msr(void) return 1; } +#endif /* CONFIG_SMP */ void lapic_disable(void) { @@ -626,6 +628,7 @@ void lapic_disable(void) return; } +#ifdef CONFIG_SMP val = lapic_read(LAPIC_LINT0) & 0xFFFE58FF; val |= APIC_ICR_INT_MASK; lapic_write (LAPIC_LINT0, val); @@ -639,6 +642,7 @@ void lapic_disable(void) lapic_write(LAPIC_SIVR, val); lapic_disable_in_msr(); +#endif /* CONFIG_SMP */ } static int lapic_enable_in_msr(void) diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 3e4b74347..27bbf43ca 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -213,7 +213,7 @@ static int lin_lin_copy(struct proc *srcproc, vir_bytes srclinaddr, static u32_t phys_get32(phys_bytes addr) { - const u32_t v; + u32_t v; int r; if((r=lin_lin_copy(NULL, addr, diff --git a/kernel/debug.c b/kernel/debug.c index 260b334aa..ad51a69c1 100644 --- a/kernel/debug.c +++ b/kernel/debug.c @@ -90,7 +90,6 @@ int runqueues_ok_cpu(unsigned cpu) } } - l = 0; for (xp = BEG_PROC_ADDR; xp < END_PROC_ADDR; ++xp) { if(!proc_ptr_ok(xp)) { printf("xp bogus pointer in proc table\n"); @@ -101,10 +100,6 @@ int runqueues_ok_cpu(unsigned cpu) if(proc_is_runnable(xp) && !xp->p_found) { printf("sched error: ready proc %d not on queue\n", xp->p_nr); return 0; - if (l++ > MAX_LOOP) { - printf("loop in debug.c?\n"); - return 0; - } } } @@ -145,7 +140,7 @@ rtsflagstr(const u32_t flags) static char str[100]; str[0] = '\0'; -#define FLAG(n) if(flags & n) { strcat(str, #n " "); } +#define FLAG(n) if(flags & n) { strlcat(str, #n " ", sizeof(str)); } FLAG(RTS_SLOT_FREE); FLAG(RTS_PROC_STOP); diff --git a/kernel/proc.c b/kernel/proc.c index 72a3d052c..c83954ab4 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -932,6 +932,7 @@ static int mini_receive(struct proc * caller_ptr, printf("mini_receive: sending notify from NONE\n"); } #endif + assert(src_proc_nr != NONE); unset_notify_pending(caller_ptr, src_id); /* no longer pending */ /* Found a suitable source, deliver the notification message. */ @@ -1250,8 +1251,6 @@ asyn_error: } return(OK); - - return r; } /*===========================================================================* diff --git a/kernel/system/do_sysctl.c b/kernel/system/do_sysctl.c index d4f258d10..5bc6b100a 100644 --- a/kernel/system/do_sysctl.c +++ b/kernel/system/do_sysctl.c @@ -46,9 +46,5 @@ int do_sysctl(struct proc * caller, message * m_ptr) printf("do_sysctl: invalid request %d\n", m_ptr->SYSCTL_CODE); return(EINVAL); } - - panic("do_sysctl: can't happen"); - - return(OK); }