NetBSD Problem Report #48812

From rtr@zora.localdomain  Thu May 15 08:56:36 2014
Return-Path: <rtr@zora.localdomain>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B4BBDA5813
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 15 May 2014 08:56:35 +0000 (UTC)
Message-Id: <20140515074022.AE66A26ED18@zora.localdomain>
Date: Thu, 15 May 2014 07:40:22 +0000 (UTC)
From: rtr@netbsd.org
Reply-To: rtr@netbsd.org
To: gnats-bugs@gnats.NetBSD.org
Subject: npftest cannot be built without optimisation
X-Send-Pr-Version: 3.95

>Number:         48812
>Category:       misc
>Synopsis:       npftest cannot be built without optimisation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 15 09:00:00 +0000 2014
>Closed-Date:    Sat Mar 17 10:46:34 +0000 2018
>Last-Modified:  Sat Mar 17 10:46:34 +0000 2018
>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.

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: maxv@NetBSD.org
State-Changed-When: Sat, 17 Mar 2018 10:46:34 +0000
State-Changed-Why:
Fixed in 2016, but thanks for the report.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.