From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B0D5C433B4 for ; Thu, 1 Apr 2021 16:03:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD37F61221 for ; Thu, 1 Apr 2021 16:02:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD37F61221 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=users.sourceforge.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRzmc-0003dH-Pl for qemu-devel@archiver.kernel.org; Thu, 01 Apr 2021 12:02:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRziF-0000zZ-5u for qemu-devel@nongnu.org; Thu, 01 Apr 2021 11:58:27 -0400 Received: from mail02.asahi-net.or.jp ([202.224.55.14]:42786) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRziD-0003Ld-6S for qemu-devel@nongnu.org; Thu, 01 Apr 2021 11:58:26 -0400 Received: from sakura.ysato.name (ik1-413-38519.vs.sakura.ne.jp [153.127.30.23]) (Authenticated sender: PQ4Y-STU) by mail02.asahi-net.or.jp (Postfix) with ESMTPA id BE2FD7B710; Fri, 2 Apr 2021 00:58:20 +0900 (JST) Received: from localhost.ysato.ml (ZM005235.ppp.dion.ne.jp [222.8.5.235]) by sakura.ysato.name (Postfix) with ESMTPSA id 16AA21C03C0; Fri, 2 Apr 2021 00:58:20 +0900 (JST) Date: Fri, 02 Apr 2021 00:58:16 +0900 Message-ID: From: Yoshinori Sato To: Peter Maydell Subject: Re: [PATCH for-6.0] hw/timer/renesas_tmr: Add default-case asserts in read_tcnt() In-Reply-To: <20210319162458.13760-1-peter.maydell@linaro.org> References: <20210319162458.13760-1-peter.maydell@linaro.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (arm-unknown-linux-androideabi) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Received-SPF: softfail client-ip=202.224.55.14; envelope-from=ysato@users.sourceforge.jp; helo=mail02.asahi-net.or.jp X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Magnus Damm , qemu-devel@nongnu.org, Philippe =?ISO-8859-1?Q?Mathieu-Daud=E9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Sat, 20 Mar 2021 01:24:58 +0900, Peter Maydell wrote: > > In commit 81b3ddaf8772ec we fixed a use of uninitialized data > in read_tcnt(). However this change wasn't enough to placate > Coverity, which is not smart enough to see that if we read a > 2 bit field and then handle cases 0, 1, 2 and 3 then there cannot > be a flow of execution through the switch default. Add explicit > default cases which assert that they can't be reached, which > should help silence Coverity. > > Signed-off-by: Peter Maydell Reviewed-by: Yoshinori Sato > --- > hw/timer/renesas_tmr.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/hw/timer/renesas_tmr.c b/hw/timer/renesas_tmr.c > index eed39917fec..d96002e1ee6 100644 > --- a/hw/timer/renesas_tmr.c > +++ b/hw/timer/renesas_tmr.c > @@ -146,6 +146,8 @@ static uint16_t read_tcnt(RTMRState *tmr, unsigned size, int ch) > case CSS_CASCADING: > tcnt[1] = tmr->tcnt[1]; > break; > + default: > + g_assert_not_reached(); > } > switch (FIELD_EX8(tmr->tccr[0], TCCR, CSS)) { > case CSS_INTERNAL: > @@ -159,6 +161,8 @@ static uint16_t read_tcnt(RTMRState *tmr, unsigned size, int ch) > case CSS_EXTERNAL: /* QEMU doesn't implement this */ > tcnt[0] = tmr->tcnt[0]; > break; > + default: > + g_assert_not_reached(); > } > } else { > tcnt[0] = tmr->tcnt[0]; > -- > 2.20.1 > I'm back. --- Yoshinori Sato