qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/1] include/qemu/bitops.h: Add deposit8 for uint8_t bit oper


From: Peter Maydell
Subject: Re: [PATCH 1/1] include/qemu/bitops.h: Add deposit8 for uint8_t bit operation
Date: Wed, 28 Aug 2024 17:07:07 +0100

On Wed, 28 Aug 2024 at 16:59, Jason Fan <fanjason@google.com> wrote:
>
> Re-send this to include the original mail-list.
>
> Hi Peter,
> I am working on a i3c target model which requires bitops on the uint8_t 
> registers.
> deposit8 can help to check incorrect length or start input for 8 bit value.
> You are right that desposit32 should also work if we always pass the correct 
> arguments, but since the implementation seems trivial enough, I just go ahead 
> and create the patch.

Thanks. However I think by this argument we would want
also deposit16, deposit24, deposit4 for 4-bit registers,
and so on indefinitely. And your start and length arguments
should be #defined constants, preferably done with the
FIELD macros, not raw numbers, so I don't think that
kind of bug is very likely. (Besides, even with a
deposit8() it could protect against, say, a wrong
start value that was 8 or greater, but not a wrong
start value that happened to still be in range for a
uint8_t.)

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]