Re: [PATCHv3 3/4] add 64 bit get_val support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marcel,

On Tue, Oct 18, 2011 at 08:53:51AM -0700, Marcel Holtmann wrote:
> > > > +	case 8:
> > > > +		return btohll(bt_get_unaligned((uint64_t *) ptr));
> > > >  	}
> > > >  	return 0;
> > > >  }
> > > 
> > > turning everything into a uint64 is a bit heavy. Just change this into
> > > broken down version. get_uint64, get_uint32, get_uint16 etc. Otherwise
> > > you keep casting yourself crazy.
> > 
> > Yes, casting does not look nice. What about if I keep everything AS IS and
> > just use btohll(bt_get_unaligned((ptr)) to access 64 bit value.
> 
> this does not make it more readable. Create helpers like get_uint64 for
> it.

Is this OK:

--- a/parser/parser.h
+++ b/parser/parser.h
...
+static inline uint64_t get_uint64(void *ptr)
+{
+       return btohll(bt_get_unaligned((uint64_t *) ptr));
+}
...

--- a/parser/l2cap.c
+++ b/parser/l2cap.c
...
        case 0x0003:
-               fc_mask = btohll(bt_get_unaligned((uint64_t *) ptr));
+               fc_mask = get_uint64(ptr);
...

Best regards 
Andrei Emeltchenko 
 
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux