diff mbox

[1/9] qerror: rename QERR_SOCKET_* macros

Message ID 1342633760-351-2-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino July 18, 2012, 5:49 p.m. UTC
The socket error classes call a socket 'Sock', like in SockConnectFailed,
but the error macros call a socket SOCKET, like in QERR_SOCKET_CONNECT_FAILED.

This will cause problems when the error macros creation get automated,
because the macro name will be derived from the error class name.

Avoid that by renaming all QERR_SOCKET_* macros to QERR_SOCK_*.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 migration-tcp.c |  6 +++---
 qemu-sockets.c  | 22 +++++++++++-----------
 qerror.c        | 10 +++++-----
 qerror.h        | 10 +++++-----
 4 files changed, 24 insertions(+), 24 deletions(-)
diff mbox

Patch

diff --git a/migration-tcp.c b/migration-tcp.c
index 440804d..587fc70 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -90,13 +90,13 @@  int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
 
     if (!error_is_set(errp)) {
         migrate_fd_connect(s);
-    } else if (error_is_type(*errp, QERR_SOCKET_CONNECT_IN_PROGRESS)) {
+    } else if (error_is_type(*errp, QERR_SOCK_CONNECT_IN_PROGRESS)) {
         DPRINTF("connect in progress\n");
         qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
-    } else if (error_is_type(*errp, QERR_SOCKET_CREATE_FAILED)) {
+    } else if (error_is_type(*errp, QERR_SOCK_CREATE_FAILED)) {
         DPRINTF("connect failed\n");
         return -1;
-    } else if (error_is_type(*errp, QERR_SOCKET_CONNECT_FAILED)) {
+    } else if (error_is_type(*errp, QERR_SOCK_CONNECT_FAILED)) {
         DPRINTF("connect failed\n");
         migrate_fd_error(s);
         return -1;
diff --git a/qemu-sockets.c b/qemu-sockets.c
index 2ae715d..1357ec0 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -120,7 +120,7 @@  int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
     if ((qemu_opt_get(opts, "host") == NULL) ||
         (qemu_opt_get(opts, "port") == NULL)) {
         fprintf(stderr, "%s: host and/or port not specified\n", __FUNCTION__);
-        error_set(errp, QERR_SOCKET_CREATE_FAILED);
+        error_set(errp, QERR_SOCK_CREATE_FAILED);
         return -1;
     }
     pstrcpy(port, sizeof(port), qemu_opt_get(opts, "port"));
@@ -139,7 +139,7 @@  int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
     if (rc != 0) {
         fprintf(stderr,"getaddrinfo(%s,%s): %s\n", addr, port,
                 gai_strerror(rc));
-        error_set(errp, QERR_SOCKET_CREATE_FAILED);
+        error_set(errp, QERR_SOCK_CREATE_FAILED);
         return -1;
     }
 
@@ -153,7 +153,7 @@  int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
             fprintf(stderr,"%s: socket(%s): %s\n", __FUNCTION__,
                     inet_strfamily(e->ai_family), strerror(errno));
             if (!e->ai_next) {
-                error_set(errp, QERR_SOCKET_CREATE_FAILED);
+                error_set(errp, QERR_SOCK_CREATE_FAILED);
             }
             continue;
         }
@@ -179,7 +179,7 @@  int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
                         inet_strfamily(e->ai_family), uaddr, inet_getport(e),
                         strerror(errno));
                 if (!e->ai_next) {
-                    error_set(errp, QERR_SOCKET_BIND_FAILED);
+                    error_set(errp, QERR_SOCK_BIND_FAILED);
                 }
             }
         }
