From patchwork Mon Jan 14 19:55:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 211891 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 265992C0082 for ; Tue, 15 Jan 2013 07:38:00 +1100 (EST) Received: from localhost ([::1]:56647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuqDb-00037G-DN for incoming@patchwork.ozlabs.org; Mon, 14 Jan 2013 15:01:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuqCs-0001eR-2B for qemu-devel@nongnu.org; Mon, 14 Jan 2013 15:00:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TuqCq-0008SA-JJ for qemu-devel@nongnu.org; Mon, 14 Jan 2013 15:00:29 -0500 Received: from mail-ie0-f171.google.com ([209.85.223.171]:52290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuqCq-0008Rr-Fs for qemu-devel@nongnu.org; Mon, 14 Jan 2013 15:00:28 -0500 Received: by mail-ie0-f171.google.com with SMTP id 17so5721137iea.2 for ; Mon, 14 Jan 2013 12:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=Lg4zMsJqshNp45zs72G50MgtzfPABlyD7DtooiToRy4=; b=B+KX5EMqsFuznZnqYmffcmOFf6J4VTG0bkRz5bxxgLwXiVSO/Wk55P+8xvG/BknrMV pyhsCPQP9gbT+Y6lZsXpLtef7zWjmE1NVNVoxECxjEubRdCdazO89vLP4rLGBDMYyeGI 4ktmNBigRw2VLV+iOWLswyYVauoBNfLgr+9C5U17WxPO4y+PZV+4A2hppvIthje+0S6K S6OgtLCT7TEcFtLwbPdE1wlMA+yCLI71TQavNg6bR26yycroNcMWgQiVVCAAufDpsvnN T92lCQ2hrKd2HzHm4snJp3wPcPa6oomytEWxtUND4U0y7nXtwJifHqn4JKUQ082KWL9Z 3Oyg== X-Received: by 10.42.94.8 with SMTP id z8mr64650370icm.36.1358193628004; Mon, 14 Jan 2013 12:00:28 -0800 (PST) Received: from localhost ([32.97.110.59]) by mx.google.com with ESMTPS id as6sm121424igc.8.2013.01.14.12.00.26 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 14 Jan 2013 12:00:27 -0800 (PST) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 14 Jan 2013 13:55:12 -0600 Message-Id: <1358193312-15960-9-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1358193312-15960-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1358193312-15960-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.223.171 Cc: aliguori@us.ibm.com, armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 8/8] qemu-ga: Handle errors uniformely in ga_channel_open() 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 From: Markus Armbruster We detect errors in several places. One reports with g_error(), which calls abort(), the others report with g_critical(). Three of them exit(), three return false. Always report with g_critical(), and return false. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Michael Roth Reviewed-by: Luiz Capitulino *minor fix-up of commit msg Signed-off-by: Michael Roth --- qga/channel-posix.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 05e8386..e65dda3 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -141,14 +141,15 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethod ); if (fd == -1) { g_critical("error opening channel: %s", strerror(errno)); - exit(EXIT_FAILURE); + return false; } #ifdef CONFIG_SOLARIS ret = ioctl(fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI); if (ret == -1) { g_critical("error setting event mask for channel: %s", strerror(errno)); - exit(EXIT_FAILURE); + close(fd); + return false; } #endif ret = ga_channel_client_add(c, fd); @@ -164,7 +165,7 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethod int fd = qemu_open(path, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd == -1) { g_critical("error opening channel: %s", strerror(errno)); - exit(EXIT_FAILURE); + return false; } tcgetattr(fd, &tio); /* set up serial port for non-canonical, dumb byte streaming */ @@ -184,7 +185,9 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethod tcsetattr(fd, TCSANOW, &tio); ret = ga_channel_client_add(c, fd); if (ret) { - g_error("error adding channel to main loop"); + g_critical("error adding channel to main loop"); + close(fd); + return false; } break; }