[libvirt] [PATCH 08/10] virt-login-shell: use single instead of double fork
Eric Blake
eblake at redhat.com
Wed Mar 5 18:55:13 UTC 2014
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140305/606dbe86/attachment-0001.sig>
More information about the libvir-list
mailing list