On 03/05/2014 06:57 AM, John Ferlan wrote: > Coverity has found an issue (NEGATIVE_RETURNS) > > The 'nfdlist' is the culprit. > >> cleanup: >> + for (i = 0; i < nfdlist; i++) >> + VIR_FORCE_CLOSE(fdlist[i]); > > (41) Event negative_returns: Using unsigned variable "nfdlist" in a > loop exit condition. > Also see events: [negative_return_fn][var_assign] Yep. Fixing with this, as the obvious followup: diff --git i/tools/virt-login-shell.c w/tools/virt-login-shell.c index 3ea7ade..abe7eeb 100644 --- i/tools/virt-login-shell.c +++ w/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) -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list