From: Michael Stapelberg Date: Mon, 21 Mar 2011 22:54:13 +0000 (+0100) Subject: little coding style fixes, fix compilation warning X-Git-Tag: tree-pr3~88 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4fd4e619ec25970aa4319b7e988ad5b03599653d;p=i3%2Fi3 little coding style fixes, fix compilation warning --- diff --git a/include/util.h b/include/util.h index 514e10bd..610e701e 100644 --- a/include/util.h +++ b/include/util.h @@ -104,7 +104,7 @@ void check_error(xcb_connection_t *conn, xcb_void_cookie_t cookie, */ char *convert_utf8_to_ucs2(char *input, int *real_strlen); -/* +/** * This function resolves ~ in pathnames. * It may resolve wildcards in the first part of the path, but if no match * or multiple matches are found, it just returns a copy of path as given. @@ -112,13 +112,20 @@ char *convert_utf8_to_ucs2(char *input, int *real_strlen); */ char *resolve_tilde(const char *path); -/* +/** * Checks if the given path exists by calling stat(). * */ bool path_exists(const char *path); -/* + +/** + * Returns the name of a temporary file with the specified prefix. + * + */ +char *get_process_filename(const char *prefix); + +/** * Restart i3 in-place * appends -a to argument list to disable autostart * diff --git a/src/main.c b/src/main.c index 2bda27c5..a5a492e7 100644 --- a/src/main.c +++ b/src/main.c @@ -260,11 +260,12 @@ int main(int argc, char *argv[]) { exit(0); } - if (config.ipc_socket_path == NULL) { + if (config.ipc_socket_path == NULL) config.ipc_socket_path = getenv("I3SOCK"); - if (config.ipc_socket_path == NULL) - config.ipc_socket_path = get_process_filename("i3-ipc-socket"); - } + + /* Fall back to a file name in /tmp/ based on the PID */ + if (config.ipc_socket_path == NULL) + config.ipc_socket_path = get_process_filename("i3-ipc-socket"); uint32_t mask = XCB_CW_EVENT_MASK; uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | diff --git a/src/util.c b/src/util.c index 693027fa..2e4d9c23 100644 --- a/src/util.c +++ b/src/util.c @@ -243,8 +243,7 @@ static char **append_argument(char **original, char *argument) { * Returns the name of a temporary file with the specified prefix. * */ -char *get_process_filename(const char *prefix) -{ +char *get_process_filename(const char *prefix) { struct passwd *pw = getpwuid(getuid()); const char *username = pw ? pw->pw_name : "unknown"; char *filename; @@ -253,9 +252,8 @@ char *get_process_filename(const char *prefix) perror("asprintf()"); return NULL; } - else { - return filename; - } + + return filename; } #define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__)