diff options
author | Eric Blake <eblake@redhat.com> | 2023-06-08 08:56:35 -0500 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2023-07-19 15:26:13 -0500 |
commit | 8cb98a725e7397c9de25ebd77c00b1d5f2d8351e (patch) | |
tree | d0db8b66e4d7ce26c8f5cc9d4b9ae2433b92e9e6 /event-loop-base.c | |
parent | 22efd81104f07f7dbe571a923cc43ed625560551 (diff) | |
download | qemu-8cb98a725e7397c9de25ebd77c00b1d5f2d8351e.zip qemu-8cb98a725e7397c9de25ebd77c00b1d5f2d8351e.tar.gz qemu-8cb98a725e7397c9de25ebd77c00b1d5f2d8351e.tar.bz2 |
nbd/client: Simplify cookie vs. index computation
Our code relies on a sentinel cookie value of zero for deciding when a
packet has been handled, as well as relying on array indices between 0
and MAX_NBD_REQUESTS-1 for dereferencing purposes. As long as we can
symmetrically convert between two forms, there is no reason to go with
the odd choice of using XOR with a random pointer, when we can instead
simplify the mappings with a mere offset of 1.
Using ((uint64_t)-1) as the sentinel instead of NULL such that the two
macros could be entirely eliminated might also be possible, but would
require a more careful audit to find places where we currently rely on
zero-initialization to be interpreted as the sentinel value, so I did
not pursue that course.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20230608135653.2918540-7-eblake@redhat.com>
[eblake: enhance commit message]
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Diffstat (limited to 'event-loop-base.c')
0 files changed, 0 insertions, 0 deletions