fs: read: do not call read op when count is 0
Some ops do not handle read with count = 0 correctly. They do not have to if this is catched in the upper layer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
d471e8549e
commit
6756cd2cb2
4
fs/fs.c
4
fs/fs.c
|
@ -503,6 +503,10 @@ int read(int fd, void *buf, size_t count)
|
||||||
|
|
||||||
if (f->pos + count > f->size)
|
if (f->pos + count > f->size)
|
||||||
count = f->size - f->pos;
|
count = f->size - f->pos;
|
||||||
|
|
||||||
|
if (!count)
|
||||||
|
return 0;
|
||||||
|
|
||||||
errno = fsdrv->read(dev, f, buf, count);
|
errno = fsdrv->read(dev, f, buf, count);
|
||||||
|
|
||||||
if (errno > 0)
|
if (errno > 0)
|
||||||
|
|
Loading…
Reference in New Issue