From 21fb9a0bac9f5eaa57e41e60bab06e9f4dc216ae Mon Sep 17 00:00:00 2001 From: Grissiom Date: Fri, 25 Oct 2013 20:15:08 +0800 Subject: [PATCH] serial: do onthing if the size of read/write is zero Return early if the size is 0 as there is nothing to do. --- components/drivers/serial/serial.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 52e37f8cfe..5e7a8ec814 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -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;