From cb9bd7963b2a4c69285d98cc78c6017ec5e2d96e Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 5 Mar 2014 11:55:27 -0700 Subject: [PATCH] virt-login-shell: silence coverity warning Coverity spotted that 'nfdlist' (ssize_t) could be -1, but that we were using 'i' (size_t) to iterate over the list at cleanup, with crashing results because it promotes to a really big unsigned number. * tools/virt-login-shell.c (main): Avoid treating -1 as unsigned. Signed-off-by: Eric Blake --- tools/virt-login-shell.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c index 3ea7ade4be..abe7eebdf7 100644 --- a/tools/virt-login-shell.c +++ b/tools/virt-login-shell.c @@ -339,8 +339,9 @@ main(int argc, char **argv) /* At this point, the parent is now waiting for the child to exit, * but as that may take a long time, we release resources now. */ cleanup: - for (i = 0; i < nfdlist; i++) - VIR_FORCE_CLOSE(fdlist[i]); + if (nfdlist > 0) + for (i = 0; i < nfdlist; i++) + VIR_FORCE_CLOSE(fdlist[i]); VIR_FREE(fdlist); virConfFree(conf); if (dom)