gnttab: adjust pin count overflow checks
authorJan Beulich <jbeulich@suse.com>
Mon, 18 Jan 2021 11:13:42 +0000 (12:13 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 18 Jan 2021 11:13:42 +0000 (12:13 +0100)
commit8cec5d065c243e54cae97aaa14b0de447883c278
tree1649c06f2f771529c99021ee6567d51fb7fcb15b
parentd6627cf1b63ce57a6a7e2c1800dbc50eed742c32
gnttab: adjust pin count overflow checks

It's at least odd to check counters which aren't going to be
incremented, resulting in failure just because prior operations may have
reached the refcount limit. And it's also not helpful to use open-coded
literal numbers in these checks.

Calculate the increment values first and derive from them the mask to
use in the checks.

Also move the pin count checks ahead of the calculation of the status
(and for copy also sha2) pointers: They're not needed in the failure
cases, and this way the compiler may also have an easier time keeping
the variables at least transiently in registers for the subsequent uses.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/grant_table.c