Re: [PATCH] perf bench: add benchmark for evlist open/close operations

From: Arnaldo Carvalho de Melo
Date: Mon Aug 09 2021 - 16:28:21 EST


Em Mon, Aug 09, 2021 at 05:23:31PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Aug 09, 2021 at 10:11:02PM +0200, Riccardo Mancini escreveu:
> > +static struct evlist *bench__create_evlist(char *evstr)
> > +{
> > + struct evlist *evlist;
> > + struct parse_events_error err;
> > + int ret;

> > + evlist = evlist__new();
> > + if (!evlist) {
> > + pr_err("Not enough memory to create evlist\n");
> > + return NULL;
> > + }

> > + bzero(&err, sizeof(err));

> man bzero
>
> The bzero() function is deprecated (marked as LEGACY in POSIX.1-2001); use memset(3) in new programs. POSIX.1-2008 removes the specification of bzero(). The bzero() function first appeared in 4.3BSD.

> I'm replacing it with a memset().

This one is also equivalent:

tools/perf/tests/pmu-events.c: struct parse_events_error error = { .idx = 0, };

https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

That text is a bit roundabout, as it says that the members that are not
explicitely initialized will be initialized as variables with static
storage duration, i.e. zeroed.

- Arnaldo