Bug 250133 - tools/tools/ifinfo/ifinfo.c Fixing build
Summary: tools/tools/ifinfo/ifinfo.c Fixing build
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2020-10-05 09:10 UTC by Olivier Cochard
Modified: 2020-11-30 15:05 UTC (History)
3 users (show)

See Also:

patch to fix build (2.94 KB, patch)
2020-10-05 09:10 UTC, Olivier Cochard
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Cochard freebsd_committer 2020-10-05 09:10:30 UTC
Created attachment 218533 [details]
patch to fix build

Fixing this tool build (tested on amd64 only):
root@netboot-f:/usr/src/tools/tools/ifinfo # make
[Creating objdir /usr/obj/usr/src/amd64.amd64/tools/tools/ifinfo...]
echo ifinfo.full: /usr/lib/libc.a  >> .depend
cc  -O2 -pipe -fno-common   -g -MD  -MF.depend.ifinfo.o -MTifinfo.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 -Winline -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/ifinfo/ifinfo.c -o ifinfo.o
/usr/src/tools/tools/ifinfo/ifinfo.c:175:25: error: format specifies type 'unsigned long' but the argument has type 'uint32_t' (aka 'unsigned int') [-Werror,-Wformat]
        printf("\tmtu: %lu\n", ifmd->ifmd_data.ifi_mtu);
                       ~~~     ^~~~~~~~~~~~~~~~~~~~~~~
/usr/src/tools/tools/ifinfo/ifinfo.c:176:28: error: format specifies type 'unsigned long' but the argument has type 'uint32_t' (aka 'unsigned int') [-Werror,-Wformat]
        printf("\tmetric: %lu\n", ifmd->ifmd_data.ifi_metric);
                          ~~~     ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/src/tools/tools/ifinfo/ifinfo.c:268:24: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
        if (type <= 0 || type >= NIFTYPES) {
                         ~~~~ ^  ~~~~~~~~
/usr/src/tools/tools/ifinfo/ifinfo.c:277:12: error: unused parameter 'type' [-Werror,-Wunused-parameter]
ifphys(int type, int phys)
4 errors generated.
*** Error code 1

make: stopped in /usr/src/tools/tools/ifinfo
Comment 1 Maxim Konovalov freebsd_committer 2020-11-04 15:01:03 UTC
Hi Oliver,

Whitespace changes are not complete, there is at least one additional tab at the line #86 that should be removed.

It looks like ifphys() function doesn't do anything meaningful.  I'd suggest to remove it and all its traces completely.

All the rest looks sane.

Comment 2 Maxim Konovalov freebsd_committer 2020-11-04 15:04:31 UTC
Oops, I misspelled your name, Olivier.  Sorry about that.

Comment 3 Olivier Cochard freebsd_committer 2020-11-09 20:27:50 UTC
Improved patch here:
Comment 4 commit-hook freebsd_committer 2020-11-30 15:04:42 UTC
A commit references this bug:

Author: olivier
Date: Mon Nov 30 15:04:36 UTC 2020
New revision: 368188
URL: https://svnweb.freebsd.org/changeset/base/368188

  Fix compilation on head and while here:
  - remove unwanted whitespaces
  - remove useless function ifphys()
  - fix the Makefile to install it into /usr/bin

  PR:		250133
  Reviewed by:	glebius, maxim
  Approved by:	glebius
  Differential Revision:	https://reviews.freebsd.org/D27155