From: Alan Cox Date: Thu, 14 Dec 2017 21:31:10 +0000 (+0000) Subject: inode: do some more pipe maths in 16bit X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=889a17f1a1595774cc433a507eee06ae8c30a503;p=FUZIX.git inode: do some more pipe maths in 16bit --- diff --git a/Kernel/inode.c b/Kernel/inode.c index 240c37cd..3e904bd1 100644 --- a/Kernel/inode.c +++ b/Kernel/inode.c @@ -12,16 +12,17 @@ /* This assumes it's called once before we do I/O. That's wrong and we need to integrate this into the I/O loop, but when we do it changes - how we handle the psleep_flags bit */ + how we handle the psleep_flags bit. Pipes wrap before 64k so we can + shorten the check */ static uint8_t pipewait(inoptr ino, uint8_t flag) { - while(ino->c_node.i_size == 0) { + while((uint16_t)ino->c_node.i_size == 0) { if (ino->c_writers == 0 || psleep_flags(ino, flag)) { udata.u_count = 0; return 0; } } - udata.u_count = min(udata.u_count, ino->c_node.i_size); + udata.u_count = min(udata.u_count, (uint16_t)ino->c_node.i_size); return 1; }