smdev

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

commit 49b838e3bf8d701ce13795a586ec463656c6c1cd
parent cae0a45a24450800ffa47e4b8cc2d617fca03106
Author: sin <sin@2f30.org>
Date:   Thu,  4 Sep 2014 15:53:36 +0100

Don't treat failure to rename an interface as fatal

Diffstat:
smdev.c | 2+-
util.h | 1+
util/eprintf.c | 19++++++++++++++++---
3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/smdev.c b/smdev.c @@ -428,7 +428,7 @@ ifrename(void) mac2names[i].name, sizeof(ifr.ifr_newname)); r = ioctl(sd, SIOCSIFNAME, &ifr); if (r < 0) - eprintf("SIOCSIFNAME:"); + weprintf("SIOCSIFNAME:"); } } freeifaddrs(ifas); diff --git a/util.h b/util.h @@ -11,6 +11,7 @@ int readuevent(const char *); int devtype(const char *); void enprintf(int, const char *, ...); void eprintf(const char *, ...); +void weprintf(const char *, ...); long estrtol(const char *, int); void recurse(const char *, void (*)(const char *)); #undef strlcpy diff --git a/util/eprintf.c b/util/eprintf.c @@ -33,14 +33,27 @@ enprintf(int status, const char *fmt, ...) void venprintf(int status, const char *fmt, va_list ap) { - /*fprintf(stderr, "%s: ", argv0);*/ - vfprintf(stderr, fmt, ap); - if(fmt[0] && fmt[strlen(fmt)-1] == ':') { + if (fmt[0] && fmt[strlen(fmt)-1] == ':') { fputc(' ', stderr); perror(NULL); } exit(status); } + +void +weprintf(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + if (fmt[0] && fmt[strlen(fmt)-1] == ':') { + fputc(' ', stderr); + perror(NULL); + } +}