Re: [PATCH 04/10] perf, x86: Making hardware events translationsavailable in sysfs

From: Arnaldo Carvalho de Melo
Date: Wed Jul 04 2012 - 12:36:10 EST


Em Wed, Jul 04, 2012 at 02:14:48PM +0200, Peter Zijlstra escreveu:
> On Wed, 2012-07-04 at 14:01 +0200, Jiri Olsa wrote:
> > > ret = sprintf(page, "event=0x%02llx", event);
> > > if (umask)
> > > ret += sprintf(page + ret, ",umask=0x%02llx", umask);
> > > if (inv)
> > > ret += sprintf(page + ret, ",inv");
> > > if (cmask)
> > > ret += sprintf(page + ret, ",cmask=0x%02llx", cmask);
> > > sprintf(page + ret, "\n");
>
> There's a ret += missing there.

And also don't use sprintf or snprintf, use scnprintf, the former have
confusing semantics for the return value, see the man pages.

- 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/