[SeaBIOS] Wrong address returned by container _of macro

Kevin O'Connor kevin at koconnor.net
Fri Apr 6 14:57:53 CEST 2012


On Wed, Apr 04, 2012 at 04:04:54PM +0900, Daniel Castro wrote:
> Hello All,
> 
> I have a little problem, when I try to get my drive on boot (16bit) I
> am getting the wrong address:
> 
> This code:
> 	struct xendrive_s * xendrive =
> GLOBALFLAT2GLOBAL(container_of(GET_GLOBAL(op->drive_g), struct
> xendrive_s, drive));

op is on the stack, so one must not use GET_GLOBAL on it.  Also,
drive_g is already a "global", so GLOBALFLAT2GLOBAL must not be called
on it.  So, this should read:

struct xendrive_s * xendrive = container_of(op->drive_g, struct xendrive_s, drive))

If one looks at the other disk drivers, they'll see something similar
- for example ahci_cmd_data() has:

    struct ahci_port_s *port = container_of(
        op->drive_g, struct ahci_port_s, drive);

-Kevin



More information about the SeaBIOS mailing list