From owner-svn-src-all@freebsd.org Wed Feb 20 18:30:56 2019 Return-Path: Delivered-To: svn-src-all@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 D0F4614FB9D4; Wed, 20 Feb 2019 18:30:55 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F9778CC89; Wed, 20 Feb 2019 18:30:55 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 429299517; Wed, 20 Feb 2019 18:30:55 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x1KIUt96092225; Wed, 20 Feb 2019 18:30:55 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x1KIUskL092224; Wed, 20 Feb 2019 18:30:54 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201902201830.x1KIUskL092224@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 20 Feb 2019 18:30:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r344370 - stable/11/stand/userboot/userboot X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/stand/userboot/userboot X-SVN-Commit-Revision: 344370 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4F9778CC89 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2019 18:30:56 -0000 Author: kevans Date: Wed Feb 20 18:30:54 2019 New Revision: 344370 URL: https://svnweb.freebsd.org/changeset/base/344370 Log: MFC r334412: userboot: Fix bad type-punning 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. Modified: stable/11/stand/userboot/userboot/devicename.c stable/11/stand/userboot/userboot/main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/userboot/userboot/devicename.c ============================================================================== --- stable/11/stand/userboot/userboot/devicename.c Wed Feb 20 18:29:52 2019 (r344369) +++ stable/11/stand/userboot/userboot/devicename.c Wed Feb 20 18:30:54 2019 (r344370) @@ -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: stable/11/stand/userboot/userboot/main.c ============================================================================== --- stable/11/stand/userboot/userboot/main.c Wed Feb 20 18:29:52 2019 (r344369) +++ stable/11/stand/userboot/userboot/main.c Wed Feb 20 18:30:54 2019 (r344370) @@ -154,19 +154,18 @@ 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; + 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 @@ -183,14 +182,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); }