serial: do onthing if the size of read/write is zero

Return early if the size is 0 as there is nothing to do.
This commit is contained in:
Grissiom 2013-10-25 20:15:08 +08:00
parent 5f61b8ce6c
commit 21fb9a0bac
1 changed files with 8 additions and 0 deletions

View File

@ -222,6 +222,10 @@ static rt_size_t rt_serial_read(struct rt_device *dev,
struct rt_serial_device *serial;
RT_ASSERT(dev != RT_NULL);
if (size == 0)
return 0;
serial = (struct rt_serial_device *)dev;
ptr = (rt_uint8_t *)buffer;
@ -272,6 +276,10 @@ static rt_size_t rt_serial_write(struct rt_device *dev,
struct rt_serial_device *serial;
RT_ASSERT(dev != RT_NULL);
if (size == 0)
return 0;
serial = (struct rt_serial_device *)dev;
ptr = (rt_uint8_t*)buffer;