[PATCH 12/22] rpc: Fix misaligned arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch fixes misaligned arguments.

Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx>
---
 src/rpc/virnetclient.c        | 40 +++++++++++++++++++----------------
 src/rpc/virnetlibsshsession.c |  2 +-
 src/rpc/virnetservermdns.c    |  4 ++--
 src/rpc/virnetsocket.c        | 23 +++++++++++---------
 src/rpc/virnetsshsession.c    |  2 +-
 5 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index b4d8fb2..d2162d4 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -493,15 +493,17 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host,
     if (!(nc = virBufferContentAndReset(&buf)))
         goto no_memory;
 
-    virBufferAsprintf(&buf,
-         "sh -c "
-         "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then "
-             "ARG=-q0;"
-         "else "
-             "ARG=;"
-         "fi;"
-         "'%s' $ARG -U %s'",
-         nc, nc, socketPath);
+#define COMMAND_FORMAT "sh -c " \
+    "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " \
+        "ARG=-q0;" \
+    "else " \
+        "ARG=;" \
+    "fi;" \
+    "'%s' $ARG -U %s'"
+
+    virBufferAsprintf(&buf, COMMAND_FORMAT, nc, nc, socketPath);
+
+#undef COMMAND_FORMAT
 
     if (!(command = virBufferContentAndReset(&buf)))
         goto no_memory;
@@ -601,17 +603,19 @@ virNetClientPtr virNetClientNewLibssh(const char *host,
     if (!(nc = virBufferContentAndReset(&buf)))
         goto no_memory;
 
-    if (virAsprintf(&command,
-         "sh -c "
-         "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then "
-             "ARG=-q0;"
-         "else "
-             "ARG=;"
-         "fi;"
-         "'%s' $ARG -U %s'",
-         nc, nc, socketPath) < 0)
+#define COMMAND_FORMAT "sh -c " \
+    "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " \
+        "ARG=-q0;" \
+    "else " \
+        "ARG=;" \
+    "fi;" \
+    "'%s' $ARG -U %s'"
+
+    if (virAsprintf(&command, COMMAND_FORMAT, nc, nc, socketPath) < 0)
         goto cleanup;
 
+#undef COMMAND_FORMAT
+
     if (virNetSocketNewConnectLibssh(host, port,
                                      family,
                                      username, privkey,
diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index 7c5f158..2422150 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -1124,7 +1124,7 @@ virNetLibsshSessionAuthAddKeyboardAuth(virNetLibsshSessionPtr sess,
 
 int
 virNetLibsshSessionSetChannelCommand(virNetLibsshSessionPtr sess,
-                                      const char *command)
+                                     const char *command)
 {
     int ret = 0;
     virObjectLock(sess);
diff --git a/src/rpc/virnetservermdns.c b/src/rpc/virnetservermdns.c
index e0a9aef..3669998 100644
--- a/src/rpc/virnetservermdns.c
+++ b/src/rpc/virnetservermdns.c
@@ -347,8 +347,8 @@ static AvahiTimeout *virNetServerMDNSTimeoutNew(const AvahiPoll *api ATTRIBUTE_U
     }
 
     VIR_DEBUG("Trigger timed for %d %d      %d %d",
-               (int)now.tv_sec, (int)now.tv_usec,
-               (int)(tv ? tv->tv_sec : 0), (int)(tv ? tv->tv_usec : 0));
+              (int)now.tv_sec, (int)now.tv_usec,
+              (int)(tv ? tv->tv_sec : 0), (int)(tv ? tv->tv_usec : 0));
     nowms = (now.tv_sec * 1000ll) + (now.tv_usec / 1000ll);
     if (tv) {
         thenms = (tv->tv_sec * 1000ll) + (tv->tv_usec/1000ll);
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 55de3b2..5fe0930 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -634,7 +634,7 @@ int virNetSocketNewConnectUNIX(const char *path,
     bool daemonLaunched = false;
 
     VIR_DEBUG("path=%s spawnDaemon=%d binary=%s", path, spawnDaemon,
-        NULLSTR(binary));
+              NULLSTR(binary));
 
     memset(&localAddr, 0, sizeof(localAddr));
     memset(&remoteAddr, 0, sizeof(remoteAddr));
@@ -883,14 +883,17 @@ int virNetSocketNewConnectSSH(const char *nodename,
      * Fedora's 'nc' doesn't have this option, and defaults to the desired
      * behavior.
      */
-    virCommandAddArgFormat(cmd,
-         "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then "
-             "ARG=-q0;"
-         "else "
-             "ARG=;"
-         "fi;"
-         "'%s' $ARG -U %s'",
-         quoted, quoted, path);
+#define COMMAND_FORMAT "" \
+    "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " \
+        "ARG=-q0;" \
+    "else " \
+        "ARG=;" \
+    "fi;" \
+    "'%s' $ARG -U %s'"
+
+    virCommandAddArgFormat(cmd, COMMAND_FORMAT, quoted, quoted, path);
+
+#undef COMMAND_FORMAT
 
     VIR_FREE(quoted);
     return virNetSocketNewConnectCommand(cmd, retsock);
@@ -1534,7 +1537,7 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
          */
         if (errno != EOPNOTSUPP) {
             virReportSystemError(errno, "%s",
-                    _("Failed to get client socket PID"));
+                                 _("Failed to get client socket PID"));
             goto cleanup;
         }
     }
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index 35dc6c5..1114036 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -462,7 +462,7 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
         if (sess->knownHostsFile) {
             if (libssh2_knownhost_writefile(sess->knownHosts,
                                             sess->knownHostsFile,
-                                         LIBSSH2_KNOWNHOST_FILE_OPENSSH) < 0) {
+                                            LIBSSH2_KNOWNHOST_FILE_OPENSSH) < 0) {
                 libssh2_session_last_error(sess->session, &errmsg, NULL, 0);
                 virReportError(VIR_ERR_SSH,
                                _("failed to write known_host file '%s': %s"),
-- 
2.17.1


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux