diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2020-01-22 19:58:36 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2020-01-22 19:58:36 +0000 |
commit | 7bf3903e3b985e0d242937e210896e12982a0c07 (patch) | |
tree | ffad06428c612f4e65445121e53f902d3127e621 /app | |
parent | 6bfaf4e0b6bafba31fc6476c7dbbd4ed706020b9 (diff) |
add, then use, xvasprintf, checking for appropriate return.
Diffstat (limited to 'app')
-rw-r--r-- | app/cwm/calmwm.h | 4 | ||||
-rw-r--r-- | app/cwm/screen.c | 7 | ||||
-rw-r--r-- | app/cwm/xmalloc.c | 17 |
3 files changed, 18 insertions, 10 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 864f4f4d2..008c16e11 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.371 2019/03/07 14:28:17 okan Exp $ + * $OpenBSD: calmwm.h,v 1.372 2020/01/22 19:58:35 okan Exp $ */ #ifndef _CALMWM_H_ @@ -598,5 +598,7 @@ char *xstrdup(const char *); int xasprintf(char **, const char *, ...) __attribute__((__format__ (printf, 2, 3))) __attribute__((__nonnull__ (2))); +int xvasprintf(char **, const char *, va_list) + __attribute__((__nonnull__ (2))); #endif /* _CALMWM_H_ */ diff --git a/app/cwm/screen.c b/app/cwm/screen.c index f86394f56..390dfe434 100644 --- a/app/cwm/screen.c +++ b/app/cwm/screen.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: screen.c,v 1.93 2019/03/08 20:33:30 okan Exp $ + * $OpenBSD: screen.c,v 1.94 2020/01/22 19:58:35 okan Exp $ */ #include <sys/types.h> @@ -275,15 +275,12 @@ void screen_prop_win_draw(struct screen_ctx *sc, const char *fmt, ...) { va_list ap; - int i; char *text; XGlyphInfo extents; va_start(ap, fmt); - i = vasprintf(&text, fmt, ap); + xvasprintf(&text, fmt, ap); va_end(ap); - if (i < 0 || text == NULL) - err(1, "vasprintf"); XftTextExtentsUtf8(X_Dpy, sc->xftfont, (const FcChar8*)text, strlen(text), &extents); diff --git a/app/cwm/xmalloc.c b/app/cwm/xmalloc.c index 21a65d711..ab5719c42 100644 --- a/app/cwm/xmalloc.c +++ b/app/cwm/xmalloc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xmalloc.c,v 1.15 2015/03/28 23:12:47 okan Exp $ + * $OpenBSD: xmalloc.c,v 1.16 2020/01/22 19:58:35 okan Exp $ */ #include <sys/types.h> @@ -91,11 +91,20 @@ xasprintf(char **ret, const char *fmt, ...) int i; va_start(ap, fmt); - i = vasprintf(ret, fmt, ap); + i = xvasprintf(ret, fmt, ap); va_end(ap); - if (i < 0 || *ret == NULL) - err(1, "asprintf"); + return(i); +} + +int +xvasprintf(char **ret, const char *fmt, va_list ap) +{ + int i; + + i = vasprintf(ret, fmt, ap); + if (i == -1) + err(1, "vasprintf"); return(i); } |