Use warn() instead of perror()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-03-19 13:11:13 +01:00
parent 93c75433f9
commit accf223bb1
9 changed files with 21 additions and 17 deletions

View File

@ -52,10 +52,10 @@ send_msg(char *msg, ssize_t msg_len)
switch (errno) switch (errno)
{ {
case ENOENT: case ENOENT:
warn("Can't write to %s\n", addr->sun_path); warn("can't write to %s\n", addr->sun_path);
break; break;
default: default:
perror("error sending datagram"); warn("error sending datagram: %s\n", strerror(errno));
} }
ret_value = errno; ret_value = errno;
} }

View File

@ -34,6 +34,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -138,10 +139,10 @@ config_parse(int screen, const char *confpatharg,
switch((ret = cfg_parse(cfg, confpath))) switch((ret = cfg_parse(cfg, confpath)))
{ {
case CFG_FILE_ERROR: case CFG_FILE_ERROR:
perror("awesome-message: parsing configuration file failed"); warn("parsing configuration file failed: %s\n", strerror(errno));
break; break;
case CFG_PARSE_ERROR: case CFG_PARSE_ERROR:
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath); cfg_error(cfg, "W: awesome: parsing configuration file %s failed.\n", confpath);
break; break;
} }

View File

@ -25,6 +25,7 @@
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -78,7 +79,7 @@ config_parse(int screen, const char *confpatharg)
switch((ret = cfg_parse(cfg, confpath))) switch((ret = cfg_parse(cfg, confpath)))
{ {
case CFG_FILE_ERROR: case CFG_FILE_ERROR:
perror("awesome-message: parsing configuration file failed"); warn("parsing configuration file failed: %s\n", strerror(errno));
break; break;
case CFG_PARSE_ERROR: case CFG_PARSE_ERROR:
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath); cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);

View File

@ -394,7 +394,7 @@ main(int argc, char *argv[])
switch (r = recv(csfd, buf, sizeof(buf)-1, MSG_TRUNC)) switch (r = recv(csfd, buf, sizeof(buf)-1, MSG_TRUNC))
{ {
case -1: case -1:
perror("awesome: error reading UNIX domain socket"); warn("error reading UNIX domain socket: %s\n", strerror(errno));
csfd = -1; csfd = -1;
break; break;
case 0: case 0:
@ -436,9 +436,9 @@ main(int argc, char *argv[])
if(csfd > 0 && close(csfd)) if(csfd > 0 && close(csfd))
perror("error closing UNIX domain socket"); warn("error closing UNIX domain socket: %s\n", strerror(errno));
if(unlink(addr->sun_path)) if(unlink(addr->sun_path))
perror("error unlinking UNIX domain socket"); warn("error unlinking UNIX domain socket: %s\n", strerror(errno));
p_delete(&addr); p_delete(&addr);
/* remap all clients since some WM won't handle them otherwise */ /* remap all clients since some WM won't handle them otherwise */

View File

@ -539,7 +539,7 @@ config_check(const char *confpatharg)
switch((ret = cfg_parse(cfg, confpath))) switch((ret = cfg_parse(cfg, confpath)))
{ {
case CFG_FILE_ERROR: case CFG_FILE_ERROR:
perror("awesome: parsing configuration file failed"); warn("parsing configuration file failed: %s\n", strerror(errno));
break; break;
case CFG_PARSE_ERROR: case CFG_PARSE_ERROR:
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath); cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);

View File

@ -55,7 +55,7 @@ draw_iso2utf8(char *iso)
warn("unable to convert text from %s to UTF-8, not available", warn("unable to convert text from %s to UTF-8, not available",
nl_langinfo(CODESET)); nl_langinfo(CODESET));
else else
perror("awesome: unable to convert text"); warn("unable to convert text: %s\n", strerror(errno));
return NULL; return NULL;
} }
@ -65,7 +65,7 @@ draw_iso2utf8(char *iso)
if(iconv(iso2utf8, &iso, &len, &utf8, &utf8len) == (size_t) -1) if(iconv(iso2utf8, &iso, &len, &utf8, &utf8len) == (size_t) -1)
{ {
perror("awesome: text conversion failed"); warn("text conversion failed: %s\n", strerror(errno));
p_delete(&utf8p); p_delete(&utf8p);
return NULL; return NULL;
} }

View File

@ -21,6 +21,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <errno.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
@ -88,7 +89,7 @@ get_client_socket(void)
csfd = socket(AF_UNIX, SOCK_DGRAM, 0); csfd = socket(AF_UNIX, SOCK_DGRAM, 0);
if(csfd < 0) if(csfd < 0)
perror("error opening UNIX domain socket"); warn("error opening UNIX domain socket: %s\n", strerror(errno));
return csfd; return csfd;
} }

View File

@ -19,6 +19,7 @@
* *
*/ */
#include <errno.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include "config.h" #include "config.h"
@ -479,12 +480,12 @@ config_parse(const char *confpatharg)
switch(ret) switch(ret)
{ {
case CFG_FILE_ERROR: case CFG_FILE_ERROR:
perror("awesome: parsing configuration file failed"); warn("parsing configuration file failed: %s\n", strerror(errno));
if(!(defconfig = fopen(confpath, "w"))) if(!(defconfig = fopen(confpath, "w")))
perror("awesome: unable to create default configuration file"); warn("unable to create default configuration file: %s\n", strerror(errno));
break; break;
case CFG_PARSE_ERROR: case CFG_PARSE_ERROR:
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath); cfg_error(cfg, "W: awesome: parsing configuration file %s failed.\n", confpath);
break; break;
} }

4
uicb.c
View File

@ -29,6 +29,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
#include "awesome.h" #include "awesome.h"
#include "tag.h" #include "tag.h"
@ -117,8 +118,7 @@ uicb_spawn(int screen, char *arg)
close(ConnectionNumber(globalconf.display)); close(ConnectionNumber(globalconf.display));
setsid(); setsid();
execl(shell, shell, "-c", arg, NULL); execl(shell, shell, "-c", arg, NULL);
warn("execl '%s -c %s'", shell, arg); warn("execl '%s -c %s' failed: %s\n", shell, arg, strerror(errno));
perror(" failed");
} }
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }