On Fri, Jun 19, 2026 at 2:12 PM Eduard Zingerman <[email protected]> wrote: > > > > int *len_ptr, len, err; > > > @@ -240,6 +260,9 @@ static int64_t ringbuf_process_ring(struct ring *r, > > > size_t n) > > > bool got_new_data; > > > void *sample; > > > > > > + err = ringbuf_validate(r); > > > + if (err) > > > + return err; > > > > as Emil noted in first version, this seems like overkill, could you > > just check sample_cb != NULL before it's actualy called? > > > > in [1] you mentioned you plan to add some feature that won't use sample_cb, > > it'd be easier to review/suggest the solution with more details on that > > > > jirka > > As-is it appears that the simplest thing to do is to error out in > ring_buffer__new() and ring_buffer__add() when callback is NULL or > when overwrite map flag is present. > I checked our internal usage for then __new/__add functions, > and it seems there are no cases when NULL is passed as a callback.
Even such an early check is probably unnecessary. A valid callback is a part of api today. In general we don't add defensive programing checks for NULL here and in other places. Sounds like there is a follow up to add callback-less api. Let's see how it looks. If there is a need to check callback nullness it's better to discuss altogether.

