Bug 258512 - net/ifdepd: fix build with clang 13
Summary: net/ifdepd: fix build with clang 13
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks: 258209
  Show dependency treegraph
 
Reported: 2021-09-15 12:12 UTC by Dimitry Andric
Modified: 2021-09-21 18:39 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (alex)


Attachments
net/ifdepd: fix clang 13 warnings and non-static inline functions (1.37 KB, patch)
2021-09-15 12:13 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer 2021-09-15 12:12:52 UTC
During an exp-run for llvm 13 (see bug 258209), it turned out that net/ifdepd fails to build with clang 13:

cc  -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Wall -Wnested-externs -Wpointer-arith -Winline -Wcast-qual -Wredundant-decls -c ifdepd.c -o ifdepd.o
ifdepd.c:420:4: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
          free(d_ints);
          ^
ifdepd.c:418:2: note: previous statement is here
        if (D)
        ^
ifdepd.c:434:4: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
          free(s_ints);
          ^
ifdepd.c:432:2: note: previous statement is here
        if (S)
        ^
2 warnings generated.
cc -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Wall -Wnested-externs -Wpointer-arith -Winline -Wcast-qual -Wredundant-decls -o ifdepd ifdepd.o
ld: error: undefined symbol: cleanup
>>> referenced by ifdepd.c
>>>               ifdepd.o:(main)
>>> referenced by ifdepd.c
>>>               ifdepd.o:(main)
>>> referenced by ifdepd.c
>>>               ifdepd.o:(main)
>>> referenced 1 more times
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

The warnings about misleading indentation are indicating an actual bug, which can be fixed by adding a few braces. The link error is because ifdepd uses an inline function without either static or extern specifier.
Comment 1 Dimitry Andric freebsd_committer 2021-09-15 12:13:24 UTC
Created attachment 227915 [details]
net/ifdepd: fix clang 13 warnings and non-static inline functions
Comment 2 Fernando Apesteguía freebsd_committer 2021-09-16 05:56:34 UTC
^Triage: Reporter is committer, assign accordingly.
Comment 3 alex 2021-09-21 12:27:55 UTC
Seems OK, please commit your patch.
Comment 4 commit-hook freebsd_committer 2021-09-21 18:30:50 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=adbaad235b4cfaa6571f3c1fb0bce2b23d50c400

commit adbaad235b4cfaa6571f3c1fb0bce2b23d50c400
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-09-21 18:26:13 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-09-21 18:26:13 +0000

    net/ifdepd: fix clang 13 warnings and non-static inline functions

    Building net/ifdepd with clang and lld 13 results in a few warnings, and
    a link error:

    cc  -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Wall -Wnested-externs -Wpointer-arith -Winline -Wcast-qual -Wredundant-decls -c ifdepd.c -o ifdepd.o
    ifdepd.c:420:4: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
              free(d_ints);
              ^
    ifdepd.c:418:2: note: previous statement is here
            if (D)
            ^
    ifdepd.c:434:4: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
              free(s_ints);
              ^
    ifdepd.c:432:2: note: previous statement is here
            if (S)
            ^
    2 warnings generated.
    cc -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Wall -Wnested-externs -Wpointer-arith -Winline -Wcast-qual -Wredundant-decls -o ifdepd ifdepd.o
    ld: error: undefined symbol: cleanup
    >>> referenced by ifdepd.c
    >>>               ifdepd.o:(main)
    >>> referenced by ifdepd.c
    >>>               ifdepd.o:(main)
    >>> referenced by ifdepd.c
    >>>               ifdepd.o:(main)
    >>> referenced 1 more times
    cc: error: linker command failed with exit code 1 (use -v to see invocation)
    *** Error code 1

    The warnings about misleading indentation are indicating an actual bug,
    which can be fixed by adding a few braces. The link error is because
    ifdepd uses an inline function without either a static or an extern
    specifier. Fix this by adding a static specifier.

    Approved by:    alex@hugo.bmg.gv.at (maintainer)
    PR:             258512
    MFH:            2021Q3

 net/ifdepd/Makefile                   |  1 +
 net/ifdepd/files/patch-ifdepd.c (new) | 44 +++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)