|
|
|
|
|
|
|
|
|
|
xen-devel
Re: [Xen-devel] [patch] fix void* arithmetic
>-#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
|
|
|
|
|