WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [patch] fix void* arithmetic

To: "Hollis Blanchard" <hollisb@xxxxxxxxxx>, "Ian Campbell" <Ian.Campbell@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [patch] fix void* arithmetic
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Wed, 30 Aug 2006 10:47:03 +0200
Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Wed, 30 Aug 2006 01:46:56 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <1156883088.29858.69.camel@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1156883088.29858.69.camel@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
>-#define ELFNOTE_NAME(_n_)   ((void*)(_n_) + sizeof(*(_n_)))
>-#define ELFNOTE_DESC(_n_)   (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3))
>-#define ELFNOTE_NEXT(_n_)   (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3))
>+#define ELFNOTE_NAME(_n_)   ((void*)((char*)(_n_) + sizeof(*(_n_))))
>+#define ELFNOTE_DESC(_n_)   (((void*)((char*)ELFNOTE_NAME(_n_) + 
>(((_n_)->namesz+3)&~3))))
>+#define ELFNOTE_NEXT(_n_)   (((void*)((char*)ELFNOTE_DESC(_n_) + 
>(((_n_)->descsz+3)&~3))))

This seems to complicate it a little too much, eg it would seem that this

#define ELFNOTE_NAME(_n_)   ((char *)(_n_) + sizeof(*(_n_)))
#define ELFNOTE_DESC(_n_)   (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3))
#define ELFNOTE_NEXT(_n_)   ((Elf_Note *)(ELFNOTE_DESC(_n_) + 
(((_n_)->descsz+3)&~3)))

would also do, and would even allow dropping an odd cast in the return statement
of xen_elfnote_string().

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>