git: 9dee581ad980 - stable/13 - stand: Change disk_fmtdev to take a struct devdesc *

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 24 Jan 2023 22:11:52 UTC
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=9dee581ad98055d8e56186f990f9bef18c0376bf

commit 9dee581ad98055d8e56186f990f9bef18c0376bf
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-08-11 15:04:50 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-01-24 21:49:30 +0000

    stand: Change disk_fmtdev to take a struct devdesc *
    
    We do a number of games with ploymorphism for different types struct
    *devdesc. Adjust one place that this affects to take the address of the
    base class (most others have void * at the moment). This is more type
    safe than a bare void *.
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D35914
    
    (cherry picked from commit c32dde3166922f55927764464d13f1bc9640f5f6)
---
 stand/common/disk.c        | 5 ++++-
 stand/common/disk.h        | 3 ++-
 stand/libsa/geli/gelidev.c | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/stand/common/disk.c b/stand/common/disk.c
index 3ad147da0e5b..15daf7e358c6 100644
--- a/stand/common/disk.c
+++ b/stand/common/disk.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include <stdarg.h>
 #include <bootstrap.h>
 #include <part.h>
+#include <assert.h>
 
 #include "disk.h"
 
@@ -386,11 +387,13 @@ disk_close(struct disk_devdesc *dev)
 }
 
 char *
-disk_fmtdev(struct disk_devdesc *dev)
+disk_fmtdev(struct devdesc *vdev)
 {
+	struct disk_devdesc *dev = (struct disk_devdesc *)vdev;
 	static char buf[128];
 	char *cp;
 
+	assert(vdev->d_dev->dv_type == DEVT_DISK);
 	cp = buf + sprintf(buf, "%s%d", dev->dd.d_dev->dv_name, dev->dd.d_unit);
 	if (dev->d_slice > D_SLICENONE) {
 #ifdef LOADER_GPT_SUPPORT
diff --git a/stand/common/disk.h b/stand/common/disk.h
index 83109981e0a8..806673349cb8 100644
--- a/stand/common/disk.h
+++ b/stand/common/disk.h
@@ -116,7 +116,8 @@ extern int ptblread(void *, void *, size_t, uint64_t);
  * Print information about slices on a disk.
  */
 extern int disk_print(struct disk_devdesc *, char *, int);
-extern char* disk_fmtdev(struct disk_devdesc *);
 extern int disk_parsedev(struct disk_devdesc *, const char *, const char **);
 
+char *disk_fmtdev(struct devdesc *vdev);
+
 #endif	/* _DISK_H */
diff --git a/stand/libsa/geli/gelidev.c b/stand/libsa/geli/gelidev.c
index d312d7b17e0e..5dd122a4a681 100644
--- a/stand/libsa/geli/gelidev.c
+++ b/stand/libsa/geli/gelidev.c
@@ -305,7 +305,7 @@ geli_probe_and_attach(struct open_file *f)
 	hlastblk = (hmediasize / DEV_BSIZE) - 1;
 
 	/* Taste the host provider.  If it's not geli-encrypted just return. */
-	gdev = geli_taste(diskdev_read, hdesc, hlastblk, disk_fmtdev(hdesc));
+	gdev = geli_taste(diskdev_read, hdesc, hlastblk, disk_fmtdev(&hdesc->dd));
 	if (gdev == NULL)
 		return;