Tools like coverity and maybe clang notice that we dereference
uri_out, and then (later) test whether uri_out is NULL.
Obviously one or the other must go.
Presuming that we will always pass a non-NULL uri_out arg to
this function, I chose to mark that parameter as ATTRIBUTE_NONNULL.
I removed the unnecessary test, too.
If anyone is concerned that a non-NULL (non-literal)
value will be passed, I can also add an assertion.
From 6ce3a9656d978b37d866f55606bc5031ad8e6b2f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 5 Jan 2010 16:32:11 +0100
Subject: [PATCH] qemu_driver.c: remove useless, warning-provoking test
* src/qemu/qemu_driver.c (qemudDomainMigratePrepare2): Remove useless
test of always-non-NULL uri_out parameter. Use ATTRIBUTE_NONNULL to
inform tools.
---
src/qemu/qemu_driver.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4639478..daa6f94 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1,7 +1,7 @@
/*
* driver.c: core driver methods for managing qemu guests
*
- * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -6961,7 +6961,7 @@ cleanup:
*
* This starts an empty VM listening on a TCP port.
*/
-static int
+static int ATTRIBUTE_NONNULL (5)
qemudDomainMigratePrepare2 (virConnectPtr dconn,
char **cookie ATTRIBUTE_UNUSED,
int *cookielen ATTRIBUTE_UNUSED,
@@ -7068,7 +7068,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
}
}
- if (uri_out && *uri_out)
+ if (*uri_out)
VIR_DEBUG("Generated uri_out=%s", *uri_out);
/* Parse the domain XML. */
--
1.6.6.387.g2649b1