From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3A3k-00033x-M3 for qemu-devel@nongnu.org; Mon, 12 Sep 2011 13:12:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3A3j-0002oA-6F for qemu-devel@nongnu.org; Mon, 12 Sep 2011 13:12:40 -0400 Received: from am1ehsobe005.messaging.microsoft.com ([213.199.154.208]:31759 helo=AM1EHSOBE005.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3A3i-0002nT-Ty for qemu-devel@nongnu.org; Mon, 12 Sep 2011 13:12:39 -0400 Message-ID: <4E6E3D7E.5070608@freescale.com> Date: Mon, 12 Sep 2011 12:12:30 -0500 From: Scott Wood MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 7/9] openpic: avoid a warning from clang analyzer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Anthony Liguori , qemu-ppc@nongnu.org, qemu-devel , Alexander Graf On 09/04/2011 10:52 AM, Blue Swirl wrote: > Avoid this warning by clang analyzer by defining a default case: > /src/qemu/hw/openpic.c:477:5: warning: Undefined or garbage value > returned to caller > return retval; > > Signed-off-by: Blue Swirl > --- > hw/openpic.c | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/hw/openpic.c b/hw/openpic.c > index 26c96e2..4b883ac 100644 > --- a/hw/openpic.c > +++ b/hw/openpic.c > @@ -469,6 +469,7 @@ static inline uint32_t read_IRQreg (openpic_t > *opp, int n_IRQ, uint32_t reg) > case IRQ_IPVP: > retval = opp->src[n_IRQ].ipvp; > break; > + default: > case IRQ_IDE: > retval = opp->src[n_IRQ].ide; > break; What's special about IDE? Shouldn't it return 0xffffffff as some other functions (e.g. openpic_gbl_read) do with unrecognized registers? Then there's openpic_src_read() which has still different behavior for the same registers. :-P Note that this function is only ever called with a constant in "reg". Since it's a static function and all call sites could have been verified, this could be considered a flaw in clang's analyzer. This workaround will prevent GCC from issuing a warning if a new caller is added that passes a different constant value. The best answer is probably to just get rid of this function and have the caller refer to opp->src[n_irq].whatever directly. write_IRQreg() could be split into something like set_src_ipvp() and set_src_ide(). -Scott