smdev

suckless mdev
git clone git://git.2f30.org/smdev.git
Log | Files | Refs | README | LICENSE

commit 23fa99a1eed2a0474d6796ca801933842f6185a8
parent 99546d0d6ea41eb2e85546b3617c33e2c18976b7
Author: sin <sin@2f30.org>
Date:   Thu,  4 Sep 2014 15:55:50 +0100

Reflect failures in the exit status

Diffstat:
smdev.c | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/smdev.c b/smdev.c @@ -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) @@ -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 @@ -396,7 +397,7 @@ populatedev(const char *path) } } -static void +static int ifrename(void) { struct sockaddr_ll *sa; @@ -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) @@ -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; }