Skip to content

Commit

Permalink
iwnstats: fix build with clang and allow install under /usr/local/sbin
Browse files Browse the repository at this point in the history
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, remove unused
pointer *is on iwn_stats_*_print functions and unused variables for
-Wunused-parameter and -Wunused-variable.

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.

Reviewed by:	adrian
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29800
  • Loading branch information
sbz committed Apr 20, 2021
1 parent d554522 commit 561d34d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
3 changes: 2 additions & 1 deletion sys/dev/iwn/if_iwnreg.h
Original file line number Diff line number Diff line change
Expand Up @@ -2267,7 +2267,8 @@ static const struct iwn_sensitivity_limits iwn2030_sensitivity_limits = {
160,310,
97,
97,
110
110,
390
};

/* Map TID to TX scheduler's FIFO. */
Expand Down
2 changes: 2 additions & 0 deletions tools/tools/iwn/iwnstats/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ PROG= iwnstats
# to not compile, use gcc for now.
#CC= gcc

BINDIR?=/usr/local/sbin

SRCS= main.c iwn_ioctl.c

# CFLAGS.clang+= -fbracket-depth=512
Expand Down
26 changes: 11 additions & 15 deletions tools/tools/iwn/iwnstats/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ iwnstats_new(const char *ifname)
}

static void
iwn_stats_phy_print(struct iwnstats *is, struct iwn_rx_phy_stats *rxphy,
const char *prefix)
iwn_stats_phy_print(struct iwn_rx_phy_stats *rxphy, const char *prefix)
{

printf("%s: %s: ina=%d, fina=%d, bad_plcp=%d, bad_crc32=%d, overrun=%d, eoverrun=%d\n",
Expand Down Expand Up @@ -108,7 +107,7 @@ iwn_stats_phy_print(struct iwnstats *is, struct iwn_rx_phy_stats *rxphy,
}

static void
iwn_stats_rx_general_print(struct iwnstats *is, struct iwn_rx_general_stats *g)
iwn_stats_rx_general_print(struct iwn_rx_general_stats *g)
{

printf("%s: bad_cts=%d, bad_ack=%d, not_bss=%d, filtered=%d, bad_chan=%d, beacons=%d\n",
Expand Down Expand Up @@ -147,7 +146,7 @@ iwn_stats_rx_general_print(struct iwnstats *is, struct iwn_rx_general_stats *g)
}

static void
iwn_stats_tx_print(struct iwnstats *is, struct iwn_tx_stats *tx)
iwn_stats_tx_print(struct iwn_tx_stats *tx)
{

printf("%s: preamble=%d, rx_detected=%d, bt_defer=%d, bt_kill=%d, short_len=%d\n",
Expand Down Expand Up @@ -191,7 +190,7 @@ iwn_stats_tx_print(struct iwnstats *is, struct iwn_tx_stats *tx)
}

static void
iwn_stats_ht_phy_print(struct iwnstats *is, struct iwn_rx_ht_phy_stats *ht)
iwn_stats_ht_phy_print(struct iwn_rx_ht_phy_stats *ht)
{

printf("%s: bad_plcp=%d, overrun=%d, eoverrun=%d, good_crc32=%d, bad_crc32=%d\n",
Expand All @@ -212,7 +211,7 @@ iwn_stats_ht_phy_print(struct iwnstats *is, struct iwn_rx_ht_phy_stats *ht)


static void
iwn_stats_general_print(struct iwnstats *is, struct iwn_stats *stats)
iwn_stats_general_print(struct iwn_stats *stats)
{

/* General */
Expand Down Expand Up @@ -249,16 +248,16 @@ iwn_print(struct iwnstats *is)
gettimeofday(&tv, NULL);
printf("time=%ld.%.6ld\n", (long)tv.tv_sec, (long)tv.tv_usec);

iwn_stats_general_print(is, s);
iwn_stats_general_print(s);

/* RX */
iwn_stats_phy_print(is, &s->rx.ofdm, "ofdm");
iwn_stats_phy_print(is, &s->rx.cck, "cck");
iwn_stats_ht_phy_print(is, &s->rx.ht);
iwn_stats_rx_general_print(is, &s->rx.general);
iwn_stats_phy_print(&s->rx.ofdm, "ofdm");
iwn_stats_phy_print(&s->rx.cck, "cck");
iwn_stats_ht_phy_print(&s->rx.ht);
iwn_stats_rx_general_print(&s->rx.general);

/* TX */
iwn_stats_tx_print(is, &s->tx);
iwn_stats_tx_print(&s->tx);
printf("--\n");
}

Expand All @@ -278,9 +277,6 @@ main(int argc, char *argv[])
int ch;
char *ifname;
bool first;
char *sysctlname;
size_t len;
int ret;

ifname = strdup(IWN_DEFAULT_IF);

Expand Down

0 comments on commit 561d34d

Please sign in to comment.