lkml.org 
[lkml]   [2015]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [perf/core PATCH v2 2/4] perf buildid-cache: Consolidate .build-id cache path generators
Em Tue, Feb 10, 2015 at 06:18:53PM +0900, Masami Hiramatsu escreveu:
> +static int asnprintf(char **strp, size_t size, const char *fmt, ...)
> +{
> + va_list ap;
> + int ret;
> + if (!strp)
> + return -EINVAL;
> + va_start(ap, fmt);
> + if (*strp)
> + ret = vsnprintf(*strp, size, fmt, ap);
> + else
> + ret = vasprintf(strp, fmt, ap);
> + va_end(ap);
> + return ret;
> +}
> +static char *build_id__filename(const char *sbuild_id, char *bf, size_t size)
> +{
> + char *tmp = bf;
> + int ret = asnprintf(&bf, size, "%s/.build-id/%.2s/%s", buildid_dir,
> + sbuild_id, sbuild_id + 2);
> + if (ret < 0 || (tmp && size < (unsigned int)ret))
> + return NULL;

This is a good thing, i.e. checking if the formatting truncated
something, i.e. vsnprintf honours 'size' but may return more than that,
but next time try to get it into a separate patch :-)

Anyway, after scratching my head with this extra thing/re-reading the
vsnprintf man page, I'm applying this patch, thanks.

- Arnaldo


\
 
 \ /
  Last update: 2015-02-11 16:21    [W:0.129 / U:2.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site