Use strerror() for more usefull errormessages
This commit is contained in:
parent
4c7f131fc5
commit
2aeea30cc7
|
@ -59,7 +59,7 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
|
||||||
buffer[rec-1] = '\0';
|
buffer[rec-1] = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ELOG("read() failed!\n");
|
ELOG("read() failed!: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
|
@ -111,7 +111,7 @@ void start_child(char *command) {
|
||||||
child_pid = fork();
|
child_pid = fork();
|
||||||
switch (child_pid) {
|
switch (child_pid) {
|
||||||
case -1:
|
case -1:
|
||||||
ELOG("Couldn't fork()\n");
|
ELOG("Couldn't fork(): %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
case 0:
|
case 0:
|
||||||
/* Child-process. Reroute stdout and start shell */
|
/* Child-process. Reroute stdout and start shell */
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <i3/ipc.h>
|
#include <i3/ipc.h>
|
||||||
|
@ -140,7 +141,7 @@ void got_data(struct ev_loop *loop, ev_io *watcher, int events) {
|
||||||
uint32_t header_len = strlen(I3_IPC_MAGIC) + sizeof(uint32_t)*2;
|
uint32_t header_len = strlen(I3_IPC_MAGIC) + sizeof(uint32_t)*2;
|
||||||
char *header = malloc(header_len);
|
char *header = malloc(header_len);
|
||||||
if (header == NULL) {
|
if (header == NULL) {
|
||||||
ELOG("Could not allocate memory!\n");
|
ELOG("Could not allocate memory: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +151,7 @@ void got_data(struct ev_loop *loop, ev_io *watcher, int events) {
|
||||||
while (rec < header_len) {
|
while (rec < header_len) {
|
||||||
int n = read(fd, header + rec, header_len - rec);
|
int n = read(fd, header + rec, header_len - rec);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
ELOG("read() failed!\n");
|
ELOG("read() failed: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
|
@ -193,7 +194,7 @@ void got_data(struct ev_loop *loop, ev_io *watcher, int events) {
|
||||||
while (rec < size) {
|
while (rec < size) {
|
||||||
int n = read(fd, buffer + rec, size - rec);
|
int n = read(fd, buffer + rec, size - rec);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
ELOG("read() failed!\n");
|
ELOG("read() failed: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
|
@ -234,7 +235,7 @@ int i3_send_msg(uint32_t type, const char *payload) {
|
||||||
* but we leave it for now */
|
* but we leave it for now */
|
||||||
char *buffer = malloc(to_write);
|
char *buffer = malloc(to_write);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
ELOG("Could not allocate memory\n");
|
ELOG("Could not allocate memory: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +255,7 @@ int i3_send_msg(uint32_t type, const char *payload) {
|
||||||
while (to_write > 0) {
|
while (to_write > 0) {
|
||||||
int n = write(i3_connection.fd, buffer + written, to_write);
|
int n = write(i3_connection.fd, buffer + written, to_write);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
ELOG("write() failed!\n");
|
ELOG("write() failed: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +277,7 @@ int init_connection(const char *socket_path) {
|
||||||
sock_path = socket_path;
|
sock_path = socket_path;
|
||||||
int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
||||||
if (sockfd == -1) {
|
if (sockfd == -1) {
|
||||||
ELOG("Could not create Socket!\n");
|
ELOG("Could not create Socket: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +286,7 @@ int init_connection(const char *socket_path) {
|
||||||
addr.sun_family = AF_LOCAL;
|
addr.sun_family = AF_LOCAL;
|
||||||
strcpy(addr.sun_path, sock_path);
|
strcpy(addr.sun_path, sock_path);
|
||||||
if (connect(sockfd, (const struct sockaddr*) &addr, sizeof(struct sockaddr_un)) < 0) {
|
if (connect(sockfd, (const struct sockaddr*) &addr, sizeof(struct sockaddr_un)) < 0) {
|
||||||
ELOG("Could not connect to i3!\n");
|
ELOG("Could not connect to i3: %s\n", strerror(errno));
|
||||||
reconnect();
|
reconnect();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ char *expand_path(char *path) {
|
||||||
}
|
}
|
||||||
char *result = strdup(globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : path);
|
char *result = strdup(globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : path);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
ELOG("malloc() failed\n");
|
ELOG("malloc() failed: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <yajl/yajl_parse.h>
|
#include <yajl/yajl_parse.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -184,7 +185,7 @@ static int workspaces_map_key_cb(void *params_, const unsigned char *keyVal, uns
|
||||||
|
|
||||||
params->cur_key = malloc(sizeof(unsigned char) * (keyLen + 1));
|
params->cur_key = malloc(sizeof(unsigned char) * (keyLen + 1));
|
||||||
if (params->cur_key == NULL) {
|
if (params->cur_key == NULL) {
|
||||||
ELOG("Could not allocate memory!\n");
|
ELOG("Could not allocate memory: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
strncpy(params->cur_key, (const char*) keyVal, keyLen);
|
strncpy(params->cur_key, (const char*) keyVal, keyLen);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <i3/ipc.h>
|
#include <i3/ipc.h>
|
||||||
#include <ev.h>
|
#include <ev.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
|
@ -493,7 +494,7 @@ void init_xcb(char *fontname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fcntl(ConnectionNumber(xkb_dpy), F_SETFD, FD_CLOEXEC) == -1) {
|
if (fcntl(ConnectionNumber(xkb_dpy), F_SETFD, FD_CLOEXEC) == -1) {
|
||||||
ELOG("Could not set FD_CLOEXEC on xkbdpy\n");
|
ELOG("Could not set FD_CLOEXEC on xkbdpy: %s\n", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue