git: e2c8ca5df4d2 - main - emulators/rtc: Unbreak build with llvm13

From: Dmitri Goutnik <dmgk_at_FreeBSD.org>
Date: Sat, 14 May 2022 16:40:59 UTC
The branch main has been updated by dmgk:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e2c8ca5df4d2b07fb124f9b7dfa9d9f62f120a5d

commit e2c8ca5df4d2b07fb124f9b7dfa9d9f62f120a5d
Author:     Jamie Landeg-Jones <jamie@catflap.org>
AuthorDate: 2022-05-14 16:34:13 +0000
Commit:     Dmitri Goutnik <dmgk@FreeBSD.org>
CommitDate: 2022-05-14 16:40:10 +0000

    emulators/rtc: Unbreak build with llvm13
    
    rtc.c:112:6: error: variable 'unit' set but not used [-Werror,-Wunused-but-set-variable]
            int unit;
                ^
    
    PR:             263616
---
 emulators/rtc/files/rtc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/emulators/rtc/files/rtc.c b/emulators/rtc/files/rtc.c
index 49c3638965f7..5c3d8cf1c5b2 100644
--- a/emulators/rtc/files/rtc.c
+++ b/emulators/rtc/files/rtc.c
@@ -109,10 +109,16 @@ static struct rtc_softc *
 rtc_attach(struct cdev *dev)
 {
 	struct rtc_softc *sc;
+/* Clang 13+ realises that "unit" below isn't actually used if we */
+/* aren't running with DEBUG set. The warning is treated as a     */
+/* fatal error by FreeBSD's kmod build system, so wrap its usage  */
+/* within DEBUG pre-processor conditionals. - Jamie Landeg-Jones  */
+#if DEBUG
 	int unit;
 
 	unit = dev2unit(dev);
 	DLog(Lenter, "%d %p", unit, dev);
+#endif /* DEBUG */
 	if (dev->si_drv1) {
 		DLog(Lexit, "old %p, %p", dev, dev->si_drv1);
 		return dev->si_drv1;