public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: Daryl Van Vorst <daryl@wideray.com>,
	"'BlueZ Mailing List'" <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] Alignment issue
Date: Sun, 23 Jan 2005 12:29:53 +0000	[thread overview]
Message-ID: <1106483393.6480.11.camel@localhost.localdomain> (raw)
In-Reply-To: <1106480346.9269.2.camel@pegasus>

On Sun, 2005-01-23 at 12:39 +0100, Marcel Holtmann wrote:
> your patch results in a lot of "initialization from incompatible
> pointer type" errors in the utils and hcidump. Basically in
> conjunction with functions like ntohs() etc. How do we fix this?

Mea culpa... forgot to cast when we deliberately use an integer pointer
as a pointer to our packed structure containing the same type of int. 
We might as well also switch sdp_internal.h to use the same macros while
we're at it.

Index: include/bluetooth.h
===================================================================
RCS file: /cvsroot/bluez/libs/include/bluetooth.h,v
retrieving revision 1.18
diff -u -r1.18 bluetooth.h
--- include/bluetooth.h	20 Jan 2005 18:14:19 -0000	1.18
+++ include/bluetooth.h	23 Jan 2005 12:26:50 -0000
@@ -92,7 +92,7 @@
 ({						\
 	struct __attribute__((packed)) {	\
 		typeof(*(ptr)) __v;		\
-	} *__p = (ptr);				\
+	}  *__p = (void *)(ptr);		\
 	__p->__v;				\
 })
 
@@ -100,7 +100,7 @@
 do {						\
 	struct __attribute__((packed)) {	\
 		typeof(*(ptr)) __v;		\
-	} *__p = (ptr);				\
+	}  *__p = (void *)(ptr);		\
 	__p->__v = (val);			\
 } while(0)
 
Index: include/sdp_internal.h
===================================================================
RCS file: /cvsroot/bluez/libs/include/sdp_internal.h,v
retrieving revision 1.3
diff -u -r1.3 sdp_internal.h
--- include/sdp_internal.h	3 Apr 2004 09:21:06 -0000	1.3
+++ include/sdp_internal.h	23 Jan 2005 12:26:50 -0000
@@ -55,102 +55,8 @@
 #define SDP_UUID_SEQ_SIZE 256
 #define SDP_MAX_ATTR_LEN 65535
 
-/* 
- * SDP unaligned access. 
- * based on linux/asm-<arch>/unaligned.h
- */
-#if defined(__i386__)
-
-#define sdp_get_unaligned(ptr) (*(ptr))
-#define sdp_put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
-
-#else
-
-struct __una_u64 { uint64_t x; } __attribute__((packed));
-struct __una_u32 { uint32_t x; } __attribute__((packed));
-struct __una_u16 { uint16_t x; } __attribute__((packed));
-
-static inline unsigned long long __uldq(const unsigned long *r11)
-{
-	const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
-	return ptr->x;
-}
-
-static inline unsigned long __uldl(const unsigned int * r11)
-{
-	const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
-	return ptr->x;
-}
-
-static inline unsigned long __uldw(const unsigned short * r11)
-{
-	const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
-	return ptr->x;
-}
-
-static inline void __ustq(unsigned long r5, unsigned long * r11)
-{
-	struct __una_u64 *ptr = (struct __una_u64 *) r11;
-	ptr->x = r5;
-}
-
-static inline void __ustl(unsigned long r5, unsigned int * r11)
-{
-	struct __una_u32 *ptr = (struct __una_u32 *) r11;
-	ptr->x = r5;
-}
-
-static inline void __ustw(unsigned long r5, unsigned short * r11)
-{
-	struct __una_u16 *ptr = (struct __una_u16 *) r11;
-	ptr->x = r5;
-}
-
-static inline unsigned long long __sdp_get_unaligned(const void *ptr, size_t size)
-{
-	unsigned long long val = 0;
-	switch (size) {
-	case 1:
-		val = *(const unsigned char *)ptr;
-		break;
-	case 2:
-		val = __uldw((const unsigned short *)ptr);
-		break;
-	case 4:
-		val = __uldl((const unsigned int *)ptr);
-		break;
-	case 8:
-		val = __uldq((const unsigned long *)ptr);
-		break;
-	}
-	return val;
-}
-
-static inline void __sdp_put_unaligned(unsigned long val, void *ptr, size_t size)
-{
-	switch (size) {
-	case 1:
-		*(unsigned char *)ptr = (val);
-		break;
-	case 2:
-		__ustw(val, (unsigned short *)ptr);
-		break;
-	case 4:
-		__ustl(val, (unsigned int *)ptr);
-		break;
-	case 8:
-		__ustq(val, (unsigned long *)ptr);
-		break;
-	}
-}
-
-#define sdp_get_unaligned(ptr) \
-	((__typeof__(*(ptr)))__sdp_get_unaligned((ptr), sizeof(*(ptr))))
-
-#define sdp_put_unaligned(x,ptr) \
-	__sdp_put_unaligned((unsigned long)(x), (ptr), sizeof(*(ptr)))
-
-#endif 
+#define sdp_get_unaligned bt_get_unaligned
+#define sdp_put_unaligned bt_put_unaligned
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 #define ntoh64(x) x



