[hackers] [smdev] Reflect failures in the exit status || sin
commit 4eeff1ea12111e7e1cdfeae0469da7198c8e6fbd
Author: sin <sin_AT_2f30.org>
Date: Thu Sep 4 15:55:50 2014 +0100
Reflect failures in the exit status
diff --git a/smdev.c b/smdev.c
index 735f68d..a13950c 100644
--- a/smdev.c
+++ b/smdev.c
_AT_@ -61,7 +61,7 @@ static int createdev(struct event *ev);
static int doevent(struct event *ev);
static int craftev(char *sysfspath);
static void populatedev(const char *path);
-static void ifrename(void);
+static int ifrename(void);
static void
usage(void)
_AT_@ -95,9 +95,10 @@ main(int argc, char *argv[])
if (pregcache[i].cached)
regfree(&pregcache[i].preg);
- ifrename();
+ if (ifrename() < 0)
+ return EXIT_FAILURE;
- return 0;
+ return EXIT_SUCCESS;
}
static enum action
_AT_@ -396,7 +397,7 @@ populatedev(const char *path)
}
}
-static void
+static int
ifrename(void)
{
struct sockaddr_ll *sa;
_AT_@ -405,6 +406,7 @@ ifrename(void)
int sd;
int i;
int r;
+ int ok = 0;
sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (sd < 0)
_AT_@ -427,10 +429,13 @@ ifrename(void)
strlcpy(ifr.ifr_newname,
mac2names[i].name, sizeof(ifr.ifr_newname));
r = ioctl(sd, SIOCSIFNAME, &ifr);
- if (r < 0)
+ if (r < 0) {
weprintf("SIOCSIFNAME:");
+ ok = -1;
+ }
}
}
freeifaddrs(ifas);
close(sd);
+ return ok;
}
Received on Thu Sep 04 2014 - 16:56:47 CEST
This archive was generated by hypermail 2.3.0
: Thu Sep 04 2014 - 17:00:13 CEST