diff --git a/uicb.c b/uicb.c index f396e8f3e..779d2534a 100644 --- a/uicb.c +++ b/uicb.c @@ -106,18 +106,26 @@ run_uicb(char *cmd, awesome_config *awesomeconf) len = strlen(cmd); p = strtok(cmd, " "); - if (!p) + if (!p){ + warn("Ignoring malformed command\n"); return -1; + } screen = atoi(cmd); - if(screen >= get_screen_count(awesomeconf->display) || screen < 0) + if(screen >= get_screen_count(awesomeconf->display) || screen < 0){ + warn("Invalid screen specified: %i\n", screen); return -1; + } p = strtok(NULL, " "); - if (!p) + if (!p){ + warn("Ignoring malformed command.\n"); return -1; + } uicb = name_func_lookup(p, UicbList); - if (!uicb) + if (!uicb){ + warn("Unknown UICB function: %s.\n", p); return -1; + } if (p+strlen(p) < cmd+len) arg = p + strlen(p) + 1; diff --git a/util.c b/util.c index eca6e30c3..c04f0d1e5 100644 --- a/util.c +++ b/util.c @@ -50,6 +50,16 @@ eprint(const char *fmt, ...) exit(EXIT_FAILURE); } +void +warn(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "awesome: "); + vfprintf(stderr, fmt, ap); + va_end(ap); +} + double compute_new_value_from_arg(const char *arg, double current_value) { diff --git a/util.h b/util.h index daf88a541..2ce1df490 100644 --- a/util.h +++ b/util.h @@ -201,6 +201,7 @@ static inline ssize_t a_strcat(char *dst, ssize_t n, const char *src) void die(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2))); void eprint(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2))); double compute_new_value_from_arg(const char *, double); +void warn(const char *, ...) __attribute__ ((format(printf, 1, 2))); void *name_func_lookup(const char *, const NameFuncLink *); #endif