-- 
dwmw2

  reply	other threads:[~2005-01-23 12:29 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-10 18:38 [Bluez-devel] Alignment issue Daryl Van Vorst
2004-08-10 23:12 ` Marcel Holtmann
2004-08-11  9:20   ` Stephen Crane
2004-08-11 11:08     ` David Woodhouse
2004-08-11 19:33       ` Marcel Holtmann
2004-08-11  7:13 ` Marcel Holtmann
2004-08-11 16:44   ` Daryl Van Vorst
2004-08-11 19:31     ` Marcel Holtmann
2004-08-12  8:34       ` David Woodhouse
2004-08-12  9:27         ` Marcel Holtmann
2004-08-12 10:01           ` David Woodhouse
2004-08-12 10:22             ` Marcel Holtmann
2004-08-12 10:35               ` David Woodhouse
2004-08-12 11:00                 ` Marcel Holtmann
2004-08-12 11:33                   ` David Woodhouse
2004-08-12 11:49                     ` Marcel Holtmann
2004-08-12 12:02                       ` David Woodhouse
2004-08-12 12:29                         ` Marcel Holtmann
2004-08-12 13:36                         ` Marcel Holtmann
2004-08-13  8:07                           ` David Woodhouse
2004-08-13  9:05                             ` Marcel Holtmann
2004-08-13  9:14                               ` David Woodhouse
2004-08-13 11:52                               ` David Woodhouse
2004-08-13 12:40                                 ` Marcel Holtmann
2004-08-12 12:53               ` David Woodhouse
2004-08-13  9:58                 ` Marcel Holtmann
2004-08-13 10:56                   ` David Woodhouse
2004-08-12 10:10           ` Stephen Crane
2004-08-12 10:25             ` Marcel Holtmann
2005-01-20 14:30   ` David Woodhouse
2005-01-20 14:45     ` Marcel Holtmann
2005-01-20 14:59       ` David Woodhouse
2005-01-20 18:14         ` Marcel Holtmann
2005-01-21  8:26           ` David Woodhouse
2005-01-23  8:12             ` Marcel Holtmann
2005-01-23 11:39         ` Marcel Holtmann
2005-01-23 12:29           ` David Woodhouse [this message]
2005-01-23 14:40             ` Marcel Holtmann
2005-01-23 15:11               ` David Woodhouse
2005-01-23 15:22                 ` Marcel Holtmann
2005-01-23 23:16                   ` David Woodhouse
  -- strict thread matches above, loose matches on Subject: below --
2004-08-16  9:48 john smith
2004-08-16 10:15 ` Marcel Holtmann

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=1106483393.6480.11.camel@localhost.localdomain \
    --to=dwmw2@infradead.org \
    --cc=bluez-devel@lists.sourceforge.net \
    --cc=daryl@wideray.com \
    --cc=marcel@holtmann.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