Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 May 2018 20:58:58 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Warner Losh <imp@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r334412 - head/stand/userboot/userboot
Message-ID:  <CANCZdfoccC_SQAjs-eM_wk1oZrWynnJWvZiNKMs88UFYvbaoRQ@mail.gmail.com>
In-Reply-To: <201805310254.w4V2sCWW073082@repo.freebsd.org>
References:  <201805310254.w4V2sCWW073082@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, May 30, 2018 at 8:54 PM, Warner Losh <imp@freebsd.org> wrote:

> Author: imp
> Date: Thu May 31 02:54:11 2018
> New Revision: 334412
> URL: https://svnweb.freebsd.org/changeset/base/334412
>
> Log:
>   Pass a struct devdesc to the format commands. Use proper type rather
>   than doing weird type-punning that happened to work because the size
>   was right. We copied a zfs devdesc into a disk_devdesc and then after
>   passing through a NULL pointer reinterpreted it as a
>   zfs_devdesc. Instead, pass the base devdesc around and 'upcase' when
>   we know the types are right.
>
>   This has the happy side effect of fixing a gcc warning about bad
>   type punning.
>
>   Differential Revision: https://reviews.freebsd.org/D15629


This should have been https://reviews.freebsd.org/D15628. Closed manually.

Warner


>
> Modified:
>   head/stand/userboot/userboot/devicename.c
>   head/stand/userboot/userboot/main.c
>
> Modified: head/stand/userboot/userboot/devicename.c
> ============================================================
> ==================
> --- head/stand/userboot/userboot/devicename.c   Thu May 31 02:25:46 2018
>       (r334411)
> +++ head/stand/userboot/userboot/devicename.c   Thu May 31 02:54:11 2018
>       (r334412)
> @@ -175,30 +175,30 @@ userboot_parsedev(struct disk_devdesc **dev, const
> cha
>  char *
>  userboot_fmtdev(void *vdev)
>  {
> -    struct disk_devdesc        *dev = (struct disk_devdesc *)vdev;
> +    struct devdesc     *dev = (struct devdesc *)vdev;
>      static char                buf[128];       /* XXX device length
> constant? */
>
> -    switch(dev->dd.d_dev->dv_type) {
> +    switch(dev->d_dev->dv_type) {
>      case DEVT_NONE:
>         strcpy(buf, "(no device)");
>         break;
>
>      case DEVT_CD:
> -       sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit);
> +       sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
>         break;
>
>      case DEVT_DISK:
>         return (disk_fmtdev(vdev));
>
>      case DEVT_NET:
> -       sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit);
> +       sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
>         break;
>
>      case DEVT_ZFS:
>  #if defined(USERBOOT_ZFS_SUPPORT)
>         return (zfs_fmtdev(vdev));
>  #else
> -       sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit);
> +       sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
>  #endif
>         break;
>      }
>
> Modified: head/stand/userboot/userboot/main.c
> ============================================================
> ==================
> --- head/stand/userboot/userboot/main.c Thu May 31 02:25:46 2018
> (r334411)
> +++ head/stand/userboot/userboot/main.c Thu May 31 02:54:11 2018
> (r334412)
> @@ -155,20 +155,19 @@ static void
>  extract_currdev(void)
>  {
>         struct disk_devdesc dev;
> -
> -       //bzero(&dev, sizeof(dev));
> -
> +       struct devdesc *dd;
>  #if defined(USERBOOT_ZFS_SUPPORT)
> +       struct zfs_devdesc zdev;
> +
>         CTASSERT(sizeof(struct disk_devdesc) >= sizeof(struct
> zfs_devdesc));
>         if (userboot_zfs_found) {
> -               struct zfs_devdesc zdev;
>
>                 /* Leave the pool/root guid's unassigned */
>                 bzero(&zdev, sizeof(zdev));
>                 zdev.dd.d_dev = &zfs_dev;
>
> -               dev = *(struct disk_devdesc *)&zdev;
> -               init_zfs_bootenv(zfs_fmtdev(&dev));
> +               init_zfs_bootenv(zfs_fmtdev(&zdev));
> +               dd = &zdev.dd;
>         } else
>  #endif
>
> @@ -185,14 +184,16 @@ extract_currdev(void)
>                         dev.d_slice = -1;
>                         dev.d_partition = -1;
>                 }
> +               dd = &dev.dd;
>         } else {
>                 dev.dd.d_dev = &host_dev;
>                 dev.dd.d_unit = 0;
> +               dd = &dev.dd;
>         }
>
> -       env_setenv("currdev", EV_VOLATILE, userboot_fmtdev(&dev),
> +       env_setenv("currdev", EV_VOLATILE, userboot_fmtdev(dd),
>             userboot_setcurrdev, env_nounset);
> -       env_setenv("loaddev", EV_VOLATILE, userboot_fmtdev(&dev),
> +       env_setenv("loaddev", EV_VOLATILE, userboot_fmtdev(dd),
>             env_noset, env_nounset);
>  }
>
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfoccC_SQAjs-eM_wk1oZrWynnJWvZiNKMs88UFYvbaoRQ>