Use type casts to size_t for return types of json_object_array_length

This will future proof the code, as it seems
that the next release of json-c will return size_t array lengths
This commit is contained in:
Marius Orcsik 2017-10-27 15:19:15 +02:00
parent e39d663135
commit ccc83f7f76
No known key found for this signature in database
GPG key ID: 889CE8E4FB2D877A
6 changed files with 14 additions and 17 deletions

View file

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