From owner-freebsd-current@FreeBSD.ORG Wed Feb 26 22:01:57 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DF5D6EF1; Wed, 26 Feb 2014 22:01:56 +0000 (UTC) Received: from mail-ea0-x22a.google.com (mail-ea0-x22a.google.com [IPv6:2a00:1450:4013:c01::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4B56E11C1; Wed, 26 Feb 2014 22:01:56 +0000 (UTC) Received: by mail-ea0-f170.google.com with SMTP id g15so1307162eak.15 for ; Wed, 26 Feb 2014 14:01:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=UWbSxvsdAQb+GxaaIsVDgcLL/GJONxmbgiHqzDQTImk=; b=kdDXn86YFRTmzV5Ade7j8PdhKAHvkMwBUWqZlcne2Hv/1rVnwQ35KSwBIvsFj0h3qn LIOKfoS1rc19wrPscIAjqMc/xSkmDxrk17FDR3sYpmEep+Q0HdlfzrChFOYhNd01yAFG OZg19OOrxewPWp25YpuVj5XIXmuq+zEIPchJqs3cvTzexorRgB6iV22nXpYPoUNwBdv7 akF3MiBGTIOu+NHBi8XtxwTQbl2WbwqDr/+cpSosgxiiRTOJOwdXwZ4c5d2frx199Hk2 fMNidiFgq+Mf2FrKQt8o9TrjMaTzh+cCTwC4BoHlI33wRb9Mob0+k5t+bAQstSvLwlT5 pttQ== MIME-Version: 1.0 X-Received: by 10.205.68.9 with SMTP id xw9mr2045bkb.112.1393452114469; Wed, 26 Feb 2014 14:01:54 -0800 (PST) Sender: chmeeedalf@gmail.com Received: by 10.205.21.68 with HTTP; Wed, 26 Feb 2014 14:01:54 -0800 (PST) In-Reply-To: <20140226212017.GY92037@funkthat.com> References: <20140226212017.GY92037@funkthat.com> Date: Wed, 26 Feb 2014 14:01:54 -0800 X-Google-Sender-Auth: uM9CFdjuhD_1E3ZSbhq9S8g-VUY Message-ID: Subject: Re: Build failure on PowerPC in pf From: Justin Hibbits To: Justin Hibbits , FreeBSD Current , Gleb Smirnoff Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Feb 2014 22:01:57 -0000 On Wed, Feb 26, 2014 at 1:20 PM, John-Mark Gurney wrote: > Justin Hibbits wrote this message on Wed, Feb 26, 2014 at 11:12 -0800: >> On Wed, Feb 26, 2014 at 10:32 AM, Justin Hibbits wrote: >> > Building on PowerPC I see the following failure: >> > >> > cc1: warnings being treated as errors >> > >> > /home/chmeee/freebsd/head/sys/modules/pf/../../netpfil/pf/pf_ioctl.c: >> > In function 'pfioctl': >> > /home/chmeee/freebsd/head/sys/modules/pf/../../netpfil/pf/pf_ioctl.c:1357:warning: >> > cast to pointer from integer of different size [-Wint-to-pointer-cast] >> > /home/chmeee/freebsd/head/sys/modules/pf/../../netpfil/pf/pf_ioctl.c:1359:warning: >> > cast to pointer from integer of different size [-Wint-to-pointer-cast] >> > /home/chmeee/freebsd/head/sys/modules/pf/../../netpfil/pf/pf_ioctl.c:1361:warning: >> > cast to pointer from integer of different size [-Wint-to-pointer-cast] >> > >> > struct pf_rule has counter_u64_t entries, which are actually pointers >> > to uint64_t's. These pointers get assigned from the result of >> > counter_u64_fetch(), which returns a uint64_t. Looks to me like >> > there's a bug in here, but I have no idea what to do to fix it. And >> > I'm surprised this hasn't been reported against other 32-bit >> > architectures. >> >> Replying to myself, it looks like this was broken by r261882. > > This comment says it all: > 1352 glebius 261882 /* > 1353 * XXXGL: this is what happens when internal kernel > 1354 * structures are used as ioctl API structures. > 1355 */ > > So, one way could be to use a union for the states: > union { > struct { > counter_u64_t states_cur; > counter_u64_t states_tot; > counter_u64_t src_nodes; > } k; > struct { > uint64_t states_cur; > uint64_t states_tot; > uint64_t src_nodes; > } u; > } u; > > The other option is to cast through uintptr_t... > > Even though it'd make the code a bit more ugly, I'd vote for the union, > since it's designed for what the code is trying to do... > > -- > John-Mark Gurney Voice: +1 415 225 5579 > > "All that I will do, has been done, All that I have, has not." Casting through uintptr_t eliminated the warning. But, like you said, the union is the better way to go. - Justin