Skip to contentSkip to conversation

e820.c : why char* ? (2nd try)

DISCUSSION PUCCETTI Armand 2 participants 2 messages Jun 29, 2006

lore
Share & tools
lore
#0 lore raw

In function

sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)

of file e820.c, the last argument is treated as an integer, but when compiling with gcc it belongs to [-128,127].

Inside the body of that function, however, we use that argument as an int to fill up a table of a different size, namely:

static struct change_member *change_point [256]
static struct change_member change_point_list [256]
static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map) {
...
old_nr = *pnr_map;
...

for (i=0; i < 2*old_nr; i++) {
      change_point[i] = &change_point_list[i];

...
}

After the loop, change_point is not completely filled-up, as change_point [254] and change_point [255] are never filled nor used.

Is it voluntary that pnr_map gets typed and used like this?

Armand

#1 lore raw
Quoted 6 lines · PUCCETTI Armand

In function

sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)

of file e820.c, the last argument is treated as an integer, but when compiling with gcc it belongs to [-128,127].

This is not a Xen specific issue. On native the value comes from the BIOS and is a single byte, hence the type. Xen uses the same function.

I don't think it is possible for there to ever be more than 127 entries in an e820 map so other than potentially wasting a couple of entries in the tables I don't see a problem.

Ian.