From 1974687e6b7a08d8383a4a5c75265d0ed3b8c5c9 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 10 Jul 2017 12:39:38 -0400 Subject: [PATCH] Port: handle 'size_t' / 'off_t' on Solaris MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Jérémie Galarneau --- cli/babeltrace.c | 6 +++--- lib/ctf-ir/field-types.c | 8 ++++---- lib/ctf-ir/fields.c | 6 +++--- plugins/ctf/common/notif-iter/notif-iter.c | 2 +- plugins/ctf/fs-src/data-stream-file.c | 4 ++-- plugins/ctf/fs-src/file.c | 2 +- tests/lib/test_graph_topo.c | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cli/babeltrace.c b/cli/babeltrace.c index ae8aacfc..a9d9f003 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -1421,8 +1421,8 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( 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; } @@ -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, - -1ULL, upstream_port_name, -1ULL)) { + SIZE_MAX, upstream_port_name, SIZE_MAX)) { continue; } diff --git a/lib/ctf-ir/field-types.c b/lib/ctf-ir/field-types.c index 95fdda9f..485c5e8f 100644 --- a/lib/ctf-ir/field-types.c +++ b/lib/ctf-ir/field-types.c @@ -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: " - "index=%" PRId64 ", " + "index=%zu, " "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: " - "index=%" PRId64 ", " + "index=%zu, " "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: " - "index=%" PRId64 ", " + "index=%zu, " "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: " - "index=%" PRId64 ", " + "index=%zu, " "field-ft-addr=%p, field-name=\"%s\"", i, field->type, g_quark_to_string(field->name)); diff --git a/lib/ctf-ir/fields.c b/lib/ctf-ir/fields.c index 9599b5bd..1633c54c 100644 --- a/lib/ctf-ir/fields.c +++ b/lib/ctf-ir/fields.c @@ -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, " - "index=%" PRId64, field, elem_field, i); + "index=%zu", field, elem_field, i); 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, " - "index=%" PRId64, field, member, i); + "index=%zu", field, member, i); 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, " - "index=%" PRId64, field, member, i); + "index=%zu", field, member, i); goto end; } } diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index 4ac971a9..33ac2495 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -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: " - "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; diff --git a/plugins/ctf/fs-src/data-stream-file.c b/plugins/ctf/fs-src/data-stream-file.c index 76b58da9..b49a32f6 100644 --- a/plugins/ctf/fs-src/data-stream-file.c +++ b/plugins/ctf/fs-src/data-stream-file.c @@ -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) { - 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->file->fp, ds_file->mmap_offset, + ds_file->file->fp, (intmax_t) ds_file->mmap_offset, strerror(errno)); goto error; } diff --git a/plugins/ctf/fs-src/file.c b/plugins/ctf/fs-src/file.c index 61c5a319..aa5b8ff6 100644 --- a/plugins/ctf/fs-src/file.c +++ b/plugins/ctf/fs-src/file.c @@ -101,7 +101,7 @@ int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode) } 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: diff --git a/tests/lib/test_graph_topo.c b/tests/lib/test_graph_topo.c index 2efac144..038ce3eb 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -280,7 +280,7 @@ size_t event_pos(struct event *event) } } - return -1ULL; + return SIZE_MAX; } static -- 2.34.1