From nobody Thu May 2 08:45:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616171203; cv=none; d=zohomail.com; s=zohoarc; b=eBa0bpwDyZ+xhDbLWkax51HORaW7RNiXU/GXMMRGhMuesgIK8xil05z6YdPr+MKoWvL7DJ/dJyTuCu9FmuUA6g/Zdt/2fwcc0RpXbPrnfQLEuylc6tNXd6JehiVCxmUlaqWq1jcxO/XxfOHGqXGj/Ko3Vy1IdICvQYGQaSdz+Jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616171203; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=46+rU9C+OSw0mSDlPfwgjj1CCS1S9rOiTtSewLKL/ZM=; b=beWGOtSuP8sq+KpqUuVeGtjA0ueu1NZgrE8UeREkMtrWrnNJjie8/djx5czNyFybM6sENlDn01+UAmr2ERpQ0Y9G5fGTOm4/47x/QAcD27SF3h+DR1lYbgEgScfsOAPnB4LY9wdQrXOT9/LKpkPo6zq8GokF4hI+i+fY/1QMtPg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616171203107324.08636934087815; Fri, 19 Mar 2021 09:26:43 -0700 (PDT) Received: from localhost ([::1]:55564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNHxR-0001KO-Hl for importer@patchew.org; Fri, 19 Mar 2021 12:26:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNHvr-0008Rc-BL for qemu-devel@nongnu.org; Fri, 19 Mar 2021 12:25:03 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:42870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNHvp-0006mH-Mt for qemu-devel@nongnu.org; Fri, 19 Mar 2021 12:25:03 -0400 Received: by mail-wr1-x436.google.com with SMTP id x13so9705585wrs.9 for ; Fri, 19 Mar 2021 09:25:01 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id x13sm8354461wrt.75.2021.03.19.09.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 09:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=46+rU9C+OSw0mSDlPfwgjj1CCS1S9rOiTtSewLKL/ZM=; b=eqapNkgbCn36px2JZ2GbkTgpvKeQdkOabjjIggZyZlyeKbr+wGovELetJQ8B2C/Uea +bswXpAZ+5iJbZhV5f2NZOIpVWYUkDGw1OITLsuYvbnBZz1c5sR4t5Faca1ELvLIFvpy aicgZNVe63LuUeVu3H2CY65DkZhXwxcZbsOxznIYeMmEsq+YvvlDtOrFn2jiJC57R6Q9 /GQd2QbolCGdwPgVo5iDB7/eQ70TYOskNcDtMV+twbbWocS/jG2OWIjySd4AVyQbmOno aQkCY3MkCG1nckY0ot1H36kkgmQL4EvnKjEp6S5upflOtJrBtMT2XZri7iguo4DQHplp RNwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=46+rU9C+OSw0mSDlPfwgjj1CCS1S9rOiTtSewLKL/ZM=; b=IX6V40cfYg8rvtiHDjZjIIjm5k/QYHgYHtLl1XhvVHsQzw8bRcBeS2O/ce0ngm7zcX d0sfWu7TgFY1RjBQOTNdaxutDxOPiDxMDEUeGHLedrh50/QVjrQ6wa9VJoN5FQItsTA/ LtpyZ5SdyP+yH0zVR53LAWdeh2teTQoF+ePtkQ2r4i3yq0Ut4G9zlSAN88xA6xhMM9A9 k0xkRVB5A0Dp2q0dnpGfel+D5kAJF8cT30SztH6WWnnDy5jaoX2l9av6S6X1U206vNPF X1fA3Z/LNnnSNuYf+xnSCXoXHFnrlc9EpXHDUWu+/HfowMkAHu964UR43htXbUHBrMz1 iCIA== X-Gm-Message-State: AOAM533qUc/tgdqVZKS3nH+2/XzG0hDEdscuJ7KciIZBtjQ5fr7hhjtE GeChcQsCibAqJ2pfQfGbvFd32Kvimip4BKF1 X-Google-Smtp-Source: ABdhPJzKoKAr9NtZ4V26TLx+aeonkKi3Rr+RmATstK+fnRd7KsdA4dOZOJjzrQfhm/GRJr+B6IQC4Q== X-Received: by 2002:a5d:404f:: with SMTP id w15mr5630913wrp.106.1616171100029; Fri, 19 Mar 2021 09:25:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH for-6.0] hw/timer/renesas_tmr: Add default-case asserts in read_tcnt() Date: Fri, 19 Mar 2021 16:24:58 +0000 Message-Id: <20210319162458.13760-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yoshinori Sato Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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: Philippe Mathieu-Daud=C3=A9 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] =3D 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] =3D tmr->tcnt[0]; break; + default: + g_assert_not_reached(); } } else { tcnt[0] =3D tmr->tcnt[0]; --=20 2.20.1