Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753418AbbBKOqA (ORCPT ); Wed, 11 Feb 2015 09:46:00 -0500 Received: from mail.kernel.org ([198.145.29.136]:42250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752928AbbBKOpo (ORCPT ); Wed, 11 Feb 2015 09:45:44 -0500 Date: Wed, 11 Feb 2015 11:46:05 -0300 From: Arnaldo Carvalho de Melo To: Masami Hiramatsu Cc: Peter Zijlstra , Adrian Hunter , linux-kernel@vger.kernel.org, Ingo Molnar , Paul Mackerras , Jiri Olsa , Namhyung Kim , Borislav Petkov , Hemant Kumar Subject: Re: [perf/core PATCH v2 2/4] perf buildid-cache: Consolidate .build-id cache path generators Message-ID: <20150211144605.GG24251@kernel.org> References: <20150210091849.19264.63698.stgit@localhost.localdomain> <20150210091853.19264.58513.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150210091853.19264.58513.stgit@localhost.localdomain> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1234 Lines: 36 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/