Skip to contentSkip to conversation

xl: free default_{vifscript, bridge, gatewaydev} on exit

PATCH In review Ian Campbell 3 participants 5 messages Jun 12, 2013 – Jun 27, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xl: free default_{vifscript, bridge, gatewaydev} on exit

These leaks aren't serious, since they are only in xl but this makes "xl list" clean according to valgrind, which is useful from the point of view of eliminating false positives when looking at the state of libxl (where leaks matter).

---

I'm inclined to suggest that these are 4.4 material.

---
 tools/libxl/xl.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
tools/libxl/xl.c +15 -0
index 3c141bf..0f3acb9 100644
@@ -276,6 +276,21 @@ static void xl_ctx_free(void)
         free(lockfile);
         lockfile = NULL;
     }
+
+    if (default_vifscript) {
+        free(default_vifscript);
+        default_vifscript = NULL;
+    }
+
+    if (default_bridge) {
+        free(default_bridge);
+        default_bridge = NULL;
+    }
+
+    if (default_gatewaydev) {
+        free(default_gatewaydev);
+        default_gatewaydev = NULL;
+    }
 }
 
 int main(int argc, char **argv)
Signature · 1 line
1.7.2.5
#1 lore raw

Ian Campbell writes ("[PATCH] xl: free default_{vifscript,bridge,gatewaydev} on exit"):

Quoted 4 lines

These leaks aren't serious, since they are only in xl but this makes "xl list" clean according to valgrind, which is useful from the point of view of eliminating false positives when looking at the state of libxl (where leaks matter).

...

tools/libxl/xl.c static void xl_ctx_free(void) · line 282

Quoted 3 lines
tools/libxl/xl.c +3 -0
+    if (default_vifscript) {
+        free(default_vifscript);
+        default_vifscript = NULL;

These ifs are unnecessary. free(NULL) is a no-op.

I would write:

+        free(default_vifscript);   default_vifscript = NULL;
+        free(default_bridge);      default_bridge = NULL;
+        free(default_gatewaydev);  default_gatewaydev = NULL;

which is nice and regular.

Ian.

#2 lore raw
Quoted 18 lines · Ian Jackson

Ian Campbell writes ("[PATCH] xl: free default_{vifscript,bridge,gatewaydev} on exit"):

Quoted 4 lines

These leaks aren't serious, since they are only in xl but this makes "xl list" clean according to valgrind, which is useful from the point of view of eliminating false positives when looking at the state of libxl (where leaks matter).

...

tools/libxl/xl.c static void xl_ctx_free(void) · line 282

Quoted 3 lines
tools/libxl/xl.c +3 -0
+    if (default_vifscript) {
+        free(default_vifscript);
+        default_vifscript = NULL;

These ifs are unnecessary. free(NULL) is a no-op.

I would write:

(quoted diff) +3 -0
+        free(default_vifscript);   default_vifscript = NULL;
+        free(default_bridge);      default_bridge = NULL;
+        free(default_gatewaydev);  default_gatewaydev = NULL;
Quoted 1 line

which is nice and regular.

So would I except this is the prevailing style in that function for some reason (even though I have a feeling I wrote it).

Ian.

Acked-by on v1 1/1
#3 lore raw
In reply to Ian Campbell
Quoted 7 lines · Ian Campbell

These leaks aren't serious, since they are only in xl but this makes "xl list" clean according to valgrind, which is useful from the point of view of eliminating false positives when looking at the state of libxl (where leaks matter).

Risk of introducing bugs? Almost nil.
Makes xen 4.3 more awesome? Yes, by allowing valgrind to run cleanly.

Re the release:

#4 lore raw
Quoted 9 lines · George Dunlap
Quoted 7 lines · Ian Campbell

These leaks aren't serious, since they are only in xl but this makes "xl list" clean according to valgrind, which is useful from the point of view of eliminating false positives when looking at the state of libxl (where leaks matter).

Quoted 6 lines

Risk of introducing bugs? Almost nil.
Makes xen 4.3 more awesome? Yes, by allowing valgrind to run cleanly.

Re the release:

Uh, seems these have languished in my queue since then, since more than two weeks have passed I don't want to just carry that ack over. I think it is now too late?