
On 03/05/2014 01:55 PM, Eric Blake wrote:
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)
ACK, checked with my Coverity build too. John