From: Gabriel-Andrew Pollo-Guilbert <gabriel.pollo-guilbert@efficios.com>
To: lttng-dev@lists.lttng.org
Subject: [PATCH lttng-ust] Fix: address GCC unaligned pointer warnings
Date: Fri, 26 Jul 2019 18:00:07 -0400 [thread overview]
Message-ID: <20190726220007.21275-1-gabriel.pollo-guilbert__26100.5516558484$1564178497$gmane$org@efficios.com> (raw)
The release of GCC 9 added the following warning:
-Waddress-of-packed-member, enabled by default, warns about an
unaligned pointer value from the address of a packed member of a
struct or union.
The warning is triggered in some place in LTTng-UST in cases where we
pass a pointer to get a result. Rather than passing the pointer directly
from the struct member, we get the result into a local storage, then
write it in the struct.
Signed-off-by: Gabriel-Andrew Pollo-Guilbert <gabriel.pollo-guilbert@efficios.com>
---
liblttng-ust-comm/lttng-ust-comm.c | 26 +++++++++++++++++++-------
liblttng-ust/lttng-ust-comm.c | 6 +++++-
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c
index 679b40e6..92d86d4e 100644
--- a/liblttng-ust-comm/lttng-ust-comm.c
+++ b/liblttng-ust-comm/lttng-ust-comm.c
@@ -853,12 +853,15 @@ static
int serialize_integer_type(struct ustctl_integer_type *uit,
const struct lttng_integer_type *lit)
{
+ int32_t encoding;
+
uit->size = lit->size;
uit->signedness = lit->signedness;
uit->reverse_byte_order = lit->reverse_byte_order;
uit->base = lit->base;
- if (serialize_string_encoding(&uit->encoding, lit->encoding))
+ if (serialize_string_encoding(&encoding, lit->encoding))
return -EINVAL;
+ uit->encoding = encoding;
uit->alignment = lit->alignment;
return 0;
}
@@ -880,9 +883,11 @@ int serialize_basic_type(struct lttng_session *session,
}
case atype_string:
{
- if (serialize_string_encoding(&ubt->string.encoding,
- lbt->string.encoding))
+ int32_t encoding;
+
+ if (serialize_string_encoding(&encoding, lbt->string.encoding))
return -EINVAL;
+ ubt->string.encoding = encoding;
*uatype = ustctl_atype_string;
break;
}
@@ -1007,13 +1012,15 @@ int serialize_one_field(struct lttng_session *session,
{
struct ustctl_field *uf = &fields[*iter_output];
struct ustctl_type *ut = &uf->type;
+ enum ustctl_abstract_types atype;
strncpy(uf->name, lf->name, LTTNG_UST_SYM_NAME_LEN);
uf->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
- ret = serialize_basic_type(session, &ut->atype, lt->atype,
+ ret = serialize_basic_type(session, &atype, lt->atype,
&ut->u.basic, <->u.basic);
if (ret)
return ret;
+ ut->atype = atype;
(*iter_output)++;
break;
}
@@ -1023,6 +1030,7 @@ int serialize_one_field(struct lttng_session *session,
struct ustctl_type *ut = &uf->type;
struct ustctl_basic_type *ubt;
const struct lttng_basic_type *lbt;
+ enum ustctl_abstract_types atype;
strncpy(uf->name, lf->name, LTTNG_UST_SYM_NAME_LEN);
uf->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
@@ -1030,10 +1038,11 @@ int serialize_one_field(struct lttng_session *session,
ubt = &ut->u.array.elem_type;
lbt = <->u.array.elem_type;
ut->u.array.length = lt->u.array.length;
- ret = serialize_basic_type(session, &ubt->atype, lbt->atype,
+ ret = serialize_basic_type(session, &atype, lbt->atype,
&ubt->u.basic, &lbt->u.basic);
if (ret)
return -EINVAL;
+ ubt->atype = atype;
ut->atype = ustctl_atype_array;
(*iter_output)++;
break;
@@ -1044,6 +1053,7 @@ int serialize_one_field(struct lttng_session *session,
struct ustctl_type *ut = &uf->type;
struct ustctl_basic_type *ubt;
const struct lttng_basic_type *lbt;
+ enum ustctl_abstract_types atype;
int ret;
strncpy(uf->name, lf->name, LTTNG_UST_SYM_NAME_LEN);
@@ -1051,16 +1061,18 @@ int serialize_one_field(struct lttng_session *session,
uf->type.atype = ustctl_atype_sequence;
ubt = &ut->u.sequence.length_type;
lbt = <->u.sequence.length_type;
- ret = serialize_basic_type(session, &ubt->atype, lbt->atype,
+ ret = serialize_basic_type(session, &atype, lbt->atype,
&ubt->u.basic, &lbt->u.basic);
if (ret)
return -EINVAL;
+ ubt->atype = atype;
ubt = &ut->u.sequence.elem_type;
lbt = <->u.sequence.elem_type;
- ret = serialize_basic_type(session, &ubt->atype, lbt->atype,
+ ret = serialize_basic_type(session, &atype, lbt->atype,
&ubt->u.basic, &lbt->u.basic);
if (ret)
return -EINVAL;
+ ubt->atype = atype;
ut->atype = ustctl_atype_sequence;
(*iter_output)++;
break;
diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c
index 61dbb41b..4bc350e2 100644
--- a/liblttng-ust/lttng-ust-comm.c
+++ b/liblttng-ust/lttng-ust-comm.c
@@ -875,14 +875,18 @@ int handle_message(struct sock_info *sock_info,
}
case LTTNG_UST_STREAM:
{
+ uint64_t memory_map_size;
+
/* Receive shm_fd, wakeup_fd */
ret = ustcomm_recv_stream_from_sessiond(sock,
- &lum->u.stream.len,
+ &memory_map_size,
&args.stream.shm_fd,
&args.stream.wakeup_fd);
if (ret) {
goto error;
}
+ lum->u.stream.len = memory_map_size;
+
if (ops->cmd)
ret = ops->cmd(lum->handle, lum->cmd,
(unsigned long) &lum->u,
--
2.22.0
next reply other threads:[~2019-07-26 22:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-26 22:00 Gabriel-Andrew Pollo-Guilbert [this message]
[not found] <20190726220007.21275-1-gabriel.pollo-guilbert@efficios.com>
2019-07-29 14:04 ` [PATCH lttng-ust] Fix: address GCC unaligned pointer warnings Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='20190726220007.21275-1-gabriel.pollo-guilbert__26100.5516558484$1564178497$gmane$org@efficios.com' \
--to=gabriel.pollo-guilbert@efficios.com \
--cc=lttng-dev@lists.lttng.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).