From owner-svn-src-head@freebsd.org Thu May 31 02:59:01 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B7A1FEFAFCF for ; Thu, 31 May 2018 02:59:00 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x22a.google.com (mail-it0-x22a.google.com [IPv6:2607:f8b0:4001:c0b::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4486A6ADB9 for ; Thu, 31 May 2018 02:59:00 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x22a.google.com with SMTP id p3-v6so25825900itc.0 for ; Wed, 30 May 2018 19:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=NrL8LCtiBrQKvqYTIlS32/2aKKbAX3/U0jIp/Ma18pw=; b=pgv0u1ZVbE5gKoR046py/vOlvB9T6cYmLRWATgb1pBCheHXK9wVY0QMtPbaqaCpIrE dtCjJBGZMkEuq0uik3XEyA4Pa1uabLLdkIyYCgnuFGqAQsdcERrxv5Zd2eGBNDc6IB29 jLazQFNkySladcT9VDLZyL8onDkt35heB0j1RVldS9GB/+UmCexfYS76STkp+itmECp3 jVYbTd+fLMoy98UMZZf6Hd7nAXfwjKOzhcmFlzY5u39GiAyaaDns4TuCFY8MNBxIkTqL qOoUCCE64svZh1vTn3x+cUKyvPXSC59v2MS/AIjEBM86Ekkupc13di0uvnfnXxtOonC8 Q+KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=NrL8LCtiBrQKvqYTIlS32/2aKKbAX3/U0jIp/Ma18pw=; b=eea7la4aR3rs2AMR8CoeuvwxJ0xcBNBJ5xVfgMMYLPmHgPKhaP8IFb+GGDYOoW7dF9 iPlCTst18/564M3pY2hHU1gYeSOGdRGl8bqkxZKhfdWBwcouIsglrgrV4FY2SQKS0Se3 U3Wh5rQWpUmQuo8PW/T0wkwF2KmFijECE1ASklFgMxwvKduGnuxz8zqJEiDB4Joj1kTn vBfAEBnMWy3pJ6lhPm3g3uRBqypJ935zcpfOHok6QJH1Hu+RaBGaDp2GweyS9fECaAJN MpVFURKtnTfW4ex28wH/2cu6qsBnHG1SOGAf5PkwDQjsvruorzoNeiQAkEUk99AMKK3G dvTw== X-Gm-Message-State: ALKqPwcvA1qzj94LdUFxiYcEKqm4o+Pd+a8K1x8run4Iypcsy1k3h00q JALQdDH8S4Lhe9A2HR/uzhBtUa608uREy0mqRCcPIg== X-Google-Smtp-Source: ADUXVKJ3J2l3djqU8VbG3lWx9xK4bBmlzrhKEVzLQ54XgwyKeonfAZi7ywDwrgnb4GbrvPR69scIZfdXP1h42Igj1HU= X-Received: by 2002:a24:efc2:: with SMTP id i185-v6mr3956561ith.57.1527735539261; Wed, 30 May 2018 19:58:59 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 2002:a4f:d028:0:0:0:0:0 with HTTP; Wed, 30 May 2018 19:58:58 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <201805310254.w4V2sCWW073082@repo.freebsd.org> References: <201805310254.w4V2sCWW073082@repo.freebsd.org> From: Warner Losh Date: Wed, 30 May 2018 20:58:58 -0600 X-Google-Sender-Auth: JHA-6_JGpcDBr4mkBKTAUCNAc8E Message-ID: Subject: Re: svn commit: r334412 - head/stand/userboot/userboot To: Warner Losh Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 May 2018 02:59:01 -0000 On Wed, May 30, 2018 at 8:54 PM, Warner Losh 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); > } > > >