On Wed, 28 Aug 2024 at 16:59, Jason Fan <fanja...@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