aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2012-02-09 17:21:07 -0500
committerIngo Molnar <mingo@elte.hu>2012-03-09 02:26:06 -0500
commit62db90681c0db8c76e5db006b929a2edd5d12ae6 (patch)
tree9a758f8c9c41b34ae96533571a132b226819803f /tools
parent69996df486fc3921bbaaa17fca0d68f537f9eabf (diff)
perf tools: Fix ABI compatibility bug in print_event_desc()
This patches cleans up local variable types for msz and ret. They need to be size_t and ssize_t respectively. It also fixes a bug whereby perf would not read attr struct with a different size than what it knows about. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: robert.richter@amd.com Cc: ming.m.lin@intel.com Cc: andi@firstfloor.org Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1328826068-11713-18-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/header.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 666f18972fa3..6d580267d043 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1144,8 +1144,9 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
1144 uint64_t id; 1144 uint64_t id;
1145 void *buf = NULL; 1145 void *buf = NULL;
1146 char *str; 1146 char *str;
1147 u32 nre, sz, nr, i, j, msz; 1147 u32 nre, sz, nr, i, j;
1148 int ret; 1148 ssize_t ret;
1149 size_t msz;
1149 1150
1150 /* number of events */ 1151 /* number of events */
1151 ret = read(fd, &nre, sizeof(nre)); 1152 ret = read(fd, &nre, sizeof(nre));
@@ -1162,25 +1163,23 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
1162 if (ph->needs_swap) 1163 if (ph->needs_swap)
1163 sz = bswap_32(sz); 1164 sz = bswap_32(sz);
1164 1165
1165 /*
1166 * ensure it is at least to our ABI rev
1167 */
1168 if (sz < (u32)sizeof(attr))
1169 goto error;
1170
1171 memset(&attr, 0, sizeof(attr)); 1166 memset(&attr, 0, sizeof(attr));
1172 1167
1173 /* read entire region to sync up to next field */ 1168 /* buffer to hold on file attr struct */
1174 buf = malloc(sz); 1169 buf = malloc(sz);
1175 if (!buf) 1170 if (!buf)
1176 goto error; 1171 goto error;
1177 1172
1178 msz = sizeof(attr); 1173 msz = sizeof(attr);
1179 if (sz < msz) 1174 if (sz < (ssize_t)msz)
1180 msz = sz; 1175 msz = sz;
1181 1176
1182 for (i = 0 ; i < nre; i++) { 1177 for (i = 0 ; i < nre; i++) {
1183 1178
1179 /*
1180 * must read entire on-file attr struct to
1181 * sync up with layout.
1182 */
1184 ret = read(fd, buf, sz); 1183 ret = read(fd, buf, sz);
1185 if (ret != (ssize_t)sz) 1184 if (ret != (ssize_t)sz)
1186 goto error; 1185 goto error;