Re: [PATCH bpf-next v3 05/15] selftests/bpf: utility functions to capture libbpf log in test_progs

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

 



On Tue, 2024-03-05 at 11:24 -0800, Andrii Nakryiko wrote:
[...]

> > +char *stop_libbpf_log_capture(void)
> > +{
> > +       char *buf;
> > +
> > +       if (!libbpf_capture_stream)
> > +               return NULL;
> > +
> > +       fputc(0, libbpf_capture_stream);
> > +       fclose(libbpf_capture_stream);
> > +       libbpf_capture_stream = NULL;
> > +       /* get 'buf' after fclose(), see open_memstream() documentation */
> > +       buf = libbpf_output_capture.buf;
> > +       bzero(&libbpf_output_capture, sizeof(libbpf_output_capture));
> 
> please use memset():
> 
> $ rg -w memset | wc -l
> 355
> $ rg -w bzero | wc -l
> 12

Ok, will do

> > +       return buf;
> > +}
> > +
> >  static int libbpf_print_fn(enum libbpf_print_level level,
> >                            const char *format, va_list args)
> >  {
> > +       if (libbpf_capture_stream) {
> > +               va_list args2;
> > +
> > +               va_copy(args2, args);
> > +               vfprintf(libbpf_capture_stream, format, args2);
> > +       }
> 
> should we take into account verbosity settings? capturing LIBBPF_DEBUG
> logs probably isn't very useful (but will make debugging harder,
> probably)

LIBBPF_DEBUG messages are not necessary for my tests,
so I'll move this down after verbosity check,
could be changed later if need be.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux