From 203ee58aa296a52dd8c499458b9daf7ddf3b1f59 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Mon, 11 Oct 2021 00:02:03 +0200 Subject: [PATCH] arp: Preserve error if only the first ioctl fails --- Userland/Utilities/arp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Userland/Utilities/arp.cpp b/Userland/Utilities/arp.cpp index 970174c090..11837795ed 100644 --- a/Userland/Utilities/arp.cpp +++ b/Userland/Utilities/arp.cpp @@ -156,11 +156,14 @@ int main(int argc, char** argv) *(MACAddress*)&arp_req.arp_ha.sa_data[0] = hw_address.value(); - int rc; + int rc = 0; if (flag_set) rc = ioctl(fd, SIOCSARP, &arp_req); - if (flag_delete) - rc = ioctl(fd, SIOCDARP, &arp_req); + if (flag_delete) { + int rc2 = ioctl(fd, SIOCDARP, &arp_req); + if (!rc2) + rc = rc2; + } if (rc < 0) { perror("ioctl");