Port: handle 'size_t' / 'off_t' on Solaris
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 10 Jul 2017 16:39:38 +0000 (12:39 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 19 Jul 2017 18:26:27 +0000 (14:26 -0400)
The size of 'size_t' / 'off_t' vary on some platforms, use C99 portable
macros and print formats to handle them.

Print 'size_t' with '%zu' and use SIZE_MAX as max value.
Print 'off_t' casted to 'intmax_t' with '%jd'.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
cli/babeltrace.c
lib/ctf-ir/field-types.c
lib/ctf-ir/fields.c
plugins/ctf/common/notif-iter/notif-iter.c
plugins/ctf/fs-src/data-stream-file.c
plugins/ctf/fs-src/file.c
tests/lib/test_graph_topo.c

index ae8aacfc0322722689f5e0c79c4d1cb82f9fe375..a9d9f003d466feb3e49f93c6f515e2a9736475b6 100644 (file)
@@ -1421,8 +1421,8 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component(
                assert(upstream_port_name);
 
                if (!bt_common_star_glob_match(
                assert(upstream_port_name);
 
                if (!bt_common_star_glob_match(
-                               cfg_conn->downstream_port_glob->str, -1ULL,
-                               downstream_port_name, -1ULL)) {
+                               cfg_conn->downstream_port_glob->str, SIZE_MAX,
+                               downstream_port_name, SIZE_MAX)) {
                        bt_put(downstream_port);
                        continue;
                }
                        bt_put(downstream_port);
                        continue;
                }
@@ -1635,7 +1635,7 @@ int cmd_run_ctx_connect_upstream_port(struct cmd_run_ctx *ctx,
 
                if (!bt_common_star_glob_match(
                            cfg_conn->upstream_port_glob->str,
 
                if (!bt_common_star_glob_match(
                            cfg_conn->upstream_port_glob->str,
-                           -1ULL, upstream_port_name, -1ULL)) {
+                           SIZE_MAX, upstream_port_name, SIZE_MAX)) {
                        continue;
                }
 
                        continue;
                }
 
index 95fdda9f38eb2a07a5d6146984a05f5e0cb21fa5..485c5e8f3ea71e2f68d6b84f62559af01c5a57e2 100644 (file)
@@ -4067,7 +4067,7 @@ int bt_ctf_field_type_structure_serialize(struct bt_ctf_field_type *type,
                struct structure_field *field = structure->fields->pdata[i];
 
                BT_LOGD("Serializing structure field type's field metadata: "
                struct structure_field *field = structure->fields->pdata[i];
 
                BT_LOGD("Serializing structure field type's field metadata: "
-                       "index=%" PRId64 ", "
+                       "index=%zu, "
                        "field-ft-addr=%p, field-name=\"%s\"",
                        i, field, g_quark_to_string(field->name));
 
                        "field-ft-addr=%p, field-name=\"%s\"",
                        i, field, g_quark_to_string(field->name));
 
@@ -4081,7 +4081,7 @@ int bt_ctf_field_type_structure_serialize(struct bt_ctf_field_type *type,
                ret = bt_ctf_field_type_serialize(field->type, context);
                if (ret) {
                        BT_LOGW("Cannot serialize structure field type's field's metadata: "
                ret = bt_ctf_field_type_serialize(field->type, context);
                if (ret) {
                        BT_LOGW("Cannot serialize structure field type's field's metadata: "
-                               "index=%" PRId64 ", "
+                               "index=%zu, "
                                "field-ft-addr=%p, field-name=\"%s\"",
                                i, field->type,
                                g_quark_to_string(field->name));
                                "field-ft-addr=%p, field-name=\"%s\"",
                                i, field->type,
                                g_quark_to_string(field->name));
@@ -4135,7 +4135,7 @@ int bt_ctf_field_type_variant_serialize(struct bt_ctf_field_type *type,
                struct structure_field *field = variant->fields->pdata[i];
 
                BT_LOGD("Serializing variant field type's field metadata: "
                struct structure_field *field = variant->fields->pdata[i];
 
                BT_LOGD("Serializing variant field type's field metadata: "
-                       "index=%" PRId64 ", "
+                       "index=%zu, "
                        "field-ft-addr=%p, field-name=\"%s\"",
                        i, field, g_quark_to_string(field->name));
 
                        "field-ft-addr=%p, field-name=\"%s\"",
                        i, field, g_quark_to_string(field->name));
 
@@ -4151,7 +4151,7 @@ int bt_ctf_field_type_variant_serialize(struct bt_ctf_field_type *type,
                ret = bt_ctf_field_type_serialize(field->type, context);
                if (ret) {
                        BT_LOGW("Cannot serialize variant field type's field's metadata: "
                ret = bt_ctf_field_type_serialize(field->type, context);
                if (ret) {
                        BT_LOGW("Cannot serialize variant field type's field's metadata: "
-                               "index=%" PRId64 ", "
+                               "index=%zu, "
                                "field-ft-addr=%p, field-name=\"%s\"",
                                i, field->type,
                                g_quark_to_string(field->name));
                                "field-ft-addr=%p, field-name=\"%s\"",
                                i, field->type,
                                g_quark_to_string(field->name));
index 9599b5bd9d42d0fe055434f13007e3f9cdd44426..1633c54cb436613f4dbb864b12719307e75cabc2 100644 (file)
@@ -2250,7 +2250,7 @@ int bt_ctf_field_sequence_validate(struct bt_ctf_field *field)
                if (ret) {
                        BT_LOGW("Invalid sequence field's element field: "
                                "sequence-field-addr=%p, field-addr=%p, "
                if (ret) {
                        BT_LOGW("Invalid sequence field's element field: "
                                "sequence-field-addr=%p, field-addr=%p, "
-                               "index=%" PRId64, field, elem_field, i);
+                               "index=%zu", field, elem_field, i);
                        goto end;
                }
        }
                        goto end;
                }
        }
@@ -2388,7 +2388,7 @@ int bt_ctf_field_array_reset(struct bt_ctf_field *field)
                if (ret) {
                        BT_LOGE("Failed to reset array field's field: "
                                "array-field-addr=%p, field-addr=%p, "
                if (ret) {
                        BT_LOGE("Failed to reset array field's field: "
                                "array-field-addr=%p, field-addr=%p, "
-                               "index=%" PRId64, field, member, i);
+                               "index=%zu", field, member, i);
                        goto end;
                }
        }
                        goto end;
                }
        }
@@ -2425,7 +2425,7 @@ int bt_ctf_field_sequence_reset(struct bt_ctf_field *field)
                if (ret) {
                        BT_LOGE("Failed to reset sequence field's field: "
                                "sequence-field-addr=%p, field-addr=%p, "
                if (ret) {
                        BT_LOGE("Failed to reset sequence field's field: "
                                "sequence-field-addr=%p, field-addr=%p, "
-                               "index=%" PRId64, field, member, i);
+                               "index=%zu", field, member, i);
                        goto end;
                }
        }
                        goto end;
                }
        }
index 4ac971a9928eadcae7894772590571a8bc947dae..33ac24953ea56d89b0cd7f45c0e3f96677dd5b41 100644 (file)
@@ -1270,7 +1270,7 @@ enum bt_ctf_notif_iter_status read_event_header_begin_state(
                } else if (packet_at(notit) > notit->cur_content_size) {
                        /* That's not supposed to happen */
                        BT_LOGV("Before decoding event header field: cursor is passed the packet's content: "
                } else if (packet_at(notit) > notit->cur_content_size) {
                        /* That's not supposed to happen */
                        BT_LOGV("Before decoding event header field: cursor is passed the packet's content: "
-                               "notit-addr=%p, content-size=%zu, "
+                               "notit-addr=%p, content-size=%" PRId64 ", "
                                "cur=%zu", notit, notit->cur_content_size,
                                packet_at(notit));
                        status = BT_CTF_NOTIF_ITER_STATUS_ERROR;
                                "cur=%zu", notit, notit->cur_content_size,
                                packet_at(notit));
                        status = BT_CTF_NOTIF_ITER_STATUS_ERROR;
index 76b58da90d5aa527827b90b366d47cc4f3934bcd..b49a32f683e93bce72ba7c2072153a363553aa3f 100644 (file)
@@ -110,9 +110,9 @@ enum bt_ctf_notif_iter_medium_status ds_file_mmap_next(
                        PROT_READ, MAP_PRIVATE, fileno(ds_file->file->fp),
                        ds_file->mmap_offset);
        if (ds_file->mmap_addr == MAP_FAILED) {
                        PROT_READ, MAP_PRIVATE, fileno(ds_file->file->fp),
                        ds_file->mmap_offset);
        if (ds_file->mmap_addr == MAP_FAILED) {
-               BT_LOGE("Cannot memory-map address (size %zu) of file \"%s\" (%p) at offset %zu: %s",
+               BT_LOGE("Cannot memory-map address (size %zu) of file \"%s\" (%p) at offset %jd: %s",
                                ds_file->mmap_len, ds_file->file->path->str,
                                ds_file->mmap_len, ds_file->file->path->str,
-                               ds_file->file->fp, ds_file->mmap_offset,
+                               ds_file->file->fp, (intmax_t) ds_file->mmap_offset,
                                strerror(errno));
                goto error;
        }
                                strerror(errno));
                goto error;
        }
index 61c5a3195b0a0f383336e102d843645be2c48d4e..aa5b8ff68871f58252d2c07f56239cce1ea9ad5b 100644 (file)
@@ -101,7 +101,7 @@ int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode)
        }
 
        file->size = stat.st_size;
        }
 
        file->size = stat.st_size;
-       BT_LOGD("File is %zu bytes", file->size);
+       BT_LOGD("File is %jd bytes", (intmax_t) file->size);
        goto end;
 
 error:
        goto end;
 
 error:
index 2efac144433798df9a5a646717925203935685ac..038ce3eba6f8230467d43325efb130d972f65965 100644 (file)
@@ -280,7 +280,7 @@ size_t event_pos(struct event *event)
                }
        }
 
                }
        }
 
-       return -1ULL;
+       return SIZE_MAX;
 }
 
 static
 }
 
 static
This page took 0.033017 seconds and 4 git commands to generate.