kfifo: fix ternary sign extension bugs
[linux-2.6-microblaze.git] / samples / kfifo / bytestream-example.c
index c406f03..5a90aa5 100644 (file)
@@ -122,8 +122,10 @@ static ssize_t fifo_write(struct file *file, const char __user *buf,
        ret = kfifo_from_user(&test, buf, count, &copied);
 
        mutex_unlock(&write_lock);
+       if (ret)
+               return ret;
 
-       return ret ? ret : copied;
+       return copied;
 }
 
 static ssize_t fifo_read(struct file *file, char __user *buf,
@@ -138,8 +140,10 @@ static ssize_t fifo_read(struct file *file, char __user *buf,
        ret = kfifo_to_user(&test, buf, count, &copied);
 
        mutex_unlock(&read_lock);
+       if (ret)
+               return ret;
 
-       return ret ? ret : copied;
+       return copied;
 }
 
 static const struct proc_ops fifo_proc_ops = {