Skip to contentSkip to conversation

perf_counter tools: Fix off-by-one bug in symbol__new

PATCH In review Arnaldo Carvalho de Melo 1 participant 2 messages Jun 3, 2009 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf_counter tools: Fix off-by-one bug in symbol__new

The end is really (start + len - 1). Noticed when synthesizing the PLT symbols, that are small (16 bytes), and hot on the start RIP.

Documentation/perf_counter/util/symbol.c +1 -1
index d52a1ae..35ee6de 100644
@@ -19,7 +19,7 @@ static struct symbol *symbol__new(uint64_t start, uint64_t len,
 			self = ((void *)self) + priv_size;
 		}
 		self->start = start;
-		self->end   = start + len;
+		self->end   = start + len - 1;
 		memcpy(self->name, name, namelen);
 	}
 
#1 lore raw
Commit-ID:  18374ab76e3ec1cf1b0ca5a8d08e35cfc5d01669
Gitweb:     http://git.kernel.org/tip/18374ab76e3ec1cf1b0ca5a8d08e35cfc5d01669
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 3 Jun 2009 14:49:21 -0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 3 Jun 2009 21:46:59 +0200

perf_counter tools: Fix off-by-one bug in symbol__new

The end is really (start + len - 1). Noticed when synthesizing the PLT symbols, that are small (16 bytes), and hot on the start RIP.

Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Corey Ashford <[email protected]>
Cc Marcelo Tosatti <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Thomas Gleixner <[email protected]>

LKML-Reference: <[email protected]>

---
 Documentation/perf_counter/util/symbol.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/perf_counter/util/symbol.c +1 -1
index d52a1ae..35ee6de 100644
@@ -19,7 +19,7 @@ static struct symbol *symbol__new(uint64_t start, uint64_t len,
 			self = ((void *)self) + priv_size;
 		}
 		self->start = start;
-		self->end   = start + len;
+		self->end   = start + len - 1;
 		memcpy(self->name, name, namelen);
 	}