From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUKsQ-0003vx-4n for qemu-devel@nongnu.org; Tue, 15 May 2012 12:45:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SUKsI-0004QB-MK for qemu-devel@nongnu.org; Tue, 15 May 2012 12:45:33 -0400 Received: from mel.act-europe.fr ([194.98.77.210]:36949) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUKsI-0004Pj-GI for qemu-devel@nongnu.org; Tue, 15 May 2012 12:45:26 -0400 Message-ID: <4FB28823.8050908@adacore.com> Date: Tue, 15 May 2012 18:45:23 +0200 From: Fabien Chouteau MIME-Version: 1.0 References: <1337074749-24189-1-git-send-email-chouteau@adacore.com> <4FB25AA9.3010905@suse.de> <4FB27F60.7090304@adacore.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] Avoid segfault in cpu_dump_state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, agraf@suse.de, =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= On 05/15/2012 06:20 PM, Peter Maydell wrote: > On 15 May 2012 17:08, Fabien Chouteau wrote: >> On 05/15/2012 03:31 PM, Andreas F=C3=A4rber wrote: >>> Am 15.05.2012 11:39, schrieb Fabien Chouteau: >>>> Do not call cpu_dump_state if logfile is NULL. >>> >>> And where is log_cpu_state() being called from? Its caller is passing >>> NULL already then. >=20 >> No, logfile is a global variable. log_cpu_state() takes only CPUState >> and flags parameters. >=20 > The question is which of the following two options we want: > (1) callers should be guarding the calls to log_cpu_state() with > checks for qemu_log_enabled() or qemu_loglevel_mask() > (2) log_cpu_state() does its own check for whether logging is enabled > in the same way that qemu_log() and qemu_log_vprintf() do >=20 > At the moment most callers of log_cpu_state() do their own checks > as per (1), but you could make an argument that we should switch > to (2) instead. >=20 I think (2) is better, we do the check in one place and that's it. All call to log_cpu_state are safe. And as you said, it's already the way qemu_log and qemu_log_vprintf work. --=20 Fabien Chouteau