Page MenuHomeFreeBSD

iwnstats: fix build with clang and allow install under /usr/local/sbin
ClosedPublic

Authored by sbz on Apr 16 2021, 11:21 PM.

Details

Summary

iwnstats was not compiling because of some issues raised by the clang
compiler due to -Werror. As a tool it is not connected to world build.

Add missing field "barker_mrc" initialization in struct
iwn_sensitivity_limits for -Wmissing-field-initializers and remove
unused pointer *is on iwn_stats_*_print functions and unused variables
for -Wunused-parameter.

The value for field "barker_mrc" of struct iwn2030_sensitivity_limits
was obtained from linux 3.2 wireless/iwlwifi driver code (iwl-2000.c:115
.barker_corr_th_min_mrc = 390).

Also set BINDIR in Makefile to make it possible to install under
/usr/local/sbin/iwnstats as it require super user.

Test Plan

I have tested build successfully on architecture amd64 and
on ref13-aarch64.

$ cd /usr/src/tools/tools/iwn/iwnstats
$ make

rm -f .depend
echo iwnstats.full: /usr/lib/libc.a  >> .depend
cc  -O2 -pipe -fno-common   -I/usr/src/tools/tools/iwn/iwnstats/../../../../sys/dev/iwn/ -I/usr/src/tools/tools/iwn/iwnstats/../../../../sys/ -fPIE -g -MD  -MF.depend.main.o -MTmain.o -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable  -Qunused-arguments    -c /usr/src/tools/tools/iwn/iwnstats/main.c -o main.o
cc  -O2 -pipe -fno-common   -I/usr/src/tools/tools/iwn/iwnstats/../../../../sys/dev/iwn/ -I/usr/src/tools/tools/iwn/iwnstats/../../../../sys/ -fPIE -g -MD  -MF.depend.iwn_ioctl.o -MTiwn_ioctl.o -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable  -Qunused-arguments    -c /usr/src/tools/tools/iwn/iwnstats/iwn_ioctl.c -o iwn_ioctl.o
cc -O2 -pipe -fno-common -I/usr/src/tools/tools/iwn/iwnstats/../../../../sys/dev/iwn/ -I/usr/src/tools/tools/iwn/iwnstats/../../../../sys/ -fPIE -g -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Qunused-arguments  -pie   -o iwnstats.full main.o iwn_ioctl.o  
objcopy --only-keep-debug iwnstats.full iwnstats.debug
objcopy --strip-debug --add-gnu-debuglink=iwnstats.debug  iwnstats.full iwnstats

$ sudo make install

install  -s -o root -g wheel -m 555   iwnstats /usr/sbin/iwnstats
install  -o root -g wheel -m 444  iwnstats.debug /usr/lib/debug/usr/sbin/iwnstats.debug

Run ok sudo /usr/sbin/iwnstats

$ sysctl net.wlan.devices
net.wlan.devices: iwn0
$ sudo /usr/sbin/iwnstats

st: 0x801809004
time=1618615064.743964
iwn_stats_general_print: temp=56, temp_m=3474, burst_check=32387, burst=0, sleep=0, slot_out=0, slot_idle=0
iwn_stats_general_print: slot_out=0, ttl_tstamp=0x11e213a4, tx_ant_a=0, tx_ant_b=0, exec=0, probe=0
iwn_stats_general_print: rx_enabled=0
iwn_stats_phy_print: ofdm: ina=5344505, fina=3626807, bad_plcp=572073, bad_crc32=18888, overrun=0, eoverrun=0
iwn_stats_phy_print: ofdm: fa=1717698, bad_fina_sync=57, sfd_timeout=0, fina_timeout=0, no_rts_ack=0
iwn_stats_phy_print: ofdm: rxe_limit=4, ack=858, cts=14, ba_resp=37296, dsp_kill=0, bad_mh=0, rssi_sum=0
iwn_stats_phy_print: cck: ina=2587442, fina=2587274, bad_plcp=842863, bad_crc32=3400, overrun=0, eoverrun=0
iwn_stats_phy_print: cck: fa=168, bad_fina_sync=215, sfd_timeout=0, fina_timeout=0, no_rts_ack=742
iwn_stats_phy_print: cck: rxe_limit=8, ack=265, cts=41504, ba_resp=0, dsp_kill=29004, bad_mh=0, rssi_sum=0
iwn_stats_ht_phy_print: bad_plcp=0, overrun=0, eoverrun=0, good_crc32=16966, bad_crc32=16885
iwn_stats_ht_phy_print: bad_mh=0, good_ampdu_crc32=77548, ampdu=144672, fragment=0
iwn_stats_rx_general_print: bad_cts=0, bad_ack=0, not_bss=0, filtered=1771299, bad_chan=0, beacons=208180
iwn_stats_rx_general_print: missed_beacons=5, adc_saturated=0, ina_searched=65535
iwn_stats_rx_general_print: noise=[0, 4114, 4627] flags=0x00000001, load=102396, fa=3
iwn_stats_rx_general_print: rssi=[0, 14, 22] energy=[72 58 50]
iwn_stats_tx_print: preamble=160927, rx_detected=3732, bt_defer=0, bt_kill=0, short_len=0
iwn_stats_tx_print: cts_timeout=0, ack_timeout=8203, exp_ack=33305, ack=25102, msdu=47
iwn_stats_tx_print: burst_err1=0, burst_err2=0, cts_collision=0, ack_collision=47
iwn_stats_tx_print: ba_timeout=631, ba_resched=631, query_ampdu=45770, query=975, query_ampdu_frag=2807
iwn_stats_tx_print: query_mismatch=0, not_ready=0, underrun=0, bt_ht_kill=0, rx_ba_resp=2176

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

sbz requested review of this revision.Apr 16 2021, 11:21 PM

Current main at 86046cf55 build errors are the following:

$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
$ cd /usr/src/tools/tools/iwn/iwnstats
$ make

rm -f .depend
echo iwnstats.full: /usr/lib/libc.a  >> .depend
cc  -O2 -pipe -fno-common   -I/usr/src/tools/tools/iwn/iwnstats/../../../../sys/dev/iwn/ -I/usr/src/tools/tools/iwn/iwnstats/../../../../sys/ -fPIE -g -MD  -MF.depend.main.o -MTmain.o -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable  -Qunused-arguments    -c /usr/src/tools/tools/iwn/iwnstats/main.c -o main.o
In file included from /usr/src/tools/tools/iwn/iwnstats/main.c:50:
/usr/src/tools/tools/iwn/iwnstats/../../../../sys/dev/iwn/if_iwnreg.h:2271:1: error: missing field 'barker_mrc' initializer [-Werror,-Wmissing-field-initializers]
};
^
/usr/src/tools/tools/iwn/iwnstats/main.c:75:38: error: unused parameter 'is' [-Werror,-Wunused-parameter]
iwn_stats_phy_print(struct iwnstats *is, struct iwn_rx_phy_stats *rxphy,
                                     ^
/usr/src/tools/tools/iwn/iwnstats/main.c:111:45: error: unused parameter 'is' [-Werror,-Wunused-parameter]
iwn_stats_rx_general_print(struct iwnstats *is, struct iwn_rx_general_stats *g)
                                            ^
/usr/src/tools/tools/iwn/iwnstats/main.c:150:37: error: unused parameter 'is' [-Werror,-Wunused-parameter]
iwn_stats_tx_print(struct iwnstats *is, struct iwn_tx_stats *tx)
                                    ^
/usr/src/tools/tools/iwn/iwnstats/main.c:194:41: error: unused parameter 'is' [-Werror,-Wunused-parameter]
iwn_stats_ht_phy_print(struct iwnstats *is, struct iwn_rx_ht_phy_stats *ht)
                                        ^
/usr/src/tools/tools/iwn/iwnstats/main.c:215:42: error: unused parameter 'is' [-Werror,-Wunused-parameter]
iwn_stats_general_print(struct iwnstats *is, struct iwn_stats *stats)
                                         ^
/usr/src/tools/tools/iwn/iwnstats/main.c:283:6: error: unused variable 'ret' [-Werror,-Wunused-variable]
        int ret;
            ^
/usr/src/tools/tools/iwn/iwnstats/main.c:281:8: error: unused variable 'sysctlname' [-Werror,-Wunused-variable]
        char *sysctlname;
              ^
/usr/src/tools/tools/iwn/iwnstats/main.c:282:9: error: unused variable 'len' [-Werror,-Wunused-variable]
        size_t len;
               ^
9 errors generated.
*** Error code 1

Stop.
make: stopped in /usr/src/tools/tools/iwn/iwnstats
bz added inline comments.
tools/tools/iwn/iwnstats/Makefile
17

Most of the tools from tools/tools/net80211/ seem to be installed to /usr/local/bin (though arguably sbin be more appropriate as some need super user priv).

tools/tools/iwn/iwnstats/Makefile
17

Would /usr/local/sbin a better choice? Indeed some of them require super user privilege and it is the case of iwnstats. Otherwise I'm fine to follow what others tools does and update with /usr/local/bin, let me know.

tools/tools/iwn/iwnstats/Makefile
17

I think /usr/local/sbin is better than /usr/local/bin.

change bindir from /usr/sbin to /usr/local/sbin to adress bz feedback
reword the commit message

sbz marked 2 inline comments as done.Apr 20 2021, 2:40 PM
sbz added inline comments.
tools/tools/iwn/iwnstats/Makefile
17

Done, I updated the binary directory with /usr/local/sbin, thanks.

sbz retitled this revision from iwnstats: build with clang and allow install under /usr/sbin to iwnstats: fix build with clang and allow install under /usr/local/sbin.Apr 20 2021, 2:41 PM
sbz edited the summary of this revision. (Show Details)
sbz marked an inline comment as done.Apr 20 2021, 2:46 PM
This revision is now accepted and ready to land.Apr 20 2021, 4:43 PM