From ea89767f2ce50078f6dc161189c4a15720ccee7f Mon Sep 17 00:00:00 2001 From: thread-liu Date: Fri, 30 Oct 2020 10:32:44 +0800 Subject: [PATCH] [update] check whether it's a same console device. --- src/kservice.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/kservice.c b/src/kservice.c index 7caf43ce2..0a74f0526 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1116,7 +1116,7 @@ RTM_EXPORT(rt_console_get_device); * * @param name the name of new console device * - * @return the old console device handler + * @return the old console device handler on successful, or RT_NULL on failure. */ rt_device_t rt_console_set_device(const char *name) { @@ -1127,6 +1127,10 @@ rt_device_t rt_console_set_device(const char *name) /* find new console device */ new_device = rt_device_find(name); + + /* check whether it's a same device */ + if (new_device == old_device) return RT_NULL; + if (new_device != RT_NULL) { if (_console_device != RT_NULL) -- GitLab