On Tue, Feb 09, 2016 at 09:08:49AM +0100, Michal Privoznik wrote:
Older gcc fails to see that the variable is set iff @hasPriority
== true in which case the former is set a value. Initialize the
value while declaring it to make the compiler shut up.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
This maybe isn't the best approach, to workaround false
positives. I'm open to discussion.
I think it is fine as is. Even if gcc were no reporting warnings,
it is always valid to initialize variables to some default value.
It may currently be redundant, but code is often refactored /
extended later, at which point the default value may well protect
against a bug, because compilers are not perfect at finding use
of uninitialized variables.
src/conf/domain_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 895a51b..67415fa 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21472,7 +21472,7 @@ virDomainFormatSchedDef(virDomainDefPtr def,
virBitmapPtr currentMap = NULL;
ssize_t nextprio;
bool hasPriority = false;
- int priority;
+ int priority = 0;
switch ((virProcessSchedPolicy) i) {
case VIR_PROC_POLICY_NONE:
ACK
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|