diff options
| author | copilot-swe-agent[bot] <[email protected]> | 2026-06-09 06:57:24 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-06-09 06:57:24 +0000 |
| commit | 910af829633cbebb9f9ba045e5bc5f67a0879656 (patch) | |
| tree | 19ac77c981eab7d6b0c94de98bcedee1ca6e2ea7 /src | |
| parent | 546190e0c447643679b5846b6a1a8053871e0b5a (diff) | |
Polish console validation checks
Diffstat (limited to 'src')
| -rw-r--r-- | src/kservice.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/kservice.c b/src/kservice.c index b21d1cf99d..991072bc0d 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -170,6 +170,7 @@ static rt_err_t _console_get_open_flags(rt_device_t device, rt_uint16_t *oflag) { rt_err_t result; rt_uint16_t console_oflag = RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM; + rt_uint16_t access_mode; RT_ASSERT(device != RT_NULL); RT_ASSERT(oflag != RT_NULL); @@ -191,8 +192,9 @@ static rt_err_t _console_get_open_flags(rt_device_t device, rt_uint16_t *oflag) } } - if ((console_oflag & RT_DEVICE_OFLAG_RDWR) != RT_DEVICE_OFLAG_WRONLY && - (console_oflag & RT_DEVICE_OFLAG_RDWR) != RT_DEVICE_OFLAG_RDWR) + access_mode = console_oflag & RT_DEVICE_OFLAG_RDWR; + if (access_mode != RT_DEVICE_OFLAG_WRONLY && + access_mode != RT_DEVICE_OFLAG_RDWR) { LOG_W("refuse to set device %.*s as console: invalid open flags 0x%04x", RT_NAME_MAX, device->parent.name, console_oflag); |
