Re: [PATCH v2] regmap: kunit: Ensure that changed bytes are actually different

From: Mark Brown
Date: Fri Feb 09 2024 - 17:40:04 EST


On Fri, Feb 09, 2024 at 02:07:38PM -0800, Guenter Roeck wrote:

> This is actually worse than v1 because hw_buf[6] isn't used anywhere.
> Making sure that the values in the val[] array don't match the values
> in hw_buf[6..7] doesn't add any value.

Yeah, I realised after reading your earlier mail. It's passing for me
somehow.

> FWIW, I had struggled with the re-use of val[0] for two different tests
> (on hw_buf[2] and hw_buf[4]) myself. The only solution other than making sure
> that it neither matches hw_buf[2] nor hw_buf[4] I came up with was to use a
> separate variable for the accesses to hw_buf[4] (or hw_buf[6] in the old code).
Indeed, it was fine with the old code due to not caring about having
different values but we need to generate three values now.

> get_changed_bytes(&hw_buf[6], &val[0], sizeof(val));
> + // Let's cheat.
> + // Remember, the above code doesn't look into hw_buf[2..5],
> + // so anything might be in there, including the values from
> + // the val[] array.
> + hw_buf[2] = val[0];
> + hw_buf[3] = val[1];
> + hw_buf[4] = val[0];
> + hw_buf[5] = val[1];

I don't understand how this interacts with the pre-sync check?

Attachment: signature.asc
Description: PGP signature