From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: u-boot@lists.denx.de, agraf@csgraf.de
Subject: Re: [PATCH] efi_driver: fix a wrong cast
Date: Mon, 27 Sep 2021 17:53:26 +0900 [thread overview]
Message-ID: <20210927085326.GA54445@laputa> (raw)
In-Reply-To: <30faf0b0-237d-02f3-9e35-6e746f1b3f52@gmx.de>
On Mon, Sep 27, 2021 at 09:48:54AM +0200, Heinrich Schuchardt wrote:
>
>
> On 9/27/21 6:30 AM, AKASHI Takahiro wrote:
> > struct efi_driver_binding_protocol, i.e. bp, is not the first element
> > in struct efi_driver_binding_extended_protocol.
> > So the casting:
> > struct efi_driver_binding_extended_protocol *bp =
> > (struct efi_driver_binding_extended_protocol *)this;
> > is simply wrong.
>
> The definition in include/efi_driver.h is:
>
> /*
> * This structure adds internal fields to the driver binding protocol.
> */
> struct efi_driver_binding_extended_protocol {
> struct efi_driver_binding_protocol bp;
> const struct efi_driver_ops *ops;
> };
>
> Why do you claim "bp is not the first element"?
>
> The whole efi_driver code relies on the fact that the
> efi_driver_binding_extended_protocol can be interpreted as
> efi_driver_binding_protocol.
Oops, *I* have added some member elements in another patch.
(I'm trying to make efi_driver objects show up in DM tree.)
Please forget this patch for a while.
-Takahiro Akashi
> Best regards
>
> Heinrich
>
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> > lib/efi_driver/efi_uclass.c | 14 +++++++-------
> > 1 file changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c
> > index 382c2b477f4d..9e784f9c237f 100644
> > --- a/lib/efi_driver/efi_uclass.c
> > +++ b/lib/efi_driver/efi_uclass.c
> > @@ -65,8 +65,8 @@ static efi_status_t EFIAPI efi_uc_supported(
> > {
> > efi_status_t r, ret;
> > void *interface;
> > - struct efi_driver_binding_extended_protocol *bp =
> > - (struct efi_driver_binding_extended_protocol *)this;
> > + struct efi_driver_binding_extended_protocol *bp = container_of(this,
> > + struct efi_driver_binding_extended_protocol, bp);
> >
> > EFI_ENTRY("%p, %p, %ls", this, controller_handle,
> > efi_dp_str(remaining_device_path));
> > @@ -113,8 +113,8 @@ static efi_status_t EFIAPI efi_uc_start(
> > {
> > efi_status_t r, ret;
> > void *interface = NULL;
> > - struct efi_driver_binding_extended_protocol *bp =
> > - (struct efi_driver_binding_extended_protocol *)this;
> > + struct efi_driver_binding_extended_protocol *bp = container_of(this,
> > + struct efi_driver_binding_extended_protocol, bp);
> >
> > EFI_ENTRY("%p, %p, %ls", this, controller_handle,
> > efi_dp_str(remaining_device_path));
> > @@ -201,8 +201,8 @@ static efi_status_t EFIAPI efi_uc_stop(
> > efi_status_t ret;
> > efi_uintn_t count;
> > struct efi_open_protocol_info_entry *entry_buffer;
> > - struct efi_driver_binding_extended_protocol *bp =
> > - (struct efi_driver_binding_extended_protocol *)this;
> > + struct efi_driver_binding_extended_protocol *bp = container_of(this,
> > + struct efi_driver_binding_extended_protocol, bp);
> >
> > EFI_ENTRY("%p, %p, %zu, %p", this, controller_handle,
> > number_of_children, child_handle_buffer);
> > @@ -283,7 +283,7 @@ static efi_status_t efi_add_driver(struct driver *drv)
> > }
> > bp->bp.image_handle = bp->bp.driver_binding_handle;
> > ret = efi_add_protocol(bp->bp.driver_binding_handle,
> > - &efi_guid_driver_binding_protocol, bp);
> > + &efi_guid_driver_binding_protocol, &bp->bp);
> > if (ret != EFI_SUCCESS) {
> > efi_delete_handle(bp->bp.driver_binding_handle);
> > free(bp);
> >
prev parent reply other threads:[~2021-09-27 8:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-27 4:30 [PATCH] efi_driver: fix a wrong cast AKASHI Takahiro
2021-09-27 7:48 ` Heinrich Schuchardt
2021-09-27 8:53 ` AKASHI Takahiro [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210927085326.GA54445@laputa \
--to=takahiro.akashi@linaro.org \
--cc=agraf@csgraf.de \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox