inode: do some more pipe maths in 16bit
authorAlan Cox <alan@linux.intel.com>
Thu, 14 Dec 2017 21:31:10 +0000 (21:31 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 14 Dec 2017 21:31:10 +0000 (21:31 +0000)
Kernel/inode.c

index 240c37c..3e904bd 100644 (file)
 
 /* 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;
 }