Skip to contentSkip to conversation

fix tool pygrub build on x64

PATCH In review Jerone Young 2 participants 6 messages May 16, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix tool pygrub build on x64

This fixes tool pygrub to build on x86-64 systems. Currently gcc is saying there are incompatible pointer type passed into function ext2fs_file_read. The address of variable n is used in ext2fs_file_read which takes an "unsigned int *" as the 4th variable. "n" is currently declared as an "size_t" which is an "int". This declares n as an "unsigned int" instead of using type "size_t".

Signature · 4 lines
Jerone Young
IBM Linux Technology Center
[email protected]
512-838-1157 (T/L: 678-1157)
pygrub/src/fsys/ext2/ext2module.c renamed from pygrub/src/fsys/ext2/ext2module.c.orig +1 -1
@@ -55,7 +55,7 @@ static PyObject *
 ext2_file_read (Ext2File *file, PyObject *args)
 {
     int err, size = 0;
-    size_t n, total = 0;
+    unsigned int n, total = 0;
     PyObject * buffer = NULL;
 
     if (file->file == NULL) {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 6 lines · Jerone Young

This fixes tool pygrub to build on x86-64 systems. Currently gcc is saying there are incompatible pointer type passed into function ext2fs_file_read. The address of variable n is used in ext2fs_file_read which takes an "unsigned int *" as the 4th variable. "n" is currently declared as an "size_t" which is an "int". This declares n as an "unsigned int" instead of using type "size_t".

size_t is "unsigned long" not "int"

Signature · 1 line
Vincent Hanquez
#2 lore raw

Maybe on i386 but not x86-64.

Quoted 10 lines · Vincent Hanquez
Quoted 6 lines · Jerone Young

This fixes tool pygrub to build on x86-64 systems. Currently gcc is saying there are incompatible pointer type passed into function ext2fs_file_read. The address of variable n is used in ext2fs_file_read which takes an "unsigned int *" as the 4th variable. "n" is currently declared as an "size_t" which is an "int". This declares n as an "unsigned int" instead of using type "size_t".

size_t is "unsigned long" not "int"

Signature · 4 lines
Jerone Young
IBM Linux Technology Center
[email protected]
512-838-1157 (T/L: 678-1157)
#4 lore raw
In reply to Vincent Hanquez

Ok,
To better followup my findings you will see that size_t is of type
__kernel_size_t. On i386 in "asm-i386/posix_types.h" you have:
typedef unsigned int __kernel_size_t;

Where as on x86-64 you in "asm-x86_64/posix_types.h" you have:

typedef unsigned long __kernel_size_t;

I must have typed "unsigned int" by accident. Sorry. But the fix is still valid.

Where as in

Quoted 10 lines · Vincent Hanquez
Quoted 6 lines · Jerone Young

This fixes tool pygrub to build on x86-64 systems. Currently gcc is saying there are incompatible pointer type passed into function ext2fs_file_read. The address of variable n is used in ext2fs_file_read which takes an "unsigned int *" as the 4th variable. "n" is currently declared as an "size_t" which is an "int". This declares n as an "unsigned int" instead of using type "size_t".

size_t is "unsigned long" not "int"

Signature · 4 lines
Jerone Young
IBM Linux Technology Center
[email protected]
512-838-1157 (T/L: 678-1157)
#3 lore raw
In reply to Jerone Young
Quoted 1 line · Jerone Young

Maybe on i386 but not x86-64.

you can just try the following program and prove that size_t is an unsigned long:

int main(int argc, char **argv) { printf("%d\n", sizeof(size_t)); }

Signature · 1 line
Vincent Hanquez
#5 lore raw
In reply to Jerone Young
Quoted 2 lines · Jerone Young

I must have typed "unsigned int" by accident. Sorry. But the fix is still valid.

sure. I was just nit picking.

Signature · 1 line
Vincent Hanquez