Re: [util-linux] readprofile ignores the last element in /proc/profile

From: William Lee Irwin III
Date: Tue Aug 31 2004 - 19:44:21 EST


On Tue, Aug 31, 2004 at 12:25:59PM -0700, William Lee Irwin III wrote:
> > - if (read(state->fd, state->buf, end - start) == end - start) {
> > - for (off = 0; off < (end - start)/sizeof(uint32_t); ++off)
> > + if ((state->bufcnt = read(state->fd, state->buf, end - start)) >= 0) {
> > + for (off = 0; off < (state->bufcnt)/sizeof(uint32_t); ++off)
> > state->last->hits += state->buf[off];

Still wrong =( That needs to be strict inequality.


--- readprofile.c.orig2 2004-08-31 12:11:54.000000000 -0700
+++ readprofile.c 2004-08-31 12:44:25.000000000 -0700
@@ -65,6 +65,7 @@
int ret = 0;
long page_mask, start, end;
unsigned off;
+ ssize_t bufcnt;

if (!state->stext) {
if (!strcmp(state->sym, "_stext"))
@@ -101,8 +102,8 @@
exit(EXIT_FAILURE);
}
}
- if (read(state->fd, state->buf, end - start) == end - start) {
- for (off = 0; off < (end - start)/sizeof(uint32_t); ++off)
+ if ((bufcnt = read(state->fd, state->buf, end - start)) > 0) {
+ for (off = 0; off < bufcnt/sizeof(uint32_t); ++off)
state->last->hits += state->buf[off];
} else {
ret = 1;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/