aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar minus <minus@mnus.de>2015-08-21 16:53:11 +0200
committerLibravatar minus <minus@mnus.de>2015-08-21 16:53:11 +0200
commit8dfaf6265be52a582cc990f4332808d55063766f (patch)
treef31d5042629c27a6fbba0cb73f2b93433dce247a
parentMinor style fix (diff)
downloadsway-8dfaf6265be52a582cc990f4332808d55063766f.tar.gz
sway-8dfaf6265be52a582cc990f4332808d55063766f.tar.zst
sway-8dfaf6265be52a582cc990f4332808d55063766f.zip
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)
2project(sway C) 2project(sway C)
3set(CMAKE_C_FLAGS "-g") 3set(CMAKE_C_FLAGS "-g")
4set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/") 4set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/")
5add_definitions("-Wall") 5add_definitions("-Wall -Wextra -Wno-unused-parameter")
6set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake) 6set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake)
7 7
8find_package(XKBCommon REQUIRED) 8find_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 {
10 L_DEBUG = 3, 10 L_DEBUG = 3,
11} log_importance_t; 11} log_importance_t;
12 12
13void init_log(int verbosity); 13void init_log(log_importance_t verbosity);
14void sway_log_colors(int mode); 14void sway_log_colors(int mode);
15void sway_log(int verbosity, const char* format, ...) __attribute__((format(printf,2,3))); 15void sway_log(log_importance_t verbosity, const char* format, ...) __attribute__((format(printf,2,3)));
16void sway_log_errno(int verbosity, char* format, ...) __attribute__((format(printf,2,3))); 16void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3)));
17void sway_abort(const char* format, ...) __attribute__((format(printf,1,2))); 17void sway_abort(const char* format, ...) __attribute__((format(printf,1,2)));
18bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3))); 18bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3)));
19 19
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) {
106 // Check for a modifier key 106 // Check for a modifier key
107 int j; 107 int j;
108 bool is_mod = false; 108 bool is_mod = false;
109 for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) { 109 for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) {
110 if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { 110 if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
111 binding->modifiers |= modifiers[j].mod; 111 binding->modifiers |= modifiers[j].mod;
112 is_mod = true; 112 is_mod = true;
@@ -261,7 +261,7 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv)
261 261
262 // set modifer keys 262 // set modifer keys
263 for (i = 0; i < split->length; ++i) { 263 for (i = 0; i < split->length; ++i) {
264 for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) { 264 for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) {
265 if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { 265 if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
266 config->floating_mod |= modifiers[j].mod; 266 config->floating_mod |= modifiers[j].mod;
267 } 267 }
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() {
107 107
108 char *test = NULL; 108 char *test = NULL;
109 int i; 109 int i;
110 for (i = 0; i < sizeof(search_paths) / sizeof(char *); ++i) { 110 for (i = 0; i < (int)(sizeof(search_paths) / sizeof(char *)); ++i) {
111 test = strdup(search_paths[i]); 111 test = strdup(search_paths[i]);
112 test = do_var_replacement(temp_config, test); 112 test = do_var_replacement(temp_config, test);
113 sway_log(L_DEBUG, "Checking for config at %s", test); 113 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) {
121 } 121 }
122 122
123 int read_available; 123 int read_available;
124 ioctl(client_fd, FIONREAD, &read_available); 124 if (ioctl(client_fd, FIONREAD, &read_available) == -1) {
125 sway_log_errno(L_INFO, "Unable to read IPC socket buffer size");
126 ipc_client_disconnect(client);
127 return 0;
128 }
125 129
126 // Wait for the rest of the command payload in case the header has already been read 130 // Wait for the rest of the command payload in case the header has already been read
127 if (client->payload_length > 0) { 131 if (client->payload_length > 0) {
128 if (read_available >= client->payload_length) { 132 if ((uint32_t)read_available >= client->payload_length) {
129 ipc_client_handle_command(client); 133 ipc_client_handle_command(client);
130 } 134 }
131 else { 135 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
114 sway_log(L_DEBUG, "Moved window"); 114 sway_log(L_DEBUG, "Moved window");
115 swayc_t *temp; 115 swayc_t *temp;
116 int i; 116 int i;
117 uint clength = root->children->length; 117 int clength = root->children->length;
118 //Rearrange 118 //Rearrange
119 for (i = 0; i < clength; ++i) { 119 for (i = 0; i < clength; ++i) {
120 swayc_t *child = root->children->items[i]; 120 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 @@
10#include <string.h> 10#include <string.h>
11 11
12int colored = 1; 12int colored = 1;
13int v = 0; 13log_importance_t v = L_SILENT;
14 14
15static const char *verbosity_colors[] = { 15static const char *verbosity_colors[] = {
16 "", // L_SILENT 16 "", // L_SILENT
@@ -19,7 +19,7 @@ static const char *verbosity_colors[] = {
19 "\x1B[1;30m", // L_DEBUG 19 "\x1B[1;30m", // L_DEBUG
20}; 20};
21 21
22void init_log(int verbosity) { 22void init_log(log_importance_t verbosity) {
23 v = verbosity; 23 v = verbosity;
24 /* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */ 24 /* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */
25 int i; 25 int i;
@@ -46,9 +46,9 @@ void sway_abort(const char *format, ...) {
46 sway_terminate(); 46 sway_terminate();
47} 47}
48 48
49void sway_log(int verbosity, const char* format, ...) { 49void sway_log(log_importance_t verbosity, const char* format, ...) {
50 if (verbosity <= v) { 50 if (verbosity <= v) {
51 int c = verbosity; 51 unsigned int c = verbosity;
52 if (c > sizeof(verbosity_colors) / sizeof(char *)) { 52 if (c > sizeof(verbosity_colors) / sizeof(char *)) {
53 c = sizeof(verbosity_colors) / sizeof(char *) - 1; 53 c = sizeof(verbosity_colors) / sizeof(char *) - 1;
54 } 54 }
@@ -69,9 +69,9 @@ void sway_log(int verbosity, const char* format, ...) {
69 } 69 }
70} 70}
71 71
72void sway_log_errno(int verbosity, char* format, ...) { 72void sway_log_errno(log_importance_t verbosity, char* format, ...) {
73 if (verbosity <= v) { 73 if (verbosity <= v) {
74 int c = verbosity; 74 unsigned int c = verbosity;
75 if (c > sizeof(verbosity_colors) / sizeof(char *)) { 75 if (c > sizeof(verbosity_colors) / sizeof(char *)) {
76 c = sizeof(verbosity_colors) / sizeof(char *) - 1; 76 c = sizeof(verbosity_colors) / sizeof(char *) - 1;
77 } 77 }