mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso <dave@gnu.org>,
	Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 3/5] perf tools: Add GCC optimization to memory allocating functions
Date: Fri, 26 Nov 2010 19:47:19 -0200	[thread overview]
Message-ID: <1290808041-16535-4-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1290808041-16535-1-git-send-email-acme@infradead.org>

From: Davidlohr Bueso <dave@gnu.org>

We can benefit from the alloc_size attribute in xrealloc and zalloc.

Quoting from http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html:

"The alloc_size attribute is used to tell the compiler that the function return
value points to memory, where the size is given by one or two of the functions
parameters. GCC uses this information to improve the correctness of
__builtin_object_size."

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1290777864.2373.2.camel@cowboy>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/util.h |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 7562707..41a5067 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -182,10 +182,11 @@ static inline char *gitstrchrnul(const char *s, int c)
  * Wrappers:
  */
 extern char *xstrdup(const char *str);
-extern void *xrealloc(void *ptr, size_t size) __attribute__((weak));
+extern void *xrealloc(void *ptr, size_t size) __attribute__((weak, alloc_size(2)));
 
 
-static inline void *zalloc(size_t size)
+static inline __attribute__((alloc_size(1)))
+void *zalloc(size_t size)
 {
 	return calloc(1, size);
 }
-- 
1.6.2.5


  parent reply	other threads:[~2010-11-26 21:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-26 21:47 [GIT PULL 0/5] perf/core improvements and fixes Arnaldo Carvalho de Melo
2010-11-26 21:47 ` [PATCH 1/5] perf record: Add option to disable collecting build-ids Arnaldo Carvalho de Melo
2010-11-26 21:47 ` [PATCH 2/5] perf events: Default to using event__process_lost Arnaldo Carvalho de Melo
2010-11-26 23:55   ` Thomas Gleixner
2010-11-27  0:18     ` Arnaldo Carvalho de Melo
2010-11-26 21:47 ` Arnaldo Carvalho de Melo [this message]
2010-11-27  0:30   ` [PATCH 3/5] perf tools: Add GCC optimization to memory allocating functions Arnaldo Carvalho de Melo
2010-11-29 12:54     ` Davidlohr Bueso
2010-11-26 21:47 ` [PATCH 4/5] perf symbols: Correct final kernel map guesses Arnaldo Carvalho de Melo
2010-11-26 21:47 ` [PATCH 5/5] perf trace: Handle DT_UNKNOWN on filesystems that don't support d_type Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1290808041-16535-4-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dave@gnu.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®