Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 205CCC433EF for ; Fri, 29 Oct 2021 23:53: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 AC46860FE3 for ; Fri, 29 Oct 2021 23:52:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AC46860FE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=eik.bme.hu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgbgA-0004wF-N7 for qemu-devel@archiver.kernel.org; Fri, 29 Oct 2021 19:52:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgbTU-0000Jg-UB for qemu-devel@nongnu.org; Fri, 29 Oct 2021 19:39:52 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:39249) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgbTS-0002pp-1Y for qemu-devel@nongnu.org; Fri, 29 Oct 2021 19:39:52 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 46311748F4B; Sat, 30 Oct 2021 01:39:48 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 200B9746333; Sat, 30 Oct 2021 01:39:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 1E8267462D3; Sat, 30 Oct 2021 01:39:48 +0200 (CEST) Date: Sat, 30 Oct 2021 01:39:48 +0200 (CEST) From: BALATON Zoltan To: =?ISO-8859-15?Q?Philippe_Mathieu-Daud=E9?= Subject: Re: [PATCH v6 30/30] hw/timer/sh_timer: Remove use of hw_error In-Reply-To: <1c4ec639-c727-e750-6d13-3cfa7fbef6dd@amsat.org> Message-ID: <05dc851-13cf-4fa6-bb99-713bd87ebe82@eik.bme.hu> References: <1c4ec639-c727-e750-6d13-3cfa7fbef6dd@amsat.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3866299591-110878667-1635550788=:5796" Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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: Peter Maydell , Magnus Damm , Richard Henderson , qemu-devel@nongnu.org, Yoshinori Sato Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --3866299591-110878667-1635550788=:5796 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT On Sat, 30 Oct 2021, Philippe Mathieu-Daudé wrote: > On 10/29/21 23:02, BALATON Zoltan wrote: >> The hw_error function calls abort and is not meant to be used by >> devices. Use qemu_log_mask instead to log and ignore invalid accesses. >> Also fix format strings to allow dropping type casts of hwaddr and use >> __func__ instead of hard coding function name in the message which >> were wrong in two cases. >> >> Signed-off-by: BALATON Zoltan >> --- >> hw/timer/sh_timer.c | 40 +++++++++++++++++++++++++--------------- >> 1 file changed, 25 insertions(+), 15 deletions(-) >> >> diff --git a/hw/timer/sh_timer.c b/hw/timer/sh_timer.c >> index a6445092e4..8a586f2c4a 100644 >> --- a/hw/timer/sh_timer.c >> +++ b/hw/timer/sh_timer.c >> @@ -10,7 +10,7 @@ >> >> #include "qemu/osdep.h" >> #include "exec/memory.h" >> -#include "hw/hw.h" >> +#include "qemu/log.h" >> #include "hw/irq.h" >> #include "hw/sh4/sh.h" >> #include "hw/timer/tmu012.h" >> @@ -75,11 +75,10 @@ static uint32_t sh_timer_read(void *opaque, hwaddr offset) >> if (s->feat & TIMER_FEAT_CAPT) { >> return s->tcpr; >> } >> - /* fall through */ >> - default: >> - hw_error("sh_timer_read: Bad offset %x\n", (int)offset); >> - return 0; >> } >> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n", >> + __func__, offset); >> + return 0; > > Note, keeping the default case allow to refactor for single return, > so it is easier to add trace event. > > Anyhow, > Reviewed-by: Philippe Mathieu-Daudé It's easy enough to change back if adding a trace point in the future so for now I'd leave it at the end outside the if as in this patch. This could be revisited when QOM-ifying it in the future, don't think it's a big deal. Regards, BALATON Zoltan --3866299591-110878667-1635550788=:5796--