From: AlexChen Date: Mon, 2 Nov 2020 10:55:52 +0000 (+0800) Subject: util: Remove redundant checks in the openpty() X-Git-Tag: v6.2.0-rc0~97^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fae0b0de71eb823dbe89f5784f3c3971485525cd;p=thirdparty%2Fqemu.git 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 Signed-off-by: Alex Chen Reviewed-by: Peter Maydell Message-Id: <5F9FE5B8.1030803@huawei.com> Signed-off-by: Laurent Vivier --- diff --git a/util/qemu-openpty.c b/util/qemu-openpty.c index eb17f5b0bce..427f43a7697 100644 --- a/util/qemu-openpty.c +++ b/util/qemu-openpty.c @@ -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);