Why cast to "signed short" before checking the return value of gnttab_claim_grant_reference() in xen-netfront.c?
Hi,
Would anyone please help with a question on xen-netfront.c code?
In xen-netfront.c, the return value of gnttab_claim_grant_reference() is checked with "BUG_ON((signed short)ref < 0);". Why we use signed short here while the return value is of uint32_t?
Am I missing anything or can I send a patch to fix this issue? In xen-blkfront.c and xen-scsifront.c "BUG_ON(gnt_list_entry->gref == -ENOSPC);" is involved to check return value.
The guest kernel would panic after grant refs reach a very large number (when guest is attached with large number of devices and live migrated).
Thank you very much!
Dongli Zhang
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 28.10.16 at 08:46, <[email protected]> wrote:
Would anyone please help with a question on
xen-netfront.ccode?In
xen-netfront.c, the return value ofgnttab_claim_grant_reference()is checked with "BUG_ON((signed short)ref < 0);". Why we use signed short here while the return value is ofuint32_t?
The return value is of type int. The value the return value gets stored into is of type uint32_t.
Quoted 3 lines
Am I missing anything or can I send a patch to fix this issue? In
xen-blkfront.candxen-scsifront.c"BUG_ON(gnt_list_entry->gref == -ENOSPC);" is involved to check return value.
This certainly looks wrong. Special casing -ENOSPC, otoh, isn't the best approach either - I think you want to use IS_ERR_VALUE() instead, perhaps together with using another intermediate variable (or type long) to at once deal with the type mismatch mentioned above as well as to please the compiler when using IS_ERR_VALUE() (which casts the value to a pointer).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines · Dongli Zhang
Hi,
Would anyone please help with a question on
xen-netfront.ccode?In
xen-netfront.c, the return value ofgnttab_claim_grant_reference()is checked with "BUG_ON((signed short)ref < 0);". Why we use signed short here while the return value is ofuint32_t?
That's wrong. Please just remove that BUG_ON() it isn't useful.
David
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel