提交 21fb9a0b 编写于 作者: G Grissiom

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

Return early if the size is 0 as there is nothing to do.
上级 5f61b8ce
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册