diff mbox

Fix an endian bug in dbus properties.

Message ID CABOJwQYQQbVjYqFu-eQbpUhB8sFSrfgrywAdJ7GHDZEoOzu_RA@mail.gmail.com
State Accepted
Commit 3d0a843823a05b159eeaa47b59f9e4ec66e74a8f
Headers show

Commit Message

Sylvestre Gallon Jan. 3, 2012, 4:24 p.m. UTC
Hi,

Here is a patch to allow the use of Frequency and Signal DBus
properties for Big Endian targets.

I have tried NetworkManager on a powerpc target (BigEndian) and I find
that these properties does not work (always 100% for Signal and 0 for
Frequency). After some investigation I find that the bug come from an
endian problem in wpa_supplicant (u32 to u16 data loss).

Cheers,

Signed-off-by: Sylvestre Gallon <ccna.syl@gmail.com>
---
 wpa_supplicant/dbus/dbus_new_handlers.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)


@@ -2833,13 +2835,15 @@ dbus_bool_t
wpas_dbus_getter_bss_frequency(DBusMessageIter *iter,
 {
        struct bss_handler_args *args = user_data;
        struct wpa_bss *res;
+       u16 freq;

        res = get_bss_helper(args, error, __func__);
        if (!res)
                return FALSE;

+       freq = (u16)res->freq;
        return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT16,
-                                               &res->freq, error);
+                                               &freq, error);
 }

Comments

Dan Williams Jan. 4, 2012, 3:55 p.m. UTC | #1
On Tue, 2012-01-03 at 17:24 +0100, Sylvestre Gallon wrote:
> Hi,
> 
> Here is a patch to allow the use of Frequency and Signal DBus
> properties for Big Endian targets.
> 
> I have tried NetworkManager on a powerpc target (BigEndian) and I find
> that these properties does not work (always 100% for Signal and 0 for
> Frequency). After some investigation I find that the bug come from an
> endian problem in wpa_supplicant (u32 to u16 data loss).

Good catch.  Looks correct to me.

Dan

> Cheers,
> 
> Signed-off-by: Sylvestre Gallon <ccna.syl@gmail.com>
> ---
>  wpa_supplicant/dbus/dbus_new_handlers.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c
> b/wpa_supplicant/dbus/dbus_new_handlers.c
> index e3526d4..b03f1d7 100644
> --- a/wpa_supplicant/dbus/dbus_new_handlers.c
> +++ b/wpa_supplicant/dbus/dbus_new_handlers.c
> @@ -2809,13 +2809,15 @@ dbus_bool_t
> wpas_dbus_getter_bss_signal(DBusMessageIter *iter,
>  {
>         struct bss_handler_args *args = user_data;
>         struct wpa_bss *res;
> +       s16 level;
> 
>         res = get_bss_helper(args, error, __func__);
>         if (!res)
>                 return FALSE;
> 
> +       level = (s16)res->level;
>         return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT16,
> -                                               &res->level, error);
> +                                               &level, error);
>  }
> 
> 
> @@ -2833,13 +2835,15 @@ dbus_bool_t
> wpas_dbus_getter_bss_frequency(DBusMessageIter *iter,
>  {
>         struct bss_handler_args *args = user_data;
>         struct wpa_bss *res;
> +       u16 freq;
> 
>         res = get_bss_helper(args, error, __func__);
>         if (!res)
>                 return FALSE;
> 
> +       freq = (u16)res->freq;
>         return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT16,
> -                                               &res->freq, error);
> +                                               &freq, error);
>  }
> 
>
Sylvestre Gallon Jan. 25, 2012, 8:10 p.m. UTC | #2
On Wed, Jan 4, 2012 at 4:55 PM, Dan Williams <dcbw@redhat.com> wrote:
> On Tue, 2012-01-03 at 17:24 +0100, Sylvestre Gallon wrote:
>> Hi,
>>
>> Here is a patch to allow the use of Frequency and Signal DBus
>> properties for Big Endian targets.
>>
>> I have tried NetworkManager on a powerpc target (BigEndian) and I find
>> that these properties does not work (always 100% for Signal and 0 for
>> Frequency). After some investigation I find that the bug come from an
>> endian problem in wpa_supplicant (u32 to u16 data loss).
>
> Good catch.  Looks correct to me.
>
> Dan
>
>> Cheers,
>>
>> Signed-off-by: Sylvestre Gallon <ccna.syl@gmail.com>
>> ---
>>  wpa_supplicant/dbus/dbus_new_handlers.c |    8 ++++++--
>>  1 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c
>> b/wpa_supplicant/dbus/dbus_new_handlers.c
>> index e3526d4..b03f1d7 100644
>> --- a/wpa_supplicant/dbus/dbus_new_handlers.c
>> +++ b/wpa_supplicant/dbus/dbus_new_handlers.c
>> @@ -2809,13 +2809,15 @@ dbus_bool_t
>> wpas_dbus_getter_bss_signal(DBusMessageIter *iter,
>>  {
>>         struct bss_handler_args *args = user_data;
>>         struct wpa_bss *res;
>> +       s16 level;
>>
>>         res = get_bss_helper(args, error, __func__);
>>         if (!res)
>>                 return FALSE;
>>
>> +       level = (s16)res->level;
>>         return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT16,
>> -                                               &res->level, error);
>> +                                               &level, error);
>>  }
>>
>>
>> @@ -2833,13 +2835,15 @@ dbus_bool_t
>> wpas_dbus_getter_bss_frequency(DBusMessageIter *iter,
>>  {
>>         struct bss_handler_args *args = user_data;
>>         struct wpa_bss *res;
>> +       u16 freq;
>>
>>         res = get_bss_helper(args, error, __func__);
>>         if (!res)
>>                 return FALSE;
>>
>> +       freq = (u16)res->freq;
>>         return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT16,
>> -                                               &res->freq, error);
>> +                                               &freq, error);
>>  }
>>
>>
>
>


Hi,

I respawn this message, because it seems to be swallowed up by the
mail volume :)

This patch could be helpful for all powerpc and Big Endian users like me :)

Cheers,
Jouni Malinen Jan. 28, 2012, 4:01 p.m. UTC | #3
On Tue, Jan 03, 2012 at 05:24:14PM +0100, Sylvestre Gallon wrote:
> Here is a patch to allow the use of Frequency and Signal DBus
> properties for Big Endian targets.

Thanks, applied.
diff mbox

Patch

diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c
b/wpa_supplicant/dbus/dbus_new_handlers.c
index e3526d4..b03f1d7 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -2809,13 +2809,15 @@  dbus_bool_t
wpas_dbus_getter_bss_signal(DBusMessageIter *iter,
 {
        struct bss_handler_args *args = user_data;
        struct wpa_bss *res;
+       s16 level;

        res = get_bss_helper(args, error, __func__);
        if (!res)
                return FALSE;

+       level = (s16)res->level;
        return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT16,
-                                               &res->level, error);
+                                               &level, error);
 }