Bug 230623 - net/pkt-gen: fails to build with Clang 7
Summary: net/pkt-gen: fails to build with Clang 7
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Stephen Hurd
URL:
Keywords: needs-patch
Depends on:
Blocks: 230355
  Show dependency treegraph
 
Reported: 2018-08-14 18:56 UTC by Jan Beich
Modified: 2018-08-15 02:34 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2018-08-14 18:56:28 UTC
$ poudriere jail -cj clang7 -a amd64 -v projects/clang700-import -m svn+https
$ poudriere testport -j clang7 net/pkt-gen
[...]
cc -O2 -pipe -Werror -Wall -Wunused-function -I ../../sys -I ../../apps/include -Wextra   -fstack-protector  pkt-gen.c  -lpthread -lm -lpcap -o pkt-gen
pkt-gen.c:729:15: error: setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments? [-Werror,-Wmemset-transposed-args]
                memset(buf, sizeof(buf), ' ');
                            ^
pkt-gen.c:729:15: note: cast the second argument to 'int' to silence

http://package18.nyi.freebsd.org/data/headamd64PR230355-default/2018-08-11_19h01m06s/logs/errors/pkt-gen-g2017.08.06_1.log
Comment 1 Jan Beich freebsd_committer freebsd_triage 2018-08-14 19:06:19 UTC
-Werror shouldn't be enabled outside of maintainer mode for unimportant warnings (e.g., -Wall -Wextra -Wunused-function) as it tends to break build on each compiler upgrade/change/etc. -Wmemset-transposed-args is already enabled by default, so you can either promote it to -Werror=memset-transposed-args while dropping global -Werror or trim unimportant warnings but keep global -Werror.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2018-08-14 19:12:34 UTC
-Werror may affect build on GCC platforms (powerpc*, sparc64, mips*). Below is USE_GCC=8 output. As you can guess, most issues are caused by -Wall.

pkt-gen.c:209:3: error: alignment 1 of 'struct <anonymous>' is less than 2 [-Werror=packed-not-aligned]
   } __attribute__((__packed__)) ipv4;
   ^
pkt-gen.c: In function 'ping_body':
pkt-gen.c:1375:13: error: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Werror=restrict]
     sprintf(buf, "%s %5d", buf, (int)buckets[j]);
             ^~~            ~~~
pkt-gen.c:1375:22: error: '%5d' directive writing between 5 and 11 bytes into a region of size between 0 and 511 [-Werror=format-overflow=]
     sprintf(buf, "%s %5d", buf, (int)buckets[j]);
                      ^~~
pkt-gen.c:1375:18: note: using the range [-2147483648, 2147483647] for directive argument
     sprintf(buf, "%s %5d", buf, (int)buckets[j]);
                  ^~~~~~~~
pkt-gen.c:1375:5: note: 'sprintf' output between 7 and 524 bytes into a destination of size 512
     sprintf(buf, "%s %5d", buf, (int)buckets[j]);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkt-gen.c: In function 'txseq_body':
pkt-gen.c:1968:3: error: 'sum' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   memcpy(targ->g->af == AF_INET ? &pkt->ipv4.udp.uh_sum : &pkt->ipv6.udp.uh_sum, &sum, sizeof(sum));
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkt-gen.c: In function 'main':
pkt-gen.c:2455:42: error: '%s' directive output may be truncated writing up to 39 bytes into a region of size between 21 and 60 [-Werror=format-truncation=]
    snprintf(b4, sizeof(b4), "[avg/std %s/%s pps]",
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
      norm(b1, ppsavg, normalize), norm(b2, ppsdev, normalize));
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkt-gen.c:2455:4: note: 'snprintf' output between 16 and 94 bytes into a destination of size 70
    snprintf(b4, sizeof(b4), "[avg/std %s/%s pps]",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      norm(b1, ppsavg, normalize), norm(b2, ppsdev, normalize));
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Comment 3 commit-hook freebsd_committer freebsd_triage 2018-08-15 02:27:20 UTC
A commit references this bug:

Author: shurd
Date: Wed Aug 15 02:26:35 UTC 2018
New revision: 477211
URL: https://svnweb.freebsd.org/changeset/ports/477211

Log:
  Disable extra warnings and especially -Werror

  -Wall and -Wextra tend to highlight new compiler features, not new problems.
  They don't need to be on when building a port... -Werror just makes them
  worse.

  PR:		230623
  Reported by:	jbeich@
  Sponsored by:	Limelight Networks

Changes:
  head/net/pkt-gen/files/patch-pkt-gen_GNUmakefile
Comment 4 Stephen Hurd freebsd_committer freebsd_triage 2018-08-15 02:33:56 UTC
Submitted a pull request for the memset() issue upstream, though it doesn't actually appear the memset() is useful anyway.

Added a patch to remove -Werror, -Wall, and -Wextra for pkg-gen build.

I'll likely dig into the rest next time I update the port.  Thanks for the report.