@@ -191,7 +191,7 @@  int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
 
 listen:
     if (listen(slisten,1) != 0) {
-        error_set(errp, QERR_SOCKET_LISTEN_FAILED);
+        error_set(errp, QERR_SOCK_LISTEN_FAILED);
         perror("listen");
         closesocket(slisten);
         freeaddrinfo(res);
@@ -226,7 +226,7 @@  int inet_connect_opts(QemuOpts *opts, Error **errp)
     block = qemu_opt_get_bool(opts, "block", 0);
     if (addr == NULL || port == NULL) {
         fprintf(stderr, "inet_connect: host and/or port not specified\n");
-        error_set(errp, QERR_SOCKET_CREATE_FAILED);
+        error_set(errp, QERR_SOCK_CREATE_FAILED);
         return -1;
     }
 
@@ -239,7 +239,7 @@  int inet_connect_opts(QemuOpts *opts, Error **errp)
     if (0 != (rc = getaddrinfo(addr, port, &ai, &res))) {
         fprintf(stderr,"getaddrinfo(%s,%s): %s\n", addr, port,
                 gai_strerror(rc));
-        error_set(errp, QERR_SOCKET_CREATE_FAILED);
+        error_set(errp, QERR_SOCK_CREATE_FAILED);
 	return -1;
     }
 
@@ -274,7 +274,7 @@  int inet_connect_opts(QemuOpts *opts, Error **errp)
   #else
         if (!block && (rc == -EINPROGRESS)) {
   #endif
-            error_set(errp, QERR_SOCKET_CONNECT_IN_PROGRESS);
+            error_set(errp, QERR_SOCK_CONNECT_IN_PROGRESS);
         } else if (rc < 0) {
             if (NULL == e->ai_next)
                 fprintf(stderr, "%s: connect(%s,%s,%s,%s): %s\n", __FUNCTION__,
@@ -287,7 +287,7 @@  int inet_connect_opts(QemuOpts *opts, Error **errp)
         freeaddrinfo(res);
         return sock;
     }
-    error_set(errp, QERR_SOCKET_CONNECT_FAILED);
+    error_set(errp, QERR_SOCK_CONNECT_FAILED);
     freeaddrinfo(res);
     return -1;
 }
@@ -479,7 +479,7 @@  int inet_listen(const char *str, char *ostr, int olen,
             }
         }
     } else {
-        error_set(errp, QERR_SOCKET_CREATE_FAILED);
+        error_set(errp, QERR_SOCK_CREATE_FAILED);
     }
     qemu_opts_del(opts);
     return sock;
@@ -497,7 +497,7 @@  int inet_connect(const char *str, bool block, Error **errp)
         }
         sock = inet_connect_opts(opts, errp);
     } else {
-        error_set(errp, QERR_SOCKET_CREATE_FAILED);
+        error_set(errp, QERR_SOCK_CREATE_FAILED);
     }
     qemu_opts_del(opts);
     return sock;
diff --git a/qerror.c b/qerror.c
index 92c4eff..e988e36 100644
--- a/qerror.c
+++ b/qerror.c
@@ -309,23 +309,23 @@  static const QErrorStringTable qerror_table[] = {
         .desc      = "Could not start VNC server on %(target)",
     },
     {
-        .error_fmt = QERR_SOCKET_CONNECT_IN_PROGRESS,
+        .error_fmt = QERR_SOCK_CONNECT_IN_PROGRESS,
         .desc      = "Connection can not be completed immediately",
     },
     {
-        .error_fmt = QERR_SOCKET_CONNECT_FAILED,
+        .error_fmt = QERR_SOCK_CONNECT_FAILED,
         .desc      = "Failed to connect to socket",
     },
     {
-        .error_fmt = QERR_SOCKET_LISTEN_FAILED,
+        .error_fmt = QERR_SOCK_LISTEN_FAILED,
         .desc      = "Failed to set socket to listening mode",
     },
     {
-        .error_fmt = QERR_SOCKET_BIND_FAILED,
+        .error_fmt = QERR_SOCK_BIND_FAILED,
         .desc      = "Failed to bind socket",
     },
     {
-        .error_fmt = QERR_SOCKET_CREATE_FAILED,
+        .error_fmt = QERR_SOCK_CREATE_FAILED,
         .desc      = "Failed to create socket",
     },
     {}
diff --git a/qerror.h b/qerror.h
index b4c8758..71b0496 100644
--- a/qerror.h
+++ b/qerror.h
@@ -251,19 +251,19 @@  QError *qobject_to_qerror(const QObject *obj);
 #define QERR_VNC_SERVER_FAILED \
     "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
 
-#define QERR_SOCKET_CONNECT_IN_PROGRESS \
+#define QERR_SOCK_CONNECT_IN_PROGRESS \
     "{ 'class': 'SockConnectInprogress', 'data': {} }"
 
-#define QERR_SOCKET_CONNECT_FAILED \
+#define QERR_SOCK_CONNECT_FAILED \
     "{ 'class': 'SockConnectFailed', 'data': {} }"
 
-#define QERR_SOCKET_LISTEN_FAILED \
+#define QERR_SOCK_LISTEN_FAILED \
     "{ 'class': 'SockListenFailed', 'data': {} }"
 
-#define QERR_SOCKET_BIND_FAILED \
+#define QERR_SOCK_BIND_FAILED \
     "{ 'class': 'SockBindFailed', 'data': {} }"
 
-#define QERR_SOCKET_CREATE_FAILED \
+#define QERR_SOCK_CREATE_FAILED \
     "{ 'class': 'SockCreateFailed', 'data': {} }"
 
 #endif /* QERROR_H */