This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][BZ #11432] next_line() in getsysstats.c skips lines dueto broken else block


Bugzilla 11432 describes a bug where next_line() in getsystats.c skips
lines due to a broken else block and therefore __get_nprocs() returns an
incorrect number of CPUs:

http://sourceware.org/bugzilla/show_bug.cgi?id=11432

In the bugzilla there's a sample /proc/stat file that can be bind
mounted over /proc/stat and a testcase that demonstrates the problem.

I came up with a corrected else block in the bugz and show how it's
redundant to what's already in next_line().

The following patch removes the else block as redundant.  The testcase
passes with this block removed.

Since this required a bind mounted /proc/stat file I'm not sure how a
test-suite check could be derived from it.

Ryan S. Arnold
IBM Linux Technology Center

2010-03-25  Ryan S. Arnold  <rsa@us.ibm.com>

	[BZ 11432]
	* sysdeps/unix/sysv/linux/getsysstats.c (next_line): Remove redundant and
	incorrect else block which overwrites current line with the partial next
	line.

--- glibc/sysdeps/unix/sysv/linux/getsysstats.c	2010-01-18 11:01:41.000000000 -0600
+++ glibc.new/sysdeps/unix/sysv/linux/getsysstats.c	2010-03-23 08:00:26.000000000 -0500
@@ -117,18 +117,6 @@
       if (nl == NULL)
 	nl = *re - 1;
     }
-  else if (nl + 5 >= *re)
-    {
-      memmove (buffer, nl, *re - nl);
-      *re = buffer + (*re - nl);
-      nl = *cp = buffer;
-
-      ssize_t n = read_not_cancel (fd, *re, buffer_end - *re);
-      if (n < 0)
-	return NULL;
-
-      *re += n;
-    }
 
   *cp = nl + 1;
   assert (*cp <= *re);



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]