From 79f7d2cdd8e7b21bcc9e39e4025377edc47c0c5f Mon Sep 17 00:00:00 2001 From: Jeremy Chadwick Date: Mon, 5 Mar 2018 02:10:58 -0800 Subject: [PATCH] Deprecate FreeBSD 9.x and older, fix for clang - smbus_ios.c, README.md: Despite being a nostalgic and greatly appreciating older FreeBSD, it's time to drop support for 9.x, 8.x, and 7.x. However, those who are still on 9.x deserve respect, as PR 173541 still affects 10.x and newer even as of this writing. - main.c: Use the format attribute to squelch warnings on clang due to use of -Wformat=2 (-Wformat-nonliteral). This should also continue to work on gcc, hopefully. - README.md: add support for 10.x, minor ordering and labelling fixups - bsdhwmon.8.txt: rebuilt on 11.x (no content changes) --- README.md | 18 +++++++++--------- bsdhwmon.8.txt | 2 +- main.c | 5 +++++ smbus_io.c | 20 ++------------------ 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 4fb0255..1935ab4 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ bsdhwmon is developed with a very different mentality compared to other hardware * Written with stability and production environments in mind * Intended for use with server products (currently Supermicro, but can be extended to others that have proper SMBIOS identification data) -* Uses SMBus ([smb(4)](https://www.freebsd.org/cgi/man.cgi?query=smb&apropos=0&sektion=0&manpath=FreeBSD+9.3-stable&arch=default&format=html) driver) exclusively, significantly decreasing risks and CPU usage compared to classic LPC I/O +* Uses SMBus ([smb(4)](https://www.freebsd.org/cgi/man.cgi?query=smb&apropos=0&sektion=0&manpath=FreeBSD+11.1-stable&arch=default&format=html) driver) exclusively, significantly decreasing risks and CPU usage compared to classic LPC I/O * Based primarily on documentation provided by motherboard/server vendors, combined with documentation from chipset manufacturers * Identifies hardware via strict SMBIOS data matching; device "probing" is avoided to minimise false positives and thus risks * Full tested on both i386 and amd64 systems across multiple versions of FreeBSD (legacy and present-day) @@ -19,17 +19,17 @@ bsdhwmon is developed with a very different mentality compared to other hardware At this time, only a subset of Supermicro hardware is supported. For an official list of supported hardware and models, please see the [doc/SUPPORTED](doc/SUPPORTED) file. ## Supported Operating Systems -* FreeBSD 8.x (stable/8) -* FreeBSD 9.x (stable/9) - -## Unsupported/Untested Operating Systems -* FreeBSD 10.x (stable/10) * FreeBSD 11.x (stable/11) +* FreeBSD 10.x (stable/10) + +## Untested Operating Systems * FreeBSD 12.x (head/current) -## Deprecated Operating Systems -* FreeBSD 6.x (stable/6) -* FreeBSD 7.x (stable/7) +## Deprecated (Unsupported) Operating Systems +* FreeBSD 9.x +* FreeBSD 8.x +* FreeBSD 7.x +* FreeBSD 6.x ## Usage Please see the [bsdhwmon man page](bsdhwmon.8.txt) for all command-line flags and usage details. diff --git a/bsdhwmon.8.txt b/bsdhwmon.8.txt index 18ae18a..f7ae349 100644 --- a/bsdhwmon.8.txt +++ b/bsdhwmon.8.txt @@ -149,4 +149,4 @@ CONTRIBUTORS lm_sensors project, for providing an unofficial secondary source of IC documentation and details of chip quirks. -FreeBSD 9.3 January 1, 2018 FreeBSD 9.3 +FreeBSD 11.1 January 1, 2018 FreeBSD 11.1 diff --git a/main.c b/main.c index fe0f7c8..a2b0d80 100644 --- a/main.c +++ b/main.c @@ -65,7 +65,12 @@ static int f_verbose = 0; /* Command line flag "-v" */ * VERBOSE() is mainly used for debugging. Use of the "-v" flag will * cause underlying functions to call VERBOSE() with all sorts of * information. + * + * The format attribute is to safely squelch -Wformat-nonliteral (part + * of of -Wformat=2) warnings about vprintf() with clang. Reference: + * http://clang.llvm.org/docs/AttributeReference.html#format-gnu-format */ +__attribute__((__format__ (__printf__, 1, 0))) void VERBOSE(const char *fmt, ...) { diff --git a/smbus_io.c b/smbus_io.c index c844957..dc82189 100644 --- a/smbus_io.c +++ b/smbus_io.c @@ -11,16 +11,6 @@ * * http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html * - * In __FreeBSD_version 702101 (2009/05/15), the smb(4) driver was - * modified to require SMBus slave addresses not have LSB (bit 0) - * set. This is per SMBus 2.0 specification, which clearly states that - * slave addreses are 7 bits in width and occupy the upper 7 bits of - * and 8-bit address (i.e. LSB is always 0). If the LSB is 1, the - * driver immediately returns EINVAL, resulting in ioctl(2) returning - * -1 with errno EINVAL. Commit: - * - * https://svnweb.freebsd.org/base?view=revision&revision=192149 - * * In __FreeBSD_version 1100070 (2015/04/25), the smb(4) driver smbcmd * struct was overhauled, and backwards-compatibility appears to have * been "lost" in favour of a different design. Discussion/commit: @@ -71,11 +61,8 @@ read_byte(int fd, int slave, const char idxreg) c.slave = slave << 1; c.rbuf = ibuf; c.rcount = 1; -#elif (__FreeBSD_version >= 702101) - c.slave = (u_char) (slave & 0xff) << 1; - c.data.byte_ptr = ibuf; #else - c.slave = (u_char) slave & 0xff; + c.slave = (u_char) (slave & 0xff) << 1; c.data.byte_ptr = ibuf; #endif @@ -114,11 +101,8 @@ write_byte(int fd, int slave, const char idxreg, const char value) #if (__FreeBSD_version >= 1100070) c.slave = slave << 1; c.wdata.byte = value; -#elif (__FreeBSD_version >= 702101) - c.slave = (u_char) (slave & 0xff) << 1; - c.data.byte = value; #else - c.slave = (u_char) slave & 0xff; + c.slave = (u_char) (slave & 0xff) << 1; c.data.byte = value; #endif