aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminus <minus@mnus.de>2015-08-21 16:53:11 +0200
committerminus <minus@mnus.de>2015-08-21 16:53:11 +0200
commit8dfaf6265be52a582cc990f4332808d55063766f (patch)
treef31d5042629c27a6fbba0cb73f2b93433dce247a
parent7ecb55f218666ec5c30371eeb9e5982a487fdb4b (diff)
fixed #108 signed/unsigned comparison
-rw-r--r--CMakeLists.txt2
-rw-r--r--include/log.h6
-rw-r--r--sway/commands.c4
-rw-r--r--sway/config.c2
-rw-r--r--sway/ipc.c8
-rw-r--r--sway/layout.c2
-rw-r--r--sway/log.c12
7 files changed, 20 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ed6fc02..1365a9ae 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 47a83321..3d77769c 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 cb96703e..e90a40a3 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 0afb0205..1ebd95ff 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 63117def..0b36d758 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 7eaa9ea4..573c6f70 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 e0734109..a1e89bad 100644
--- a/sway/log.c
+++ b/sway/log.c
@@ -10,7 +10,7 @@
#include <string.h>
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;
}