mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
fixed #108 signed/unsigned comparison
This commit is contained in:
parent
7ecb55f218
commit
8dfaf6265b
7 changed files with 20 additions and 16 deletions
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.5)
|
||||||
project(sway C)
|
project(sway C)
|
||||||
set(CMAKE_C_FLAGS "-g")
|
set(CMAKE_C_FLAGS "-g")
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/")
|
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)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake)
|
||||||
|
|
||||||
find_package(XKBCommon REQUIRED)
|
find_package(XKBCommon REQUIRED)
|
||||||
|
|
|
@ -10,10 +10,10 @@ typedef enum {
|
||||||
L_DEBUG = 3,
|
L_DEBUG = 3,
|
||||||
} log_importance_t;
|
} log_importance_t;
|
||||||
|
|
||||||
void init_log(int verbosity);
|
void init_log(log_importance_t verbosity);
|
||||||
void sway_log_colors(int mode);
|
void sway_log_colors(int mode);
|
||||||
void sway_log(int verbosity, const 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(int verbosity, 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)));
|
void sway_abort(const char* format, ...) __attribute__((format(printf,1,2)));
|
||||||
bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3)));
|
bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3)));
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ static bool cmd_bindsym(struct sway_config *config, int argc, char **argv) {
|
||||||
// Check for a modifier key
|
// Check for a modifier key
|
||||||
int j;
|
int j;
|
||||||
bool is_mod = false;
|
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) {
|
if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
|
||||||
binding->modifiers |= modifiers[j].mod;
|
binding->modifiers |= modifiers[j].mod;
|
||||||
is_mod = true;
|
is_mod = true;
|
||||||
|
@ -261,7 +261,7 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv)
|
||||||
|
|
||||||
// set modifer keys
|
// set modifer keys
|
||||||
for (i = 0; i < split->length; ++i) {
|
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) {
|
if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
|
||||||
config->floating_mod |= modifiers[j].mod;
|
config->floating_mod |= modifiers[j].mod;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ static char *get_config_path() {
|
||||||
|
|
||||||
char *test = NULL;
|
char *test = NULL;
|
||||||
int i;
|
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 = strdup(search_paths[i]);
|
||||||
test = do_var_replacement(temp_config, test);
|
test = do_var_replacement(temp_config, test);
|
||||||
sway_log(L_DEBUG, "Checking for config at %s", test);
|
sway_log(L_DEBUG, "Checking for config at %s", test);
|
||||||
|
|
|
@ -121,11 +121,15 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_available;
|
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
|
// Wait for the rest of the command payload in case the header has already been read
|
||||||
if (client->payload_length > 0) {
|
if (client->payload_length > 0) {
|
||||||
if (read_available >= client->payload_length) {
|
if ((uint32_t)read_available >= client->payload_length) {
|
||||||
ipc_client_handle_command(client);
|
ipc_client_handle_command(client);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -114,7 +114,7 @@ void move_container(swayc_t *container,swayc_t* root,enum movement_direction dir
|
||||||
sway_log(L_DEBUG, "Moved window");
|
sway_log(L_DEBUG, "Moved window");
|
||||||
swayc_t *temp;
|
swayc_t *temp;
|
||||||
int i;
|
int i;
|
||||||
uint clength = root->children->length;
|
int clength = root->children->length;
|
||||||
//Rearrange
|
//Rearrange
|
||||||
for (i = 0; i < clength; ++i) {
|
for (i = 0; i < clength; ++i) {
|
||||||
swayc_t *child = root->children->items[i];
|
swayc_t *child = root->children->items[i];
|
||||||
|
|
12
sway/log.c
12
sway/log.c
|
@ -10,7 +10,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int colored = 1;
|
int colored = 1;
|
||||||
int v = 0;
|
log_importance_t v = L_SILENT;
|
||||||
|
|
||||||
static const char *verbosity_colors[] = {
|
static const char *verbosity_colors[] = {
|
||||||
"", // L_SILENT
|
"", // L_SILENT
|
||||||
|
@ -19,7 +19,7 @@ static const char *verbosity_colors[] = {
|
||||||
"\x1B[1;30m", // L_DEBUG
|
"\x1B[1;30m", // L_DEBUG
|
||||||
};
|
};
|
||||||
|
|
||||||
void init_log(int verbosity) {
|
void init_log(log_importance_t verbosity) {
|
||||||
v = verbosity;
|
v = verbosity;
|
||||||
/* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */
|
/* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */
|
||||||
int i;
|
int i;
|
||||||
|
@ -46,9 +46,9 @@ void sway_abort(const char *format, ...) {
|
||||||
sway_terminate();
|
sway_terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sway_log(int verbosity, const char* format, ...) {
|
void sway_log(log_importance_t verbosity, const char* format, ...) {
|
||||||
if (verbosity <= v) {
|
if (verbosity <= v) {
|
||||||
int c = verbosity;
|
unsigned int c = verbosity;
|
||||||
if (c > sizeof(verbosity_colors) / sizeof(char *)) {
|
if (c > sizeof(verbosity_colors) / sizeof(char *)) {
|
||||||
c = sizeof(verbosity_colors) / sizeof(char *) - 1;
|
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) {
|
if (verbosity <= v) {
|
||||||
int c = verbosity;
|
unsigned int c = verbosity;
|
||||||
if (c > sizeof(verbosity_colors) / sizeof(char *)) {
|
if (c > sizeof(verbosity_colors) / sizeof(char *)) {
|
||||||
c = sizeof(verbosity_colors) / sizeof(char *) - 1;
|
c = sizeof(verbosity_colors) / sizeof(char *) - 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue