diff --git a/sway/ipc-server.c b/sway/ipc-server.c index b560b930..7d4b8e12 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -724,7 +724,7 @@ void ipc_client_handle_command(struct ipc_client *client) { } // parse requested event types - for (int i = 0; i < json_object_array_length(request); i++) { + for (size_t i = 0; i < (size_t)json_object_array_length(request); i++) { const char *event_type = json_object_get_string(json_object_array_get_idx(request, i)); if (strcmp(event_type, "workspace") == 0) { client->subscribed_events |= event_mask(IPC_EVENT_WORKSPACE); diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 93d1219c..6f686703 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -120,18 +120,17 @@ static void ipc_parse_config(struct config *config, const char *payload) { #endif // free previous outputs list - int i; - for (i = 0; i < config->outputs->length; ++i) { + for (int i = 0; i < config->outputs->length; ++i) { free(config->outputs->items[i]); } list_free(config->outputs); config->outputs = create_list(); if (outputs) { - int length = json_object_array_length(outputs); + size_t length = (size_t)json_object_array_length(outputs); json_object *output; const char *output_str; - for (i = 0; i < length; ++i) { + for (size_t i = 0; i < length; ++i) { output = json_object_array_get_idx(outputs, i); output_str = json_object_get_string(output); if (strcmp("*", output_str) == 0) { diff --git a/swaybar/status_line.c b/swaybar/status_line.c index cc324fdb..5c7b102e 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c @@ -70,8 +70,7 @@ static void parse_json(struct bar *bar, const char *text) { bar->status->block_line = create_list(); - int i; - for (i = 0; i < json_object_array_length(results); ++i) { + for (size_t i = 0; i < (size_t)json_object_array_length(results); ++i) { json_object *full_text, *short_text, *color, *min_width, *align, *urgent; json_object *name, *instance, *separator, *separator_block_width; json_object *background, *border, *border_top, *border_bottom; @@ -430,7 +429,7 @@ bool status_line_mouse_event(struct bar *bar, int x, int y, uint32_t button) { } // event example {"name":"capture","instance":"label","button":1,"x":3431,"y":18} - + struct json_object *event_json = json_object_new_object(); json_object_object_add(event_json, "name", json_object_new_string(clicked_block->name)); if (clicked_block->instance) { diff --git a/swaygrab/json.c b/swaygrab/json.c index 286085c3..5ea264a3 100644 --- a/swaygrab/json.c +++ b/swaygrab/json.c @@ -50,8 +50,7 @@ static json_object *get_focused_container_r(json_object *c) { } else { json_object *nodes, *node, *child; json_object_object_get_ex(c, "nodes", &nodes); - int i; - for (i = 0; i < json_object_array_length(nodes); i++) { + for (size_t i = 0; i < (size_t)json_object_array_length(nodes); i++) { node = json_object_array_get_idx(nodes, i); if ((child = get_focused_container_r(node))) { @@ -60,7 +59,7 @@ static json_object *get_focused_container_r(json_object *c) { } json_object_object_get_ex(c, "floating_nodes", &nodes); - for (i = 0; i < json_object_array_length(nodes); i++) { + for (size_t i = 0; i < (size_t)json_object_array_length(nodes); i++) { node = json_object_array_get_idx(nodes, i); if ((child = get_focused_container_r(node))) { @@ -81,9 +80,9 @@ char *get_focused_output() { json_object *outputs, *output, *name; json_object_object_get_ex(tree, "nodes", &outputs); if (!outputs) { - sway_abort("Unabled to get focused output. No nodes in tree."); + sway_abort("Unable to get focused output. No nodes in tree."); } - for (int i = 0; i < json_object_array_length(outputs); i++) { + for (size_t i = 0; i < (size_t)json_object_array_length(outputs); i++) { output = json_object_array_get_idx(outputs, i); if (get_focused_container_r(output)) { @@ -131,7 +130,7 @@ json_object *get_output_container(const char *output) { json_object *outputs, *json_output, *name; json_object_object_get_ex(tree, "nodes", &outputs); - for (int i = 0; i < json_object_array_length(outputs); i++) { + for (size_t i = 0; i < (size_t)json_object_array_length(outputs); i++) { json_output = json_object_array_get_idx(outputs, i); json_object_object_get_ex(json_output, "name", &name); diff --git a/swaylock/main.c b/swaylock/main.c index c2615951..3853c7ce 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -584,8 +584,8 @@ int main(int argc, char **argv) { for (i = 0; i < registry->outputs->length; ++i) { if (displays_paths[i * 2] != NULL) { - for (int j = 0;; ++j) { - if (j >= json_object_array_length(json_outputs)) { + for (size_t j = 0;; ++j) { + if (j >= (size_t)json_object_array_length(json_outputs)) { sway_log(L_ERROR, "%s is not an extant output", displays_paths[i * 2]); exit(EXIT_FAILURE); } diff --git a/swaymsg/main.c b/swaymsg/main.c index 2f9cfb14..fce98143 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -149,7 +149,7 @@ static void pretty_print_version(json_object *v) { static void pretty_print_clipboard(json_object *v) { if (success(v, true)) { if (json_object_is_type(v, json_type_array)) { - for (int i = 0; i < json_object_array_length(v); ++i) { + for (size_t i = 0; i < (size_t)json_object_array_length(v); ++i) { json_object *o = json_object_array_get_idx(v, i); printf("%s\n", json_object_get_string(o)); }