On 5. Mar 2025, at 10:18, Ingo Molnar wrote: > Actually, on a second thought: > >> - buf = kzalloc_node(offsetof(struct bts_buffer, buf[nbuf]), GFP_KERNEL, node); >> + buf = kzalloc_node(struct_size(buf, buf, nbuf), GFP_KERNEL, node); > > Firstly, in what world is 'buf, buf' more readable? One is a member of > a structure, the other is the name of the structure - and they match, > which shows that this function's naming conventions are a mess. > > Which should be fixed first ... Yes, I noticed this too, but since buf->buf[] is used all over the place (also in other functions), I didn't rename it in this patch. We could just keep offsetof(struct bts_buffer, buf[nbuf]), or use struct_size_t(struct bts_buffer, buf, nbuf) and still benefit from additional compile-time checks, or rename the local variable to struct bts_buffer *bts and use struct_size(bts, buf, nbuf), for example. Any preferences or other ideas? > I'm also not sure the code is correct ... Which part of it? Thanks, Thorsten
![]() |