public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: mita akinobu <amgta@yacht.ocn.ne.jp>
Cc: linux-kernel@vger.kernel.org, Andries Brouwer <aeb@cwi.nl>,
	Alessandro Rubini <rubini@ipvvis.unipv.it>
Subject: Re: [util-linux] readprofile ignores the last element in /proc/profile
Date: Tue, 31 Aug 2004 12:45:52 -0700	[thread overview]
Message-ID: <20040831194552.GQ5492@holomorphy.com> (raw)
In-Reply-To: <20040831192559.GN5492@holomorphy.com>

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;

  reply	other threads:[~2004-09-01  0:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-24 15:22 [util-linux] readprofile ignores the last element in /proc/profile mita akinobu
2004-08-29 16:22 ` William Lee Irwin III
2004-08-29 18:41   ` William Lee Irwin III
2004-08-29 19:26     ` Andries Brouwer
2004-08-29 21:23       ` William Lee Irwin III
2004-08-29 21:26         ` William Lee Irwin III
2004-08-29 23:25         ` Andries Brouwer
2004-08-30  0:26           ` William Lee Irwin III
2004-08-30 18:27   ` Paulo Marques
2004-08-30 20:48     ` William Lee Irwin III
2004-08-31 16:45   ` mita akinobu
2004-08-31 17:21     ` mita akinobu
2004-08-31 19:25     ` William Lee Irwin III
2004-08-31 19:45       ` William Lee Irwin III [this message]
2004-09-01 16:09         ` mita akinobu
2004-09-01 16:27           ` William Lee Irwin III

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=20040831194552.GQ5492@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=aeb@cwi.nl \
    --cc=amgta@yacht.ocn.ne.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rubini@ipvvis.unipv.it \
    /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