Hi Jukka,

> >>   gdhcp/client.c | 17 +++++++----------
> >>   gdhcp/common.c | 19 +++++++++++++++----
> >>   gdhcp/common.h | 16 ----------------
> >>   gdhcp/server.c |  8 ++++----
> >>   4 files changed, 26 insertions(+), 34 deletions(-)
> >>
> >> diff --git a/gdhcp/client.c b/gdhcp/client.c
> >> index cf04ced..801d652 100644
> >> --- a/gdhcp/client.c
> >> +++ b/gdhcp/client.c
> >> @@ -41,6 +41,7 @@
> >>            case OPTION_U32: {
> >> -                  uint32_t val_u32 = dhcp_get_unaligned(
> >> -                                          (uint32_t *) option);
> >> +                  uint32_t val_u32 = get_unaligned_be32(option);
> >>                    dest += sprintf(dest, type == OPTION_U32 ? "%lu" :
> >> -                                  "%ld", (unsigned long) ntohl(val_u32));
> >> +                                  "%ld", (unsigned long)val_u32);
> >
> > I do not get this unsigned long magic here? Why are we doing that
> > instead of just using %u?
> 
> Not my code so don't know why it is done like that. I will fix it.

that would be a good idea. Thanks.

> >
> >>                    break;
> >>            }
> >>            case OPTION_STRING:
> >> @@ -1924,8 +1922,7 @@ static gboolean listener_event(GIOChannel *channel, 
> >> GIOCondition condition,
> >>            dhcp_client->retry_times = 0;
> >>
> >>            option_u8 = dhcp_get_option(&packet, DHCP_SERVER_ID);
> >> -          dhcp_client->server_ip =
> >> -                          dhcp_get_unaligned((uint32_t *) option_u8);
> >> +          dhcp_client->server_ip = get_unaligned((uint32_t *)option_u8);
> >
> > Why is this used in native endian?
> 
> No need to convert to native endian as server_ip is sent back to wire 
> anyway.

So I get the feeling we should not be as smart as we pretend to be here.
Maybe converting service_ip into native endian and then converting it
back is a good idea.

I get the feeling that this optimization might eventually lead to hidden
bugs. And I prefer we uncover them instead handwaving around it.

Regards

Marcel


_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to