[libvirt] [PATCH] build: avoid shadowing a function name

Eric Blake eblake at redhat.com
Thu Mar 7 14:53:35 UTC 2013


On 03/07/2013 07:48 AM, Daniel P. Berrange wrote:
> On Thu, Mar 07, 2013 at 06:40:49AM -0700, Eric Blake wrote:
>> Make the same fix as in commit de53eff.
>>
>> * src/util/viralloc.h (virDeleteElementsN): Cater to old gcc/glibc.
>> ---
>>
>> Pushing under the trivial rule.
>>
>>  src/util/viralloc.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/util/viralloc.h b/src/util/viralloc.h
>> index 3c97a58..6f46d0b 100644
>> --- a/src/util/viralloc.h
>> +++ b/src/util/viralloc.h
>> @@ -64,7 +64,7 @@ int virInsertElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr,
>>                         bool clearOriginal, bool inPlace)
>>      ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
>>  int virDeleteElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr,
>> -                       size_t remove, bool inPlace)
>> +                       size_t toremove, bool inPlace)
>>      ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
>>  int virAllocVar(void *ptrptr,
>>                  size_t struct_size,
> 
> Ideally we should update the .c file too, to match.

Agreed; I'll push this followup soon.  The original de53eff that I was
copying from did not touch the .c file, but that was because it was
already using the name 'toremove' in the .c file at the time.

diff --git i/src/util/viralloc.c w/src/util/viralloc.c
index 58d4bcd..807de04 100644
--- i/src/util/viralloc.c
+++ w/src/util/viralloc.c
@@ -1,7 +1,7 @@
 /*
  * viralloc.c: safer memory allocation
  *
- * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2010-2013 Red Hat, Inc.
  * Copyright (C) 2008 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -328,7 +328,7 @@ virInsertElementsN(void *ptrptr, size_t size, size_t at,
  * @size:     the size of one element in bytes
  * @at:       index within array where new elements should be deleted
  * @countptr: variable tracking number of elements currently allocated
- * @remove:   number of elements to remove
+ * @toremove: number of elements to remove
  * @inPlace:  false if we should shrink the allocated memory when done,
  *            true if we should assume someone else will do that.
  *
@@ -341,12 +341,12 @@ virInsertElementsN(void *ptrptr, size_t size,
size_t at,
  */
 int
 virDeleteElementsN(void *ptrptr, size_t size, size_t at,
-                   size_t *countptr, size_t remove,
+                   size_t *countptr, size_t toremove,
                    bool inPlace)
 {
-    if (at + remove > *countptr) {
-        VIR_WARN("out of bounds index - count %zu at %zu remove %zu",
-                 *countptr, at, remove);
+    if (at + toremove > *countptr) {
+        VIR_WARN("out of bounds index - count %zu at %zu toremove %zu",
+                 *countptr, at, toremove);
         return -1;
     }

@@ -355,12 +355,12 @@ virDeleteElementsN(void *ptrptr, size_t size,
size_t at,
      * already been cleared.
     */
     memmove(*(char**)ptrptr + (size * at),
-            *(char**)ptrptr + (size * (at + remove)),
-            size * (*countptr - remove - at));
+            *(char**)ptrptr + (size * (at + toremove)),
+            size * (*countptr - toremove - at));
     if (inPlace)
-        *countptr -= remove;
+        *countptr -= toremove;
     else
-        virShrinkN(ptrptr, size, countptr, remove);
+        virShrinkN(ptrptr, size, countptr, toremove);
     return 0;
 }



-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130307/f26a5591/attachment-0001.sig>


More information about the libvir-list mailing list