NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

misc/48812: npftest cannot be built without optimisation



>Number:         48812
>Category:       misc
>Synopsis:       npftest cannot be built without optimisation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 15 09:00:00 +0000 2014
>Originator:     Tyler
>Release:        NetBSD 6.1.4
>Organization:
None
>Environment:
System: NetBSD zora.localdomain 6.1.4 NetBSD 6.1.4 (GENERIC) amd64
Architecture: x86_64
Machine: amd64
>Description:

src/usr.sbin/npf/npftest/libnpftest/npf_table_test.c revision 1.5
introduced a change where a static const array (ip6_list) had portions
of the array populated using htons().

This will have fixed some endian bugs in the test.  However, compilation
of this code with optimisation -O0 now fails since ntohs() is replaced
with the bswap16() function from libc instead of a constant expression.

SuS v4 just says that ntohs() can be a macro not that it has to be so
probably they ought not to be used in a constant intialization context.

>How-To-Repeat:

Attempt to compile npf_table_test.c with COPTS = -O0.

/usr/src/usr.sbin/npf/npftest/libnpftest/npf_table_test.c:28:6: error: 
initializer element is not constant
      htons(0xfe80), 0x0, 0x0, 0x0,
      ^
/usr/src/usr.sbin/npf/npftest/libnpftest/npf_table_test.c:28:6: error: (near 
initialization for 'ip6_list[0][0]')

>Fix:

At least 2 ways to fix.

1. Define 2 versions of the array for each endianness and select at
   compile time.
2. Make the table non-const and initialize it prior to running the test at
   runtime.

Probably other options but those seem fairly obvious.



Home | Main Index | Thread Index | Old Index