Skip to content
Snippets Groups Projects
Commit fae0b0de authored by Alex Chen's avatar Alex Chen Committed by Laurent Vivier
Browse files

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: default avatarEuler Robot <euler.robot@huawei.com>
Signed-off-by: default avatarAlex Chen <alex.chen@huawei.com>
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Message-Id: <5F9FE5B8.1030803@huawei.com>
Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
parent 831aaf24
No related branches found
No related tags found
No related merge requests found
......@@ -80,10 +80,9 @@ static int openpty(int *amaster, int *aslave, char *name,
(termp != NULL && tcgetattr(sfd, termp) < 0))
goto err;
if (amaster)
*amaster = mfd;
if (aslave)
*aslave = sfd;
*amaster = mfd;
*aslave = sfd;
if (winp)
ioctl(sfd, TIOCSWINSZ, winp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment