Reflect failures in the exit status - smdev - suckless mdev
 (HTM) git clone git://git.suckless.org/smdev
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 4eeff1ea12111e7e1cdfeae0469da7198c8e6fbd
 (DIR) parent 49b838e3bf8d701ce13795a586ec463656c6c1cd
 (HTM) Author: sin <sin@2f30.org>
       Date:   Thu,  4 Sep 2014 15:55:50 +0100
       
       Reflect failures in the exit status
       
       Diffstat:
         M smdev.c                             |      15 ++++++++++-----
       
       1 file changed, 10 insertions(+), 5 deletions(-)
       ---
 (DIR) 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;
        }