From patchwork Tue May 30 08:23:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Privoznik X-Patchwork-Id: 9754085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E8D0602B9 for ; Tue, 30 May 2017 08:44:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FE6D1FE82 for ; Tue, 30 May 2017 08:44:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4234127F7F; Tue, 30 May 2017 08:44:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A6F7E1FE82 for ; Tue, 30 May 2017 08:44:19 +0000 (UTC) Received: from localhost ([::1]:52266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFclG-0006Id-Jf for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 May 2017 04:44:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFcRK-0006VB-6K for qemu-devel@nongnu.org; Tue, 30 May 2017 04:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFcRH-0001Oy-V1 for qemu-devel@nongnu.org; Tue, 30 May 2017 04:23:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8753) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFcRH-0001Nn-PU for qemu-devel@nongnu.org; Tue, 30 May 2017 04:23:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1DFAC83E for ; Tue, 30 May 2017 08:23:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D1DFAC83E Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mprivozn@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D1DFAC83E Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5702317151 for ; Tue, 30 May 2017 08:23:38 +0000 (UTC) From: Michal Privoznik To: qemu-devel@nongnu.org Date: Tue, 30 May 2017 10:23:34 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 May 2017 08:23:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] qemu-bridge-helper: Reverse return value setting logic in parse_acl_file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Just like in the previous commit, it's better to have just a single point of exit from a function as we can have cleanup code just once instead of copying it all over the place. Signed-off-by: Michal Privoznik --- qemu-bridge-helper.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c index af6613ea18..a7f9bf06cc 100644 --- a/qemu-bridge-helper.c +++ b/qemu-bridge-helper.c @@ -65,6 +65,7 @@ static int parse_acl_file(const char *filename, ACLList *acl_list) FILE *f; char line[4096]; ACLRule *acl_rule; + int ret = -1; f = fopen(filename, "r"); if (f == NULL) { @@ -92,9 +93,8 @@ static int parse_acl_file(const char *filename, ACLList *acl_list) if (arg == NULL) { fprintf(stderr, "Invalid config line:\n %s\n", line); - fclose(f); errno = EINVAL; - return -1; + goto cleanup; } *arg = 0; @@ -132,15 +132,16 @@ static int parse_acl_file(const char *filename, ACLList *acl_list) parse_acl_file(arg, acl_list); } else { fprintf(stderr, "Unknown command `%s'\n", cmd); - fclose(f); errno = EINVAL; - return -1; + goto cleanup; } } - fclose(f); + ret = 0; - return 0; + cleanup: + fclose(f); + return ret; } static bool has_vnet_hdr(int fd)