From: Greger Wrang gregermw@gmail.com
The TEAM_OPTION_TYPE_BOOL is handled as a bool in the kernel and as a long in userspace. On a little endian architecture this is not a problem, but on a big endian architecture the result will not be correct.
Signed-off-by: Jonas Johansson jonasj76@gmail.com --- libteam/options.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libteam/options.c b/libteam/options.c index 79c98d7..2e95aa3 100644 --- a/libteam/options.c +++ b/libteam/options.c @@ -259,6 +259,7 @@ int get_options_handler(struct nl_msg *msg, void *arg) int nla_type; int opt_type; long tmp; + bool tmp_bool; void *data; int data_len = 0; int err; @@ -317,8 +318,8 @@ int get_options_handler(struct nl_msg *msg, void *arg) opt_type = TEAM_OPTION_TYPE_BINARY; break; case NLA_FLAG: - tmp = (long) (data_attr ? true : false); - data = &tmp; + tmp_bool = (bool) (data_attr ? true : false); + data = &tmp_bool; opt_type = TEAM_OPTION_TYPE_BOOL; break; case NLA_S32:
Fri, May 06, 2016 at 08:06:24AM CEST, jonasj76@gmail.com wrote:
From: Greger Wrang gregermw@gmail.com
The TEAM_OPTION_TYPE_BOOL is handled as a bool in the kernel and as a long in userspace. On a little endian architecture this is not a problem, but on a big endian architecture the result will not be correct.
Signed-off-by: Jonas Johansson jonasj76@gmail.com
There should be sign off of Greger as well. should I add it?
libteam/options.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libteam/options.c b/libteam/options.c index 79c98d7..2e95aa3 100644 --- a/libteam/options.c +++ b/libteam/options.c @@ -259,6 +259,7 @@ int get_options_handler(struct nl_msg *msg, void *arg) int nla_type; int opt_type; long tmp;
void *data; int data_len = 0; int err;bool tmp_bool;
@@ -317,8 +318,8 @@ int get_options_handler(struct nl_msg *msg, void *arg) opt_type = TEAM_OPTION_TYPE_BINARY; break; case NLA_FLAG:
tmp = (long) (data_attr ? true : false);
data = &tmp;
tmp_bool = (bool) (data_attr ? true : false);
you don't need "(bool)" here, just: tmp_bool = data_attr ? true : false;
case NLA_S32:data = &tmp_bool; opt_type = TEAM_OPTION_TYPE_BOOL; break;
-- 2.5.0
On Fri, May 06, 2016 at 08:36:44AM +0200, Jiri Pirko wrote:
Fri, May 06, 2016 at 08:06:24AM CEST, jonasj76@gmail.com wrote:
From: Greger Wrang gregermw@gmail.com
The TEAM_OPTION_TYPE_BOOL is handled as a bool in the kernel and as a long in userspace. On a little endian architecture this is not a problem, but on a big endian architecture the result will not be correct.
Signed-off-by: Jonas Johansson jonasj76@gmail.com
There should be sign off of Greger as well. should I add it?
Yes. Thanks.
libteam/options.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libteam/options.c b/libteam/options.c index 79c98d7..2e95aa3 100644 --- a/libteam/options.c +++ b/libteam/options.c @@ -259,6 +259,7 @@ int get_options_handler(struct nl_msg *msg, void *arg) int nla_type; int opt_type; long tmp;
void *data; int data_len = 0; int err;bool tmp_bool;
@@ -317,8 +318,8 @@ int get_options_handler(struct nl_msg *msg, void *arg) opt_type = TEAM_OPTION_TYPE_BINARY; break; case NLA_FLAG:
tmp = (long) (data_attr ? true : false);
data = &tmp;
tmp_bool = (bool) (data_attr ? true : false);
you don't need "(bool)" here, just: tmp_bool = data_attr ? true : false;
case NLA_S32:data = &tmp_bool; opt_type = TEAM_OPTION_TYPE_BOOL; break;
-- 2.5.0
Fri, May 06, 2016 at 09:27:43AM CEST, jonasj76@gmail.com wrote:
On Fri, May 06, 2016 at 08:36:44AM +0200, Jiri Pirko wrote:
Fri, May 06, 2016 at 08:06:24AM CEST, jonasj76@gmail.com wrote:
From: Greger Wrang gregermw@gmail.com
The TEAM_OPTION_TYPE_BOOL is handled as a bool in the kernel and as a long in userspace. On a little endian architecture this is not a problem, but on a big endian architecture the result will not be correct.
Signed-off-by: Jonas Johansson jonasj76@gmail.com
There should be sign off of Greger as well. should I add it?
Yes. Thanks.
libteam/options.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libteam/options.c b/libteam/options.c index 79c98d7..2e95aa3 100644 --- a/libteam/options.c +++ b/libteam/options.c @@ -259,6 +259,7 @@ int get_options_handler(struct nl_msg *msg, void *arg) int nla_type; int opt_type; long tmp;
void *data; int data_len = 0; int err;bool tmp_bool;
@@ -317,8 +318,8 @@ int get_options_handler(struct nl_msg *msg, void *arg) opt_type = TEAM_OPTION_TYPE_BINARY; break; case NLA_FLAG:
tmp = (long) (data_attr ? true : false);
data = &tmp;
tmp_bool = (bool) (data_attr ? true : false);
you don't need "(bool)" here, just: tmp_bool = data_attr ? true : false;
Please fix this, add the signed of and post v2. Thanks!
case NLA_S32:data = &tmp_bool; opt_type = TEAM_OPTION_TYPE_BOOL; break;
-- 2.5.0
libteam@lists.fedorahosted.org