[libvirt] [PATCH] virDomainDefFormatInternal: Drop useless check

There's a check if a domain definition has any graphics card and if so, we iterate over each one of them. This makes no sense, because even if it has none we can still iterate over. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/domain_conf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e47d613..56bd1aa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22363,11 +22363,9 @@ virDomainDefFormatInternal(virDomainDefPtr def, goto error; } - if (def->ngraphics > 0) { - for (n = 0; n < def->ngraphics; n++) - if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) - goto error; - } + for (n = 0; n < def->ngraphics; n++) + if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) + goto error; for (n = 0; n < def->nsounds; n++) if (virDomainSoundDefFormat(buf, def->sounds[n], flags) < 0) -- 2.4.10

On 22/02/16 08:57, Michal Privoznik wrote:
There's a check if a domain definition has any graphics card and if so, we iterate over each one of them. This makes no sense, because even if it has none we can still iterate over.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/domain_conf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e47d613..56bd1aa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22363,11 +22363,9 @@ virDomainDefFormatInternal(virDomainDefPtr def, goto error; }
- if (def->ngraphics > 0) { - for (n = 0; n < def->ngraphics; n++) - if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) - goto error; - } + for (n = 0; n < def->ngraphics; n++) + if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) + goto error;
for (n = 0; n < def->nsounds; n++) if (virDomainSoundDefFormat(buf, def->sounds[n], flags) < 0)
ACK Erik

On Mon, Feb 22, 2016 at 10:06:34AM +0100, Erik Skultety wrote:
On 22/02/16 08:57, Michal Privoznik wrote:
There's a check if a domain definition has any graphics card and if so, we iterate over each one of them. This makes no sense, because even if it has none we can still iterate over.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/domain_conf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e47d613..56bd1aa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22363,11 +22363,9 @@ virDomainDefFormatInternal(virDomainDefPtr def, goto error; }
- if (def->ngraphics > 0) { - for (n = 0; n < def->ngraphics; n++) - if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) - goto error; - } + for (n = 0; n < def->ngraphics; n++) + if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) + goto error;
You could also add the curly brackets so it complies with our coding style. And also add similar fixes from other files. But I see you've already pushed it, so I'll send a follow-up.
for (n = 0; n < def->nsounds; n++) if (virDomainSoundDefFormat(buf, def->sounds[n], flags) < 0)
ACK
Erik
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (3)
-
Erik Skultety
-
Martin Kletzander
-
Michal Privoznik