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

Re: [libvirt] [PATCH 2/2] vbox: Adjust the UTF FREE macros



On 01/23/2013 05:34 PM, John Ferlan wrote:
> Adjust the macros to free memory allocated during various calls to
> perform the check if parameter is NULL prior to really freeing and to
> set the pointer to NULL after done freeing.
> ---
>  src/vbox/vbox_tmpl.c | 76 +++++++++++++++++++++++++---------------------------
>  1 file changed, 37 insertions(+), 39 deletions(-)
> 

> +#define VBOX_UTF16_FREE(arg)                                                  \
> +    do {                                                                      \
> +        if (arg) {                                                            \
> +             data->pFuncs->pfnUtf16Free((arg));                               \

Unneeded set of () here, but it doesn't hurt anything.  Also,
indentation is off.

Modifying cfg.mk will make it easy to enforce that we don't re-introduce
the problem.  ACK with this squashed in, so I pushed.

diff --git i/cfg.mk w/cfg.mk
index a687eb9..2dfde01 100644
--- i/cfg.mk
+++ w/cfg.mk
@@ -93,6 +93,9 @@ VC_LIST_ALWAYS_EXCLUDE_REGEX = \

 # Functions like free() that are no-ops on NULL arguments.
 useless_free_options =				\
+  --name=VBOX_UTF16_FREE			\
+  --name=VBOX_UTF8_FREE				\
+  --name=VBOX_COM_UNALLOC_MEM			\
   --name=VIR_FREE				\
   --name=qemuCapsFree				\
   --name=qemuMigrationCookieFree                \
diff --git i/src/vbox/vbox_tmpl.c w/src/vbox/vbox_tmpl.c
index 86e08da..0a164dc 100644
--- i/src/vbox/vbox_tmpl.c
+++ w/src/vbox/vbox_tmpl.c
@@ -8,7 +8,7 @@
  */

 /*
- * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2010-2013 Red Hat, Inc.
  * Copyright (C) 2008-2009 Sun Microsystems, Inc.
  *
  * This file is part of a free software library; you can redistribute
@@ -80,28 +80,28 @@


 #define VIR_FROM_THIS                   VIR_FROM_VBOX
-#define VBOX_UTF16_FREE(arg)
       \
-    do {
       \
-        if (arg) {
       \
-             data->pFuncs->pfnUtf16Free((arg));
       \
-            (arg) = NULL;
       \
-        }
       \
+#define VBOX_UTF16_FREE(arg)                                            \
+    do {                                                                \
+        if (arg) {                                                      \
+            data->pFuncs->pfnUtf16Free(arg);                            \
+            (arg) = NULL;                                               \
+        }                                                               \
     } while (0)

-#define VBOX_UTF8_FREE(arg)
       \
-    do {
       \
-        if (arg) {
       \
-             data->pFuncs->pfnUtf8Free((arg));
       \
-            (arg) = NULL;
       \
-        }
       \
+#define VBOX_UTF8_FREE(arg)                                             \
+    do {                                                                \
+        if (arg) {                                                      \
+            data->pFuncs->pfnUtf8Free(arg);                             \
+            (arg) = NULL;                                               \
+        }                                                               \
     } while (0)

-#define VBOX_COM_UNALLOC_MEM(arg)
       \
-    do {
       \
-        if (arg) {
       \
-             data->pFuncs->pfnComUnallocMem((arg));
       \
-            (arg) = NULL;
       \
-        }
       \
+#define VBOX_COM_UNALLOC_MEM(arg)                                       \
+    do {                                                                \
+        if (arg) {                                                      \
+            data->pFuncs->pfnComUnallocMem(arg);                        \
+            (arg) = NULL;                                               \
+        }                                                               \
     } while (0)

 #define VBOX_UTF16_TO_UTF8(arg1, arg2)
data->pFuncs->pfnUtf16ToUtf8(arg1, arg2)


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

Attachment: signature.asc
Description: OpenPGP digital signature


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