little coding style fixes, fix compilation warning

This commit is contained in:
Michael Stapelberg 2011-03-21 23:54:13 +01:00
parent f0f7cb7478
commit 4fd4e619ec
3 changed files with 18 additions and 12 deletions

View File

@ -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); char *convert_utf8_to_ucs2(char *input, int *real_strlen);
/* /**
* This function resolves ~ in pathnames. * This function resolves ~ in pathnames.
* It may resolve wildcards in the first part of the path, but if no match * 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. * 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); char *resolve_tilde(const char *path);
/* /**
* Checks if the given path exists by calling stat(). * Checks if the given path exists by calling stat().
* *
*/ */
bool path_exists(const char *path); 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 * Restart i3 in-place
* appends -a to argument list to disable autostart * appends -a to argument list to disable autostart
* *

View File

@ -260,11 +260,12 @@ int main(int argc, char *argv[]) {
exit(0); exit(0);
} }
if (config.ipc_socket_path == NULL) { if (config.ipc_socket_path == NULL)
config.ipc_socket_path = getenv("I3SOCK"); config.ipc_socket_path = getenv("I3SOCK");
/* Fall back to a file name in /tmp/ based on the PID */
if (config.ipc_socket_path == NULL) if (config.ipc_socket_path == NULL)
config.ipc_socket_path = get_process_filename("i3-ipc-socket"); config.ipc_socket_path = get_process_filename("i3-ipc-socket");
}
uint32_t mask = XCB_CW_EVENT_MASK; uint32_t mask = XCB_CW_EVENT_MASK;
uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |

View File

@ -243,8 +243,7 @@ static char **append_argument(char **original, char *argument) {
* Returns the name of a temporary file with the specified prefix. * 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()); struct passwd *pw = getpwuid(getuid());
const char *username = pw ? pw->pw_name : "unknown"; const char *username = pw ? pw->pw_name : "unknown";
char *filename; char *filename;
@ -253,10 +252,9 @@ char *get_process_filename(const char *prefix)
perror("asprintf()"); perror("asprintf()");
return NULL; return NULL;
} }
else {
return filename; return filename;
} }
}
#define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__) #define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__)
#define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str)) #define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str))