Siarhei Siamashka wrote:
On Monday 05 January 2009 16:42:39 ext Christian Hoene wrote:
There are some parts that look a bit redundant/suspicious:
@@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t
count) while (count > 0) {
len = read(fd, buf + pos, count);
if (len <= 0)
- return len;
+ return pos > len ? pos : len;
count -= len;
pos += len;
Is the ternary '?' operator really needed here? In this part of code we
know for sure that 'len' is less or equal to zero, also 'pos ' is a
positive number or zero. Having just 'return pos' should be enough.
No. If read returns an error, the this error is passed to __read, too.
I mean that 'return pos > len ? pos : len' and 'return pos' expressions are
completely interexchangeable in this context.
Is it trying to say: return pos > 0 ? pos : len;
That's slightly functionally different, but makes it make sense to have
a ternary there :) Dodgy to ignore the error though (when pos > 0).
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html