The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4b301f7e7ab43bb61561786c2ab33f3a3c4a725d
commit 4b301f7e7ab43bb61561786c2ab33f3a3c4a725d Author: Warner Losh <i...@freebsd.org> AuthorDate: 2025-09-14 17:12:38 +0000 Commit: Warner Losh <i...@freebsd.org> CommitDate: 2025-09-14 17:12:38 +0000 iicbb: Fix gcc12 complaint So gcc12 doesn't understand that t->udelay is >= 1, so thinks that noack might be unset sometimes. While we specifically constrain this on direct assignment, there's a sysctl that might not. This is likely also a bug. Instead of uglifying everything by using MAX(1, sc->udelay), I rewrote the for loop as a do-while loop (which arguably dictates intent better because this code clearly assumes it will be executed once). Sponsored by: Netflix --- sys/dev/iicbus/iicbb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/dev/iicbus/iicbb.c b/sys/dev/iicbus/iicbb.c index c344bda930b0..5f6423135f46 100644 --- a/sys/dev/iicbus/iicbb.c +++ b/sys/dev/iicbus/iicbb.c @@ -331,7 +331,7 @@ iicbb_getack(device_t dev) { struct iicbb_softc *sc = device_get_softc(dev); int noack, err; - int t; + int t = 0; /* Release SDA so that the slave can drive it. */ err = iicbb_clockin(dev, 1); @@ -341,12 +341,13 @@ iicbb_getack(device_t dev) } /* Sample SDA until ACK (low) or udelay runs out. */ - for (t = 0; t < sc->udelay; t++) { + do { noack = I2C_GETSDA(dev); if (!noack) break; DELAY(1); - } + t++; + } while(t < sc->udelay); DELAY(sc->udelay - t); iicbb_clockout(dev);