x86: properly define size_t
PATCH 1/1 x86: properly define size_t
Having it defined unilaterally as 'unsigned long' got me surprised recently when I tried to use the 'z' printk type modifier, as that is expected by the compiler to be used only on the type it knows size_t is supposed to have.
Generally the compiler provides a construct to do this, so use it when available.
xen/arch/x86/microcode_amd.c +4 -4
@@ -183,10 +183,10 @@ static int get_next_ucode_from_buffer_amstruct microcode_amd *mc_amd, const void *buf, size_t bufsize, - unsigned long *offset) + size_t *offset) { const uint8_t *bufp = buf; -unsigned long off; +size_t off;const struct mpbhdr *mpbuf; off = *offset;
@@ -203,7 +203,7 @@ static int get_next_ucode_from_buffer_amreturn -EINVAL ; } -printk (KERN_DEBUG "microcode: size %lu, block size %u, offset %ld\n" , +printk (KERN_DEBUG "microcode: size %zu, block size %u, offset %zu\n" , bufsize, mpbuf->len, off);if ( (off + mpbuf->len) > bufsize )
@@ -234,7 +234,7 @@ static int get_next_ucode_from_buffer_amstatic int install_equiv_cpu_table (struct microcode_amd *mc_amd,const uint32_t *buf, -unsigned long *offset) +size_t *offset) {const struct mpbhdr *mpbuf = (const struct mpbhdr *)&buf[1 ];
xen/include/asm-x86/types.h +6 -0
@@ -47,7 +47,13 @@ typedef unsigned long paddr_t;#define PRIpaddr "016lx"#endif +#if defined(__SIZE_TYPE__) +typedef __SIZE_TYPE__ size_t ; +#elif defined(__i386__) +typedef unsigned int size_t ; +#else typedef unsigned long size_t ; +#endif typedef char bool_t ;#define test_and_set_bool (b) xchg(&(b), 1)
x86: properly define size_t
Having it defined unilaterally as 'unsigned long' got me surprised recently when I tried to use the 'z' printk type modifier, as that is expected by the compiler to be used only on the type it knows size_t is supposed to have.
Generally the compiler provides a construct to do this, so use it when available.
xen/arch/x86/microcode_amd.c +4 -4
@@ -183,10 +183,10 @@ static int get_next_ucode_from_buffer_amstruct microcode_amd *mc_amd, const void *buf, size_t bufsize, - unsigned long *offset) + size_t *offset) { const uint8_t *bufp = buf; -unsigned long off; +size_t off;const struct mpbhdr *mpbuf; off = *offset;
@@ -203,7 +203,7 @@ static int get_next_ucode_from_buffer_amreturn -EINVAL ; } -printk (KERN_DEBUG "microcode: size %lu, block size %u, offset %ld\n" , +printk (KERN_DEBUG "microcode: size %zu, block size %u, offset %zu\n" , bufsize, mpbuf->len, off);if ( (off + mpbuf->len) > bufsize )
@@ -234,7 +234,7 @@ static int get_next_ucode_from_buffer_amstatic int install_equiv_cpu_table (struct microcode_amd *mc_amd,const uint32_t *buf, -unsigned long *offset) +size_t *offset) {const struct mpbhdr *mpbuf = (const struct mpbhdr *)&buf[1 ];
xen/include/asm-x86/types.h +6 -0
@@ -47,7 +47,13 @@ typedef unsigned long paddr_t;#define PRIpaddr "016lx"#endif +#if defined(__SIZE_TYPE__) +typedef __SIZE_TYPE__ size_t ; +#elif defined(__i386__) +typedef unsigned int size_t ; +#else typedef unsigned long size_t ; +#endif typedef char bool_t ;#define test_and_set_bool (b) xchg(&(b), 1)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 9 lines · Jan Beulich
Having it defined unilaterally as 'unsigned long' got me surprised recently when I tried to use the 'z' printk type modifier, as that is expected by the compiler to be used only on the type it knows
size_tis supposed to have.Generally the compiler provides a construct to do this, so use it when available.
Signed-off-by Jan Beulich<[email protected]>
Quoted 53 lines
xen/arch/x86/microcode_amd.c +4
-4@@ -183,10 +183,10 @@ static int get_next_ucode_from_buffer_amstruct microcode_amd *mc_amd, const void *buf, size_t bufsize, - unsigned long *offset) + size_t *offset) { const uint8_t *bufp = buf; -unsigned long off; +size_t off;const struct mpbhdr *mpbuf; off = *offset;@@ -203,7 +203,7 @@ static int get_next_ucode_from_buffer_amreturn -EINVAL ; } -printk (KERN_DEBUG "microcode: size %lu, block size %u, offset %ld\n" , +printk (KERN_DEBUG "microcode: size %zu, block size %u, offset %zu\n" , bufsize, mpbuf->len, off);if ( (off + mpbuf->len)> bufsize )@@ -234,7 +234,7 @@ static int get_next_ucode_from_buffer_amstatic int install_equiv_cpu_table (struct microcode_amd *mc_amd,const uint32_t *buf, -unsigned long *offset) +size_t *offset) {const struct mpbhdr *mpbuf = (const struct mpbhdr *)&buf[1 ];xen/include/asm-x86/types.h +6
-0@@ -47,7 +47,13 @@ typedef unsigned long paddr_t;#define PRIpaddr "016lx"#endif +#if defined(__SIZE_TYPE__) +typedef __SIZE_TYPE__ size_t ; +#elif defined(__i386__) +typedef unsigned int size_t ; +#else typedef unsigned long size_t ; +#endif typedef char bool_t ;#define test_and_set_bool (b) xchg(&(b), 1)
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
Quoted 9 lines · Jan Beulich
Having it defined unilaterally as 'unsigned long' got me surprised recently when I tried to use the 'z' printk type modifier, as that is expected by the compiler to be used only on the type it knows
size_tis supposed to have.Generally the compiler provides a construct to do this, so use it when available.
Signed-off-by Jan Beulich <[email protected]>
Quoted 56 lines
xen/arch/x86/microcode_amd.c +4
-4@@ -183,10 +183,10 @@ static int get_next_ucode_from_buffer_amstruct microcode_amd *mc_amd, const void *buf, size_t bufsize, - unsigned long *offset) + size_t *offset) { const uint8_t *bufp = buf; -unsigned long off; +size_t off;const struct mpbhdr *mpbuf; off = *offset;@@ -203,7 +203,7 @@ static int get_next_ucode_from_buffer_amreturn -EINVAL ; } -printk (KERN_DEBUG "microcode: size %lu, block size %u, offset %ld\n" , +printk (KERN_DEBUG "microcode: size %zu, block size %u, offset %zu\n" , bufsize, mpbuf->len, off);if ( (off + mpbuf->len) > bufsize )@@ -234,7 +234,7 @@ static int get_next_ucode_from_buffer_amstatic int install_equiv_cpu_table (struct microcode_amd *mc_amd,const uint32_t *buf, -unsigned long *offset) +size_t *offset) {const struct mpbhdr *mpbuf = (const struct mpbhdr *)&buf[1 ];xen/include/asm-x86/types.h +6
-0@@ -47,7 +47,13 @@ typedef unsigned long paddr_t;#define PRIpaddr "016lx"#endif +#if defined(__SIZE_TYPE__) +typedef __SIZE_TYPE__ size_t ; +#elif defined(__i386__) +typedef unsigned int size_t ; +#else typedef unsigned long size_t ; +#endif typedef char bool_t ;#define test_and_set_bool (b) xchg(&(b), 1)_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel