smdev

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

commit 99546d0d6ea41eb2e85546b3617c33e2c18976b7
parent 6c9449b688d99e986de1ea9b72e2186f7920c655
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:
Msmdev.c | 2+-
Mutil.h | 1+
Mutil/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); + } +}