Re: [PATCH v3 7/9] perf header: Add check_perf_magic() func

From: Arnaldo Carvalho de Melo
Date: Tue Sep 25 2012 - 07:22:46 EST


Em Tue, Sep 25, 2012 at 04:21:40PM +0800, Feng Tang escreveu:
> On Tue, 25 Sep 2012 11:07:15 +0900
> Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> > On Mon, 24 Sep 2012 23:24:09 +0800, Feng Tang wrote:
> > [snip]
> > > +/* Return 0 if matched */
> > > +int check_perf_magic(u64 magic)
> > > +{
> > > + if (!memcmp(&magic, __perf_magic1, sizeof(magic))
> > > + || magic == __perf_magic2
> > > + || magic == __perf_magic2_sw)
> > > + return 0;
> > > +
> > > + return -1;
> > > +}
> >
> > Just an idea. How about returning version number instead of 0 so that
> > it can be used elsewhere those check is needed and possibly wants to
> > know the version number also?

> Sounds ok to me, I can add that if nobody has objection.

Leave it for when we need it?

What we need now is to see if a file is a perf.data file, so I think the
function is good as is.

Minor nitpicks: use bool, rename it to is_perf_magic(), no need for that
comment then, it becomes obvious from the function name :-)

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/