summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-06-15 15:14:28 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-24 01:43:01 +0200
commitd1913e3916f35eb043e8d770839dd96c1379007d (patch)
tree1186ca9f5c96f24f2e9bf029613e9753202f31c7 /drivers
parentn_tty: Reset lnext if canonical mode changes (diff)
downloadlinux-d1913e3916f35eb043e8d770839dd96c1379007d.tar.xz
linux-d1913e3916f35eb043e8d770839dd96c1379007d.zip
n_tty: Fix type mismatches in receive_buf raw copy
Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/n_tty.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index e63beab3d1c3..fe1c39992c51 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1444,24 +1444,27 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
struct n_tty_data *ldata = tty->disc_data;
const unsigned char *p;
char *f, flags = TTY_NORMAL;
- int i;
char buf[64];
if (ldata->real_raw) {
- i = min(N_TTY_BUF_SIZE - read_cnt(ldata),
- N_TTY_BUF_SIZE - (ldata->read_head & (N_TTY_BUF_SIZE - 1)));
- i = min(count, i);
- memcpy(read_buf_addr(ldata, ldata->read_head), cp, i);
- ldata->read_head += i;
- cp += i;
- count -= i;
-
- i = min(N_TTY_BUF_SIZE - read_cnt(ldata),
- N_TTY_BUF_SIZE - (ldata->read_head & (N_TTY_BUF_SIZE - 1)));
- i = min(count, i);
- memcpy(read_buf_addr(ldata, ldata->read_head), cp, i);
- ldata->read_head += i;
+ size_t n, head;
+
+ head = ldata->read_head & (N_TTY_BUF_SIZE - 1);
+ n = N_TTY_BUF_SIZE - max(read_cnt(ldata), head);
+ n = min_t(size_t, count, n);
+ memcpy(read_buf_addr(ldata, head), cp, n);
+ ldata->read_head += n;
+ cp += n;
+ count -= n;
+
+ head = ldata->read_head & (N_TTY_BUF_SIZE - 1);
+ n = N_TTY_BUF_SIZE - max(read_cnt(ldata), head);
+ n = min_t(size_t, count, n);
+ memcpy(read_buf_addr(ldata, head), cp, n);
+ ldata->read_head += n;
} else {
+ int i;
+
for (i = count, p = cp, f = fp; i; i--, p++) {
if (f)
flags = *f++;