Guido Günther <agx(a)sigxcpu.org> wrote:
attached patch removes the hardcoded port 22 when going through ssh,
ssh
uses it by default. This makes it easier to override this via
.ssh/config on a per host basis instead of having to add this to the
connection URI explicitly.
Good idea!
While at that I cleaned up some free vs. VIR_FREE usage and replaced
pointer intializations with 0 by NULL.
Always welcome. Thanks!
ACK, with one suggestion:
>From 8947ce3926829f0c30935c9a4acfc28dde9c621a Mon Sep 17 00:00:00
2001
From: =?utf-8?q?Guido=20G=C3=BCnther?= <agx(a)sigxcpu.org>
Date: Fri, 30 Jan 2009 20:23:29 +0100
Subject: [PATCH] don't hardcode ssh port to 22
...
- if (priv->hostname) {
- free (priv->hostname);
- priv->hostname = NULL;
- }
+ if (priv->hostname)
+ VIR_FREE(priv->hostname);
Now that you've converted to VIR_FREE, you can also
remove the preceding (useless) test.
This made me realize our "avoid_if_before_free" syntax
check should also be checking for uses of VIR_FREE, so
I added that. That exposed a few more useless tests.
The patch below corrects them:
From 1f7540990c61976f185ab3ffb1111a18ba25e810 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Sat, 31 Jan 2009 12:15:54 +0100
Subject: [PATCH] cleanup: remove useless if-before-VIR_FREE
* Makefile.cfg (useless_free_options): Also check for VIR_FREE.
* src/iptables.c (iptRulesFree): Remove useless if-before-VIR_FREE.
* src/remote_internal.c (remoteAuthSASL): Likewise.
* src/test.c (testOpenFromFile): Likewise.
---
Makefile.cfg | 1 +
src/iptables.c | 9 +++------
src/remote_internal.c | 4 +---
src/test.c | 11 ++++-------
4 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/Makefile.cfg b/Makefile.cfg
index 44d3898..d9bccd2 100644
--- a/Makefile.cfg
+++ b/Makefile.cfg
@@ -59,6 +59,7 @@ local-checks-to-skip = \
useless_free_options = \
--name=sexpr_free \
+ --name=VIR_FREE \
--name=xmlFree \
--name=xmlXPathFreeContext \
--name=xmlXPathFreeObject
diff --git a/src/iptables.c b/src/iptables.c
index ad7fddf..c850b9e 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2007-2009 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -325,11 +325,8 @@ iptRulesFree(iptRules *rules)
{
int i;
- if (rules->table)
- VIR_FREE(rules->table);
-
- if (rules->chain)
- VIR_FREE(rules->chain);
+ VIR_FREE(rules->table);
+ VIR_FREE(rules->chain);
if (rules->rules) {
for (i = 0; i < rules->nrules; i++)
diff --git a/src/remote_internal.c b/src/remote_internal.c
index f8740af..6eef328 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -5392,9 +5392,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int
in_open,
goto cleanup;
}
- if (serverin) {
- VIR_FREE(serverin);
- }
+ VIR_FREE(serverin);
DEBUG("Client step result %d. Data %d bytes %p", err, clientoutlen,
clientout);
/* Previous server call showed completion & we're now locally complete
too */
diff --git a/src/test.c b/src/test.c
index 59b9370..0e0ec7c 100644
--- a/src/test.c
+++ b/src/test.c
@@ -1,7 +1,7 @@
/*
* test.c: A "mock" hypervisor for use by application unit tests
*
- * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2009 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -509,8 +509,7 @@ static int testOpenFromFile(virConnectPtr conn,
dom->persistent = 1;
virDomainObjUnlock(dom);
}
- if (domains != NULL)
- VIR_FREE(domains);
+ VIR_FREE(domains);
ret = virXPathNodeSet(conn, "/node/network", ctxt, &networks);
if (ret < 0) {
@@ -544,8 +543,7 @@ static int testOpenFromFile(virConnectPtr conn,
net->persistent = 1;
virNetworkObjUnlock(net);
}
- if (networks != NULL)
- VIR_FREE(networks);
+ VIR_FREE(networks);
/* Parse Storage Pool list */
ret = virXPathNodeSet(conn, "/node/pool", ctxt, &pools);
@@ -599,8 +597,7 @@ static int testOpenFromFile(virConnectPtr conn,
pool->active = 1;
virStoragePoolObjUnlock(pool);
}
- if (pools != NULL)
- VIR_FREE(pools);
+ VIR_FREE(pools);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
--
1.6.1.2.418.gd79e6