change strncmp(...) != 0 to STRNEQLEN(...)
[libguestfs.git] / daemon / guestfsd.c
index 370eea8..61a6236 100644 (file)
@@ -548,7 +548,7 @@ commandf (char **stdoutput, char **stderror, int flags, const char *name, ...)
 
   va_end (args);
 
-  r = commandvf (stdoutput, stderror, flags, (char **) argv);
+  r = commandvf (stdoutput, stderror, flags, (const char * const*) argv);
 
   /* NB: Mustn't free the strings which are on the stack. */
   free (argv);
@@ -605,7 +605,8 @@ commandrf (char **stdoutput, char **stderror, int flags, const char *name, ...)
 
 /* Same as 'command', but passing an argv. */
 int
-commandvf (char **stdoutput, char **stderror, int flags, char *const *argv)
+commandvf (char **stdoutput, char **stderror, int flags,
+           char const *const *argv)
 {
   int r;
 
@@ -640,7 +641,7 @@ commandvf (char **stdoutput, char **stderror, int flags, char *const *argv)
  */
 int
 commandrvf (char **stdoutput, char **stderror, int flags,
-           char const* const *argv)
+            char const* const *argv)
 {
   int so_size = 0, se_size = 0;
   int so_fd[2], se_fd[2];
@@ -745,19 +746,19 @@ commandrvf (char **stdoutput, char **stderror, int flags,
       if (r == 0) { FD_CLR (se_fd[0], &rset); quit++; }
 
       if (r > 0) {
-       if (verbose)
-         ignore_value (write (2, buf, r));
-
-       if (stderror) {
-         se_size += r;
-         p = realloc (*stderror, se_size);
-         if (p == NULL) {
-           perror ("realloc");
-           goto quit;
-         }
-         *stderror = p;
-         memcpy (*stderror + se_size - r, buf, r);
-       }
+        if (verbose)
+          ignore_value (write (2, buf, r));
+
+        if (stderror) {
+          se_size += r;
+          p = realloc (*stderror, se_size);
+          if (p == NULL) {
+            perror ("realloc");
+            goto quit;
+          }
+          *stderror = p;
+          memcpy (*stderror + se_size - r, buf, r);
+        }
       }
     }
   }
@@ -944,7 +945,7 @@ device_name_translation (char *device, const char *func)
   }
 
   /* If the name begins with "/dev/sd" then try the alternatives. */
-  if (strncmp (device, "/dev/sd", 7) != 0)
+  if (STRNEQLEN (device, "/dev/sd", 7))
     goto error;
 
   device[5] = 'h';             /* /dev/hd (old IDE driver) */