Bug 196166

Summary: Fix net/mrouted build with clang 3.5.0
Product: Ports & Packages Reporter: Dimitry Andric <dim>
Component: Individual Port(s)Assignee: Hiroki Sato <hrs>
Status: Closed FIXED    
Severity: Affects Many People CC: kwm
Priority: --- Flags: bugzilla: maintainer-feedback? (hrs)
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 195480    
Attachments:
Description Flags
Fix net/mrouted build with clang 3.5.0 none

Description Dimitry Andric freebsd_committer freebsd_triage 2014-12-20 19:37:30 UTC
Created attachment 150819 [details]
Fix net/mrouted build with clang 3.5.0

The net/mrouted port fails to compile with clang 3.5.0, due to the following -Werror warning:

mtrace.c:923:12: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
        if (*s || abs(ntohl(n->tr_vifout) - ntohl(p->tr_vifout)) > 100000) {
                  ^
mtrace.c:923:12: note: remove the call to 'abs' since unsigned values cannot be negative
        if (*s || abs(ntohl(n->tr_vifout) - ntohl(p->tr_vifout)) > 100000) {
                  ^~~
1 error generated.

This is a bug in the code, because the return value of ntohl() is unsigned, and the difference of two unsigned quantities is still unsigned.  However, the intent of the expression is to look at the absolute difference between the two quantities.

Therefore, similar to head r274898 [1] for rtadvd, introduce a small static function that clarifies the intent, and call it instead.

[1] https://svnweb.freebsd.org/base?view=revision&revision=274898
Comment 1 Bugzilla Automation freebsd_committer freebsd_triage 2014-12-20 19:37:30 UTC
Auto-assigned to maintainer hrs@FreeBSD.org
Comment 2 Koop Mast freebsd_committer freebsd_triage 2015-02-23 00:14:27 UTC
Any progress on this? Else I would like to commit this after a week.
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-03-02 10:50:51 UTC
A commit references this bug:

Author: kwm
Date: Mon Mar  2 10:50:15 UTC 2015
New revision: 380247
URL: https://svnweb.freebsd.org/changeset/ports/380247

Log:
  Fix the build with clang 3.5.

  PR:		196166
  Submitted by:	dim@
  Approved by:	maintainer (timeout 6 weeks)

Changes:
  head/net/mrouted/files/patch-mtrace.c