OSDN Git Service

util: Remove redundant checks in the openpty()
authorAlexChen <alex.chen@huawei.com>
Mon, 2 Nov 2020 10:55:52 +0000 (18:55 +0800)
committerLaurent Vivier <laurent@vivier.eu>
Wed, 15 Sep 2021 12:42:48 +0000 (14:42 +0200)
commitfae0b0de71eb823dbe89f5784f3c3971485525cd
tree1bced10ebd431b2a21d3559e6e048abae7b23c02
parent831aaf24967a49d7750090b9dcfd6bf356f16529
util: Remove redundant checks in the openpty()

As we can see from the following function call stack, amaster and aslave
can not be NULL: char_pty_open() -> qemu_openpty_raw() -> openpty().
In addition, according to the API specification for openpty():
https://www.gnu.org/software/libc/manual/html_node/Pseudo_002dTerminal-Pairs.html,
the arguments name, termp and winp can all be NULL, but arguments amaster or aslave
can not be NULL.
Finally, amaster and aslave has been dereferenced at the beginning of the openpty().
So the checks on amaster and aslave in the openpty() are redundant. Remove them.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Alex Chen <alex.chen@huawei.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <5F9FE5B8.1030803@huawei.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
util/qemu-openpty.c