[libvirt] [PATCH] storage: Use VIR_DELETE_ELEMENT instead of open coding

Replace the open coded array element deletion by our new helper. --- src/storage/storage_driver.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index baba9c9..aaa0f02 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1565,17 +1565,8 @@ storageVolDelete(virStorageVolPtr obj, VIR_INFO("Deleting volume '%s' from storage pool '%s'", vol->name, pool->def->name); virStorageVolDefFree(vol); - vol = NULL; - - if (i < (pool->volumes.count - 1)) - memmove(pool->volumes.objs + i, pool->volumes.objs + i + 1, - sizeof(*(pool->volumes.objs)) * (pool->volumes.count - (i + 1))); - - if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count - 1) < 0) { - ; /* Failure to reduce memory allocation isn't fatal */ - } - pool->volumes.count--; + VIR_DELETE_ELEMENT(pool->volumes.objs, pool->volumes.count, i); break; } } -- 1.8.5.2

On 01/06/2014 03:04 PM, Peter Krempa wrote:
Replace the open coded array element deletion by our new helper. --- src/storage/storage_driver.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index baba9c9..aaa0f02 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1565,17 +1565,8 @@ storageVolDelete(virStorageVolPtr obj, VIR_INFO("Deleting volume '%s' from storage pool '%s'", vol->name, pool->def->name); virStorageVolDefFree(vol); - vol = NULL; - - if (i < (pool->volumes.count - 1)) - memmove(pool->volumes.objs + i, pool->volumes.objs + i + 1, - sizeof(*(pool->volumes.objs)) * (pool->volumes.count - (i + 1))); - - if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count - 1) < 0) { - ; /* Failure to reduce memory allocation isn't fatal */ - } - pool->volumes.count--;
+ VIR_DELETE_ELEMENT(pool->volumes.objs, pool->volumes.count, i); break; } }
ACK Jan

On 01/06/14 15:18, Ján Tomko wrote:
On 01/06/2014 03:04 PM, Peter Krempa wrote:
Replace the open coded array element deletion by our new helper. --- src/storage/storage_driver.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
ACK
Thanks; Pushed.
Jan
Peter

On 01/06/2014 07:04 AM, Peter Krempa wrote:
Replace the open coded array element deletion by our new helper. --- src/storage/storage_driver.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Eric Blake
-
Ján Tomko
-
Peter Krempa