diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ed6fc02f..1365a9aee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.5) project(sway C) set(CMAKE_C_FLAGS "-g") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/") -add_definitions("-Wall") +add_definitions("-Wall -Wextra -Wno-unused-parameter") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake) find_package(XKBCommon REQUIRED) diff --git a/include/log.h b/include/log.h index 47a83321d..3d77769c2 100644 --- a/include/log.h +++ b/include/log.h @@ -10,10 +10,10 @@ typedef enum { L_DEBUG = 3, } log_importance_t; -void init_log(int verbosity); +void init_log(log_importance_t verbosity); void sway_log_colors(int mode); -void sway_log(int verbosity, const char* format, ...) __attribute__((format(printf,2,3))); -void sway_log_errno(int verbosity, char* format, ...) __attribute__((format(printf,2,3))); +void sway_log(log_importance_t verbosity, const char* format, ...) __attribute__((format(printf,2,3))); +void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3))); void sway_abort(const char* format, ...) __attribute__((format(printf,1,2))); bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3))); diff --git a/sway/commands.c b/sway/commands.c index cb96703ed..e90a40a3a 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -106,7 +106,7 @@ static bool cmd_bindsym(struct sway_config *config, int argc, char **argv) { // Check for a modifier key int j; bool is_mod = false; - for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) { + for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) { if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { binding->modifiers |= modifiers[j].mod; is_mod = true; @@ -261,7 +261,7 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv) // set modifer keys for (i = 0; i < split->length; ++i) { - for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) { + for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) { if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { config->floating_mod |= modifiers[j].mod; } diff --git a/sway/config.c b/sway/config.c index 0afb02051..1ebd95ff8 100644 --- a/sway/config.c +++ b/sway/config.c @@ -107,7 +107,7 @@ static char *get_config_path() { char *test = NULL; int i; - for (i = 0; i < sizeof(search_paths) / sizeof(char *); ++i) { + for (i = 0; i < (int)(sizeof(search_paths) / sizeof(char *)); ++i) { test = strdup(search_paths[i]); test = do_var_replacement(temp_config, test); sway_log(L_DEBUG, "Checking for config at %s", test); diff --git a/sway/ipc.c b/sway/ipc.c index 63117defc..0b36d7582 100644 --- a/sway/ipc.c +++ b/sway/ipc.c @@ -121,11 +121,15 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) { } int read_available; - ioctl(client_fd, FIONREAD, &read_available); + if (ioctl(client_fd, FIONREAD, &read_available) == -1) { + sway_log_errno(L_INFO, "Unable to read IPC socket buffer size"); + ipc_client_disconnect(client); + return 0; + } // Wait for the rest of the command payload in case the header has already been read if (client->payload_length > 0) { - if (read_available >= client->payload_length) { + if ((uint32_t)read_available >= client->payload_length) { ipc_client_handle_command(client); } else { diff --git a/sway/layout.c b/sway/layout.c index 7eaa9ea4b..573c6f708 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -114,7 +114,7 @@ void move_container(swayc_t *container,swayc_t* root,enum movement_direction dir sway_log(L_DEBUG, "Moved window"); swayc_t *temp; int i; - uint clength = root->children->length; + int clength = root->children->length; //Rearrange for (i = 0; i < clength; ++i) { swayc_t *child = root->children->items[i]; diff --git a/sway/log.c b/sway/log.c index e0734109e..a1e89bade 100644 --- a/sway/log.c +++ b/sway/log.c @@ -10,7 +10,7 @@ #include int colored = 1; -int v = 0; +log_importance_t v = L_SILENT; static const char *verbosity_colors[] = { "", // L_SILENT @@ -19,7 +19,7 @@ static const char *verbosity_colors[] = { "\x1B[1;30m", // L_DEBUG }; -void init_log(int verbosity) { +void init_log(log_importance_t verbosity) { v = verbosity; /* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */ int i; @@ -46,9 +46,9 @@ void sway_abort(const char *format, ...) { sway_terminate(); } -void sway_log(int verbosity, const char* format, ...) { +void sway_log(log_importance_t verbosity, const char* format, ...) { if (verbosity <= v) { - int c = verbosity; + unsigned int c = verbosity; if (c > sizeof(verbosity_colors) / sizeof(char *)) { c = sizeof(verbosity_colors) / sizeof(char *) - 1; } @@ -69,9 +69,9 @@ void sway_log(int verbosity, const char* format, ...) { } } -void sway_log_errno(int verbosity, char* format, ...) { +void sway_log_errno(log_importance_t verbosity, char* format, ...) { if (verbosity <= v) { - int c = verbosity; + unsigned int c = verbosity; if (c > sizeof(verbosity_colors) / sizeof(char *)) { c = sizeof(verbosity_colors) / sizeof(char *) - 1; }