Message ID | CABdb7372q-LntFhkDuurfWi2JakzZCM9xVxkEA=cqYMbKv_jGw@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 28 November 2017 at 08:18, Ladi Prosek <lprosek@redhat.com> wrote: > On Tue, Nov 21, 2017 at 3:07 PM, Mihail Abakumov > <mikhail.abakumov@ispras.ru> wrote: >> Added some helper features for windbgstub. > --- a/include/exec/windbgstub-utils.h > +++ b/include/exec/windbgstub-utils.h > @@ -32,7 +32,7 @@ > #define FMT_ERR "Error:%d" > > #define UINT8_P(ptr) ((uint8_t *) (ptr)) > -#define UINT32_P(ptr) ((uint32_t *) (ptr)) > +#define UINT32_P(ptr) ((uint32_t *) (size_t) (ptr)) > #define PTR(var) UINT8_P(&var) Hiding casts behind macros like this doesn't seem worthwhile to me anyway -- all it's doing is obscuring what's going on. And casting an arbitrary pointer to a uint32_t* is somewhat alarming -- the alignment requirements may not be met. Chances are high that code using that macro is not correct. thanks -- PMM
On 28/11/2017 09:34, Peter Maydell wrote: >> #define FMT_ERR "Error:%d" >> >> #define UINT8_P(ptr) ((uint8_t *) (ptr)) >> -#define UINT32_P(ptr) ((uint32_t *) (ptr)) >> +#define UINT32_P(ptr) ((uint32_t *) (size_t) (ptr)) >> #define PTR(var) UINT8_P(&var) > Hiding casts behind macros like this doesn't seem worthwhile > to me anyway -- all it's doing is obscuring what's going on. > And casting an arbitrary pointer to a uint32_t* is somewhat > alarming -- the alignment requirements may not be met. > Chances are high that code using that macro is not correct. And also, we already have ldb_p and ldl_*_p that do exactly what you want (and give you an opportunity to specify the intended endianness, probably little-endian). Thanks, Paolo
--- a/include/exec/windbgstub-utils.h +++ b/include/exec/windbgstub-utils.h @@ -32,7 +32,7 @@ #define FMT_ERR "Error:%d" #define UINT8_P(ptr) ((uint8_t *) (ptr)) -#define UINT32_P(ptr) ((uint32_t *) (ptr)) +#define UINT32_P(ptr) ((uint32_t *) (size_t) (ptr)) #define PTR(var) UINT8_P(&var)