Bug 258513 - net-mgmt/pmacct: fix build with clang 13
Summary: net-mgmt/pmacct: 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 13:33 UTC by Dimitry Andric
Modified: 2021-09-22 18:50 UTC (History)
0 users

See Also:
pi: maintainer-feedback+


Attachments
net-mgmt/pmacct: mark unused but set variables with attributes (1.46 KB, patch)
2021-09-15 13:34 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 freebsd_triage 2021-09-15 13:33:50 UTC
During an exp-run for llvm 13 (see bug 258209), it turned out that net-mgmt/pmacct fails to build with clang 13:

netflow9.c:2236:25: error: variable 'tot_len' set but not used [-Werror,-Wunused-but-set-variable]
                        u_int16_t flows = 0, tot_len = 0;
                                             ^
1 error generated.

In this particular instance, the 'tot_len' variable does not seem to have any purpose, nor does it have any further side-effects. There is one more instance of a set but unused variable 'label' in src/sflow.c, but the code there is also increasing a byte ptr, so it can't easily be eliminated.

For now I think it is best to mark these variables as unused, with an attribute. Alternatively, we can suppress the -Wunused-but-set warning for clang 13 and higher, but this requires a patch to the configure script.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2021-09-15 13:34:19 UTC
Created attachment 227916 [details]
net-mgmt/pmacct: mark unused but set variables with attributes
Comment 2 Kurt Jaeger freebsd_committer freebsd_triage 2021-09-15 18:37:40 UTC
Thanks for the patch, please commit!
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-09-22 18:46:47 UTC
A commit in branch main references this bug:

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

commit f508cdd3cc283c3ce68f7070eec18ce68573dfe5
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-09-22 18:43:17 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-09-22 18:43:17 +0000

    net-mgmt/pmacct: mark unused but set variables with attributes

    With clang 13, building net-mgmt/pmacct results in a number of warnings:

    netflow9.c:2236:25: error: variable 'tot_len' set but not used [-Werror,-Wunused-but-set-variable]
                            u_int16_t flows = 0, tot_len = 0;
                                                 ^

    In this particular instance, the 'tot_len' variable does not seem to
    have any purpose, nor does it have any further side-effects. There is
    one more instance of a set but unused variable 'label' in src/sflow.c,
    but the code there is also increasing a byte ptr, so it can't easily be
    eliminated. For now mark these variables as unused, with an attribute.

    Approved by:    pi (maintainer)
    PR:             258513
    MFC:            2021Q3

 net-mgmt/pmacct/Makefile                                      |  1 +
 .../pmacct/files/patch-src_nfprobe__plugin_netflow9.c (new)   | 11 +++++++++++
 net-mgmt/pmacct/files/patch-src_sflow.c (new)                 | 11 +++++++++++
 3 files changed, 23 insertions(+)