Merge pull request #110 from minus7/sign-comparsion-fix

fixed #108 signed/unsigned comparison
This commit is contained in:
Drew DeVault 2015-08-21 10:56:56 -04:00
commit 034358dbfd
7 changed files with 20 additions and 16 deletions

View file

@ -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)

View file

@ -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)));

View file

@ -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;
}

View file

@ -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);

View file

@ -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 {

View file

@ -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];

View file

@ -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;
}