[hackers] [wmii] X/\.c$/ , s/wmiiwm/wmii/g. Don't use printf (may malloc) on malloc failure.

From: Kris Maglione <jg_AT_suckless.org>
Date: Thu Mar 22 22:03:49 2007

changeset: 2025:00fb9e31716e
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Thu Mar 22 17:00:27 2007 -0400
summary: X/\.c$/ ,s/wmiiwm/wmii/g. Don't use printf (may malloc) on malloc failure.

diff -r d4782f998911 -r 00fb9e31716e area.c
--- a/area.c Thu Mar 22 16:23:10 2007 -0400
+++ b/area.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,5 +1,5 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * © 2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+ * ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 #include <assert.h>
@@ -82,7 +82,8 @@ destroy_area(Area *a) {
 
         v = a->view;
 
- assert(!a->frame && "wmiiwm: fatal, destroying non-empty area");
+ if(a->frame)
+ fatal("destroying non-empty area");
         if(v->revert == a)
                 v->revert = nil;
         for(c=client; c; c=c->next)
diff -r d4782f998911 -r 00fb9e31716e bar.c
--- a/bar.c Thu Mar 22 16:23:10 2007 -0400
+++ b/bar.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,5 +1,5 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * © 2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+ * ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 #include <math.h>
diff -r d4782f998911 -r 00fb9e31716e client.c
--- a/client.c Thu Mar 22 16:23:10 2007 -0400
+++ b/client.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,5 +1,5 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * © 2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+ * ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 #include <assert.h>
diff -r d4782f998911 -r 00fb9e31716e column.c
--- a/column.c Thu Mar 22 16:23:10 2007 -0400
+++ b/column.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,5 +1,5 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * © 2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+ * ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 #include <assert.h>
diff -r d4782f998911 -r 00fb9e31716e draw.c
--- a/draw.c Thu Mar 22 16:23:10 2007 -0400
+++ b/draw.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,4 +1,4 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
  * See LICENSE file for license details.
  */
 #include <stdio.h>
@@ -32,7 +32,7 @@ loadfont(Blitz *blitz, BlitzFont *font)
         font->set = XCreateFontSet(blitz->dpy, fontname, &missing, &n, &def);
         if(missing) {
                 while(n--)
- fprintf(stderr, "wmiiwm: missing fontset for '%s': %s\n",
+ fprintf(stderr, "wmii: missing fontset for '%s': %s\n",
                                         fontname, missing[n]);
                 XFreeStringList(missing);
         }
diff -r d4782f998911 -r 00fb9e31716e event.c
--- a/event.c Thu Mar 22 16:23:10 2007 -0400
+++ b/event.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,5 +1,5 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * © 2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+ * ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 #include <fcntl.h>
diff -r d4782f998911 -r 00fb9e31716e frame.c
--- a/frame.c Thu Mar 22 16:23:10 2007 -0400
+++ b/frame.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,4 +1,4 @@
-/* © 2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 #include <stdlib.h>
diff -r d4782f998911 -r 00fb9e31716e fs.c
--- a/fs.c Thu Mar 22 16:23:10 2007 -0400
+++ b/fs.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,4 +1,4 @@
-/* © 2006 Kris Maglione <fbsdaemon at gmail dot com>
+/* ©2006 Kris Maglione <fbsdaemon at gmail dot com>
  * See LICENSE file for license details.
  */
 #include <assert.h>
@@ -244,7 +244,7 @@ message_root(char *message)
         else if(!strncmp(message, "view ", 5))
                 select_view(&message[5]);
         else if(!strncmp(message, "selcolors ", 10)) {
- fprintf(stderr, "wmiiwm: warning: selcolors have been removed\n");
+ fprintf(stderr, "wmii: warning: selcolors have been removed\n");
                 return Ebadcmd;
         }
         else if(!strncmp(message, "focuscolors ", 12)) {
diff -r d4782f998911 -r 00fb9e31716e geom.c
--- a/geom.c Thu Mar 22 16:23:10 2007 -0400
+++ b/geom.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,4 +1,4 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
  * See LICENSE file for license details.
  */
 #include "wmii.h"
diff -r d4782f998911 -r 00fb9e31716e key.c
--- a/key.c Thu Mar 22 16:23:10 2007 -0400
+++ b/key.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,4 +1,4 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
  * See LICENSE file for license details.
  */
 #include <string.h>
diff -r d4782f998911 -r 00fb9e31716e main.c
--- a/main.c Thu Mar 22 16:23:10 2007 -0400
+++ b/main.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,5 +1,5 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * © 2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+ * ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 #include <X11/Xatom.h>
@@ -22,7 +22,7 @@
 #define nelem(ary) (sizeof(ary) / sizeof(*ary))
 
 static const char
- version[] = "wmiiwm - " VERSION ", ©2007 Kris Maglione\n";
+ version[] = "wmii - " VERSION ", ©2007 Kris Maglione\n";
 
 static int (*x_error_handler) (Display *, XErrorEvent *);
 static char *address, *ns_path;
@@ -33,7 +33,7 @@ static int sleeperfd, sock;
 
 static void
 usage() {
- fatal("usage: wmiiwm -a <address> [-r <wmiirc>] [-v]\n");
+ fatal("usage: wmii [-a <address>] [-r <wmiirc>] [-v]\n");
 }
 
 static void
@@ -281,7 +281,7 @@ wmii_error_handler(Display *dpy, XErrorE
                     && error->error_code == BadAccess))
                 return 0;
 
- fprintf(stderr, "wmiiwm: fatal error: Xrequest code=%d, Xerror code=%d\n",
+ fprintf(stderr, "wmii: fatal error: Xrequest code=%d, Xerror code=%d\n",
                         error->request_code, error->error_code);
         return x_error_handler(blz.dpy, error); /* calls exit() */
 }
diff -r d4782f998911 -r 00fb9e31716e mouse.c
--- a/mouse.c Thu Mar 22 16:23:10 2007 -0400
+++ b/mouse.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,4 +1,4 @@
-/* © 2006 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* ©2006 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 #include <stdlib.h>
diff -r d4782f998911 -r 00fb9e31716e rule.c
--- a/rule.c Thu Mar 22 16:23:10 2007 -0400
+++ b/rule.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,5 +1,5 @@
 /*
- * © 2006 Anselm R. Garbe <garbeam at gmail dot com>
+ * ©2006 Anselm R. Garbe <garbeam at gmail dot com>
  * See LICENSE file for license details.
  */
 
diff -r d4782f998911 -r 00fb9e31716e util.c
--- a/util.c Thu Mar 22 16:23:10 2007 -0400
+++ b/util.c Thu Mar 22 17:00:27 2007 -0400
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include "wmii.h"
 
 void
@@ -13,7 +14,7 @@ fatal(const char *fmt, ...) {
         int err;
 
         err = errno;
- fprintf(stderr, "wmiiwm: fatal: ");
+ fprintf(stderr, "wmii: fatal: ");
 
         va_start(ap, fmt);
         vfprintf(stderr, fmt, ap);
@@ -27,11 +28,34 @@ fatal(const char *fmt, ...) {
         exit(1);
 }
 
+/* Can't malloc */
+void
+mfatal(char *name, int size) {
+ const char
+ couldnot[] = "Could not ",
+ paren[] = "() ",
+ bytes[] = " bytes\n";
+ char sizestr[8];
+ int i;
+
+ i = sizeof(sizestr);
+ do {
+ sizestr[--i] = size&8;
+ size >>= 8;
+ } while(size > 0);
+
+ write(1, couldnot, sizeof(couldnot)-1);
+ write(1, name, strlen(name));
+ write(1, paren, sizeof(paren)-1);
+ write(1, sizestr+i, sizeof(sizestr)-i);
+ write(1, bytes, sizeof(bytes)-1);
+}
+
 void *
 emalloc(uint size) {
         void *ret = malloc(size);
         if(!ret)
- fatal("could not malloc() %d bytes", size);
+ mfatal("malloc", size);
         return ret;
 }
 
@@ -46,7 +70,7 @@ erealloc(void *ptr, uint size) {
 erealloc(void *ptr, uint size) {
         void *ret = realloc(ptr, size);
         if(!ret)
- fatal("fatal: could not realloc() %d bytes", size);
+ mfatal("realloc", size);
         return ret;
 }
 
@@ -54,7 +78,7 @@ estrdup(const char *str) {
 estrdup(const char *str) {
         void *ret = strdup(str);
         if(!ret)
- fatal("fatal: could not strdup() %u bytes", strlen(str));
+ mfatal("strdup", strlen(str));
         return ret;
 }
 
diff -r d4782f998911 -r 00fb9e31716e view.c
--- a/view.c Thu Mar 22 16:23:10 2007 -0400
+++ b/view.c Thu Mar 22 17:00:27 2007 -0400
@@ -1,5 +1,5 @@
-/* © 2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * © 2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+ * ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 
Received on Thu Mar 22 2007 - 22:03:49 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:21 UTC