linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] Fix wrong EOF compare
@ 2013-01-11  2:30 Minchan Kim
  2013-01-11  2:30 ` [PATCH v2 2/2] Enhance read_block of page_owner.c Minchan Kim
  2013-01-11 14:21 ` [PATCH v2 1/2] Fix wrong EOF compare Michal Nazarewicz
  0 siblings, 2 replies; 9+ messages in thread
From: Minchan Kim @ 2013-01-11  2:30 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Minchan Kim, Mel Gorman, Andy Whitcroft,
	Alexander Nyberg, Michal Nazarewicz, Randy Dunlap

The C standards allows the character type char to be singed or unsinged,
depending on the platform and compiler. Most of systems uses signed char,
but those based on PowerPC and ARM processors typically use unsigned char.
This can lead to unexpected results when the variable is used to compare
with EOF(-1). It happens my ARM system and this patch fixes it.

Cc: Mel Gorman <mgorman@suse.de>
Cc: Andy Whitcroft <apw@shadowen.org>
Cc: Alexander Nyberg <alexn@dsv.su.se>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 Documentation/page_owner.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/page_owner.c b/Documentation/page_owner.c
index f0156e1..43dde96 100644
--- a/Documentation/page_owner.c
+++ b/Documentation/page_owner.c
@@ -32,12 +32,13 @@ int read_block(char *buf, FILE *fin)
 {
 	int ret = 0;
 	int hit = 0;
+	int val;
 	char *curr = buf;
 
 	for (;;) {
-		*curr = getc(fin);
-		if (*curr == EOF) return -1;
-
+		val = getc(fin);
+		if (val == EOF) return -1;
+		*curr = val;
 		ret++;
 		if (*curr == '\n' && hit == 1)
 			return ret - 1;
-- 
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-01-31 18:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-11  2:30 [PATCH v2 1/2] Fix wrong EOF compare Minchan Kim
2013-01-11  2:30 ` [PATCH v2 2/2] Enhance read_block of page_owner.c Minchan Kim
2013-01-11 16:01   ` Michal Nazarewicz
2013-01-14  2:33     ` Minchan Kim
2013-01-14  8:27       ` Michal Nazarewicz
2013-01-11 14:21 ` [PATCH v2 1/2] Fix wrong EOF compare Michal Nazarewicz
2013-01-13 11:44   ` Rob Landley
2013-01-13 18:15     ` Randy Dunlap
2013-01-31 10:25       ` Rob Landley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).