From patchwork Tue May 15 09:39:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Chouteau X-Patchwork-Id: 159279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 15653B6FB7 for ; Tue, 15 May 2012 19:39:24 +1000 (EST) Received: from localhost ([::1]:49209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUEDx-0000HI-TY for incoming@patchwork.ozlabs.org; Tue, 15 May 2012 05:39:21 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUEDr-0000H7-Ou for qemu-devel@nongnu.org; Tue, 15 May 2012 05:39:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SUEDq-00086y-4d for qemu-devel@nongnu.org; Tue, 15 May 2012 05:39:15 -0400 Received: from mel.act-europe.fr ([194.98.77.210]:50533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUEDp-00086i-Up for qemu-devel@nongnu.org; Tue, 15 May 2012 05:39:14 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 67DF2290054; Tue, 15 May 2012 11:39:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at eu.adacore.com Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nbgsND7kCxo8; Tue, 15 May 2012 11:39:18 +0200 (CEST) Received: from PomPomGalli.act-europe.fr (pompomgalli.act-europe.fr [10.10.1.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 43633290048; Tue, 15 May 2012 11:39:18 +0200 (CEST) From: Fabien Chouteau To: qemu-devel@nongnu.org Date: Tue, 15 May 2012 11:39:09 +0200 Message-Id: <1337074749-24189-1-git-send-email-chouteau@adacore.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 194.98.77.210 Cc: peter.maydell@linaro.org, agraf@suse.de Subject: [Qemu-devel] [PATCH] Avoid segfault in cpu_dump_state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Do not call cpu_dump_state if logfile is NULL. Signed-off-by: Fabien Chouteau --- qemu-log.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qemu-log.h b/qemu-log.h index fccfb110..2cd5ffa 100644 --- a/qemu-log.h +++ b/qemu-log.h @@ -51,7 +51,12 @@ extern int loglevel; /* Special cases: */ /* cpu_dump_state() logging functions: */ -#define log_cpu_state(env, f) cpu_dump_state((env), logfile, fprintf, (f)); +#define log_cpu_state(env, f) \ +do { \ + if (logfile != NULL) { \ + cpu_dump_state((env), logfile, fprintf, (f)); \ + } \ + } while (0) #define log_cpu_state_mask(b, env, f) do { \ if (loglevel & (b)) log_cpu_state((env), (f)); \ } while (0)