Re: [PATCH] esx: remove dead store

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

 



2011/5/4 Eric Blake <eblake@xxxxxxxxxx>:
> Detected by clang.
>
> * src/esx/esx_util.c (esxUtil_ParseDatastorePath): No need to
> increment.
> ---
> Âsrc/esx/esx_util.c | Â Â4 ++--
> Â1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
> index 9ef947c..640e984 100644
> --- a/src/esx/esx_util.c
> +++ b/src/esx/esx_util.c
> @@ -2,7 +2,7 @@
> Â/*
> Â* esx_util.c: utility functions for the VMware ESX driver
> Â*
> - * Copyright (C) 2010 Red Hat, Inc.
> + * Copyright (C) 2010-2011 Red Hat, Inc.
> Â* Copyright (C) 2009 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>
> Â* Copyright (C) 2009 Maximilian Wilhelm <max@xxxxxxxxxxx>
> Â*
> @@ -332,7 +332,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
> Â Â Â Â preliminaryFileName = strrchr(preliminaryDirectoryAndFileName, '/');
>
> Â Â Â Â if (preliminaryFileName != NULL) {
> - Â Â Â Â Â Â*preliminaryFileName++ = '\0';
> + Â Â Â Â Â Â*preliminaryFileName = '\0';
> Â Â Â Â }
>
> Â Â Â Â if (esxVI_String_DeepCopyValue(directoryName,
> --
> 1.7.4.4
>

This fixes the problem, but I prefer the attached patch.

Matthias
From 59830bc0f103978dcafd50f241a7109f92f03f69 Mon Sep 17 00:00:00 2001
From: Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>
Date: Wed, 4 May 2011 09:07:41 +0200
Subject: [PATCH] esx: Remove dead store in esxUtil_ParseDatastorePath

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 |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 9ef947c..c14179d 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -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@xxxxxxxxxxxxxx>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>
  * Copyright (C) 2009 Maximilian Wilhelm <max@xxxxxxxxxxx>
  *
  * 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,
-- 
1.7.0.4

--
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]