From 4fd4e619ec25970aa4319b7e988ad5b03599653d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 21 Mar 2011 23:54:13 +0100 Subject: [PATCH] little coding style fixes, fix compilation warning --- include/util.h | 13 ++++++++++--- src/main.c | 9 +++++---- src/util.c | 8 +++----- 3 files changed, 18 insertions(+), 12 deletions(-) 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__) -- 2.39.5