[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/10] util: Remove redundant checks in the openpty()
From: |
Laurent Vivier |
Subject: |
[PULL 01/10] util: Remove redundant checks in the openpty() |
Date: |
Thu, 16 Sep 2021 16:10:17 +0200 |
From: AlexChen <alex.chen@huawei.com>
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 | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/util/qemu-openpty.c b/util/qemu-openpty.c
index eb17f5b0bcec..427f43a76973 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);
--
2.31.1
- [PULL 00/10] Trivial branch for 6.2 patches, Laurent Vivier, 2021/09/16
- [PULL 05/10] configure: add missing pc-bios/qemu_vga.ndrv symlink in build tree, Laurent Vivier, 2021/09/16
- [PULL 03/10] qdev: Complete qdev_init_gpio_out() documentation, Laurent Vivier, 2021/09/16
- [PULL 02/10] hw/i386/acpi-build: Fix a typo, Laurent Vivier, 2021/09/16
- [PULL 06/10] target/i386: spelling: occured=>occurred, mininum=>minimum, Laurent Vivier, 2021/09/16
- [PULL 04/10] spelling: sytem => system, Laurent Vivier, 2021/09/16
- [PULL 09/10] target/avr: Fix compiler errors (-Werror=enum-conversion), Laurent Vivier, 2021/09/16
- [PULL 01/10] util: Remove redundant checks in the openpty(),
Laurent Vivier <=
- [PULL 07/10] intel_iommu: Fix typo in comments, Laurent Vivier, 2021/09/16
- [PULL 08/10] hw/vfio: Fix typo in comments, Laurent Vivier, 2021/09/16
- [PULL 10/10] target/sparc: Make sparc_cpu_dump_state() static, Laurent Vivier, 2021/09/16
- Re: [PULL 00/10] Trivial branch for 6.2 patches, Peter Maydell, 2021/09/16