lkml.org 
[lkml]   [2004]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [util-linux] readprofile ignores the last element in /proc/profile
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:05    [W:0.075 / U:0.164 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site