2011/5/4 Eric Blake <ebl...@redhat.com>: > 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.bo...@googlemail.com> > * Copyright (C) 2009 Maximilian Wilhelm <m...@rfc2324.org> > * > @@ -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.bo...@googlemail.com> 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.bo...@googlemail.com> + * Copyright (C) 2009-2011 Matthias Bolte <matthias.bo...@googlemail.com> * Copyright (C) 2009 Maximilian Wilhelm <m...@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, -- 1.7.0.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list