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.
Created attachment 227916 [details] net-mgmt/pmacct: mark unused but set variables with attributes
Thanks for the patch, please commit!
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(+)