From patchwork Thu Dec 10 21:44:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: laurent chavey X-Patchwork-Id: 40892 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 6AAF8B6F0E for ; Fri, 11 Dec 2009 08:45:08 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761722AbZLJVoy (ORCPT ); Thu, 10 Dec 2009 16:44:54 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761723AbZLJVox (ORCPT ); Thu, 10 Dec 2009 16:44:53 -0500 Received: from smtp-out.google.com ([216.239.45.13]:41693 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761709AbZLJVow (ORCPT ); Thu, 10 Dec 2009 16:44:52 -0500 Received: from spaceape8.eur.corp.google.com (spaceape8.eur.corp.google.com [172.28.16.142]) by smtp-out.google.com with ESMTP id nBALivjp012190; Thu, 10 Dec 2009 13:44:58 -0800 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1260481499; bh=iR1DbfM2m1ZuK+CV1fgHXlufSXE=; h=From:Date:Message-Id:To:CC:Subject; b=EUlqXHy9ijE8Bj4WaKh6ngCjgFEJJ+sAsq2wbcZK5GUI7B9Kr71ZVfq6tPkTc+3A5 KA+EjpXo3dt/NW9jSZebQ== DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=from:date:message-id:to:cc:subject:x-system-of-record; b=WHKKjyE7WCDtuug6U1+0OH7QBdhGaRtaXCrFXK+sS9X9SrN3d7IM0i/g4G7tCISyy /nFS7ZMm04ayJQDiFUExQ== Received: from ywh7 (ywh7.prod.google.com [10.192.8.7]) by spaceape8.eur.corp.google.com with ESMTP id nBALis3Y005566; Thu, 10 Dec 2009 13:44:54 -0800 Received: by ywh7 with SMTP id 7so311533ywh.24 for ; Thu, 10 Dec 2009 13:44:53 -0800 (PST) Received: by 10.150.21.26 with SMTP id 26mr1113355ybu.192.1260481493773; Thu, 10 Dec 2009 13:44:53 -0800 (PST) Received: from chavey.mtv.corp.google.com (chavey.mtv.corp.google.com [172.22.64.28]) by mx.google.com with ESMTPS id 4sm468455ywi.57.2009.12.10.13.44.52 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 10 Dec 2009 13:44:53 -0800 (PST) From: chavey@google.com Date: Thu, 10 Dec 2009 13:44:50 -0800 Message-Id: To: davem@davemloft.net CC: netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, chavey@google.com, eric.dumazet@gmail.com, akpm@google.com Subject: [PATCH] netfilter: Fix compiler warning. X-System-Of-Record: true Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fix compiler warning "discards qualifiers from pointer target type", by allowing explicit discard of const qualifier thru type casting. The const_cast() macro is taken from a patch from Kaveh R. Ghazi [PATCH]: Fix problematic -Wcast-qual cases using new CONST_CAST macro posted on http://old.nabble.com/-PATCH-:-Fix-problematic--Wcast-qual-cases-using-new-CONST_CAST--macro-td11824676.html The proposed __nowarn__ keyword has not yet been implemented, (see http://gcc.gnu.org/ml/gcc-patches/2009-11/msg01261.html). Signed-off-by: Laurent Chavey --- include/linux/kernel.h | 12 ++++++++++++ net/ipv4/netfilter/ipt_ULOG.c | 2 +- net/netfilter/xt_time.c | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 3fa4c59..0246771 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -710,4 +710,16 @@ struct sysinfo { # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD #endif +/* Cast away const-ness to pass -Wcast-qual */ +#ifdef __GNUC__ +union gcc_constcast +{ + const void *cv; + void *v; +}; +#define const_cast(X) ((__extension__(union gcc_constcast)(const void *)(X)).v) +#else +#define const_cast(X) ((void *)(X)) +#endif + #endif diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c index d32cc4b..c8f8b8b 100644 --- a/net/ipv4/netfilter/ipt_ULOG.c +++ b/net/ipv4/netfilter/ipt_ULOG.c @@ -210,7 +210,7 @@ static void ipt_ulog_packet(unsigned int hooknum, /* We might not have a timestamp, get one */ if (skb->tstamp.tv64 == 0) - __net_timestamp((struct sk_buff *)skb); + __net_timestamp((struct sk_buff *)const_cast(skb)); /* copy hook, prefix, timestamp, payload, etc. */ pm->data_len = copy_len; diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c index 93acaa5..8f34a4a 100644 --- a/net/netfilter/xt_time.c +++ b/net/netfilter/xt_time.c @@ -170,7 +170,7 @@ time_mt(const struct sk_buff *skb, const struct xt_match_param *par) * it arrived at the right moment before 13:00. */ if (skb->tstamp.tv64 == 0) - __net_timestamp((struct sk_buff *)skb); + __net_timestamp((struct sk_buff *)const_cast(skb)); stamp = ktime_to_ns(skb->tstamp); stamp = div_s64(stamp, NSEC_PER_SEC);