From patchwork Fri Sep 26 19:04:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 393929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E08171401EB for ; Sat, 27 Sep 2014 05:09:58 +1000 (EST) Received: from localhost ([::1]:51157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXatw-0001QV-F1 for incoming@patchwork.ozlabs.org; Fri, 26 Sep 2014 15:09:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXaoy-0001uH-Ls for qemu-devel@nongnu.org; Fri, 26 Sep 2014 15:04:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXaos-0004Hp-Bs for qemu-devel@nongnu.org; Fri, 26 Sep 2014 15:04:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48454) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXaos-0004GV-3R for qemu-devel@nongnu.org; Fri, 26 Sep 2014 15:04:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8QJ4VgE014765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Sep 2014 15:04:31 -0400 Received: from localhost (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8QJ4UQQ016757; Fri, 26 Sep 2014 15:04:31 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Fri, 26 Sep 2014 15:04:06 -0400 Message-Id: <1411758247-12161-9-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1411758247-12161-1-git-send-email-lcapitulino@redhat.com> References: <1411758247-12161-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 8/9] qemu-socket: Eliminate silly QERR_ macros 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 The QERR_ macros are leftovers from the days of "rich" error objects. They're used with error_set() and qerror_report(), and expand into the first *two* arguments. This trickiness has become pointless. Clean up. Signed-off-by: Markus Armbruster Reviewed-by: Paolo Bonzini Signed-off-by: Luiz Capitulino --- include/qapi/qmp/qerror.h | 12 ------------ util/qemu-sockets.c | 26 +++++++++++++------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index 774e75d..0ca6cbd 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -154,16 +154,4 @@ void qerror_report_err(Error *err); #define QERR_UNSUPPORTED \ ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported" -#define QERR_SOCKET_CONNECT_FAILED \ - ERROR_CLASS_GENERIC_ERROR, "Failed to connect socket" - -#define QERR_SOCKET_LISTEN_FAILED \ - ERROR_CLASS_GENERIC_ERROR, "Failed to listen on socket" - -#define QERR_SOCKET_BIND_FAILED \ - ERROR_CLASS_GENERIC_ERROR, "Failed to bind socket" - -#define QERR_SOCKET_CREATE_FAILED \ - ERROR_CLASS_GENERIC_ERROR, "Failed to create socket" - #endif /* QERROR_H */ diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 4a25585..1eef590 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -159,7 +159,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol); if (slisten < 0) { if (!e->ai_next) { - error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); + error_setg_errno(errp, errno, "Failed to create socket"); } continue; } @@ -183,7 +183,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) } if (p == port_max) { if (!e->ai_next) { - error_set_errno(errp, errno, QERR_SOCKET_BIND_FAILED); + error_setg_errno(errp, errno, "Failed to bind socket"); } } } @@ -194,7 +194,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) listen: if (listen(slisten,1) != 0) { - error_set_errno(errp, errno, QERR_SOCKET_LISTEN_FAILED); + error_setg_errno(errp, errno, "Failed to listen on socket"); closesocket(slisten); freeaddrinfo(res); return -1; @@ -281,7 +281,7 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress, sock = qemu_socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); if (sock < 0) { - error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); + error_setg_errno(errp, errno, "Failed to create socket"); return -1; } socket_set_fast_reuse(sock); @@ -302,7 +302,7 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress, connect_state); *in_progress = true; } else if (rc < 0) { - error_set_errno(errp, errno, QERR_SOCKET_CONNECT_FAILED); + error_setg_errno(errp, errno, "Failed to connect socket"); closesocket(sock); return -1; } @@ -466,20 +466,20 @@ int inet_dgram_opts(QemuOpts *opts, Error **errp) /* create socket */ sock = qemu_socket(peer->ai_family, peer->ai_socktype, peer->ai_protocol); if (sock < 0) { - error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); + error_setg_errno(errp, errno, "Failed to create socket"); goto err; } socket_set_fast_reuse(sock); /* bind socket */ if (bind(sock, local->ai_addr, local->ai_addrlen) < 0) { - error_set_errno(errp, errno, QERR_SOCKET_BIND_FAILED); + error_setg_errno(errp, errno, "Failed to bind socket"); goto err; } /* connect to peer */ if (connect(sock,peer->ai_addr,peer->ai_addrlen) < 0) { - error_set_errno(errp, errno, QERR_SOCKET_CONNECT_FAILED); + error_setg_errno(errp, errno, "Failed to connect socket"); goto err; } @@ -684,7 +684,7 @@ int unix_listen_opts(QemuOpts *opts, Error **errp) sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { - error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); + error_setg_errno(errp, errno, "Failed to create socket"); return -1; } @@ -709,11 +709,11 @@ int unix_listen_opts(QemuOpts *opts, Error **errp) unlink(un.sun_path); if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) { - error_set_errno(errp, errno, QERR_SOCKET_BIND_FAILED); + error_setg_errno(errp, errno, "Failed to bind socket"); goto err; } if (listen(sock, 1) < 0) { - error_set_errno(errp, errno, QERR_SOCKET_LISTEN_FAILED); + error_setg_errno(errp, errno, "Failed to listen on socket"); goto err; } @@ -739,7 +739,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp, sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { - error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); + error_setg_errno(errp, errno, "Failed to create socket"); return -1; } if (callback != NULL) { @@ -774,7 +774,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp, } if (rc < 0) { - error_set_errno(errp, -rc, QERR_SOCKET_CONNECT_FAILED); + error_setg_errno(errp, -rc, "Failed to connect socket"); close(sock); sock = -1; }