]> xenbits.xensource.com Git - libvirt.git/commitdiff
esx: Remove dead store in esxUtil_ParseDatastorePath
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 4 May 2011 07:07:41 +0000 (09:07 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 4 May 2011 16:33:14 +0000 (18:33 +0200)
The ++ on preliminaryFileName was a left over from a previous version
of this function that explicitly returned the filename and did a strdup
on preliminaryFileName afterwards.

As the filename isn't returned explicitly anymore remove the preliminary
variable for it and reuse the tmp variable instead.

Reported by Eric Blake, detected by clang.

src/esx/esx_util.c

index 9ef947c747901dccd048fa581360a7a94467b728..c14179d7f1971fee9aa05a28fbe10e79a98df7e4 100644 (file)
@@ -3,7 +3,7 @@
  * esx_util.c: utility functions for the VMware ESX driver
  *
  * Copyright (C) 2010 Red Hat, Inc.
- * Copyright (C) 2009 Matthias Bolte <matthias.bolte@googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte@googlemail.com>
  * Copyright (C) 2009 Maximilian Wilhelm <max@rfc2324.org>
  *
  * This library is free software; you can redistribute it and/or
@@ -284,7 +284,6 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
     char *saveptr = NULL;
     char *preliminaryDatastoreName = NULL;
     char *preliminaryDirectoryAndFileName = NULL;
-    char *preliminaryFileName = NULL;
 
     if ((datastoreName != NULL && *datastoreName != NULL) ||
         (directoryName != NULL && *directoryName != NULL) ||
@@ -328,11 +327,11 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
     }
 
     if (directoryName != NULL) {
-        /* Split <path> into <directory>/<file> */
-        preliminaryFileName = strrchr(preliminaryDirectoryAndFileName, '/');
+        /* Split <path> into <directory>/<file> and remove /<file> */
+        tmp = strrchr(preliminaryDirectoryAndFileName, '/');
 
-        if (preliminaryFileName != NULL) {
-            *preliminaryFileName++ = '\0';
+        if (tmp != NULL) {
+            *tmp = '\0';
         }
 
         if (esxVI_String_DeepCopyValue(directoryName,