From patchwork Wed Nov 26 13:52:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 5385571 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 87D7B9F39B for ; Wed, 26 Nov 2014 13:52:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC61F201C7 for ; Wed, 26 Nov 2014 13:52:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A57E22015E for ; Wed, 26 Nov 2014 13:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751485AbaKZNwM (ORCPT ); Wed, 26 Nov 2014 08:52:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42163 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750967AbaKZNwL (ORCPT ); Wed, 26 Nov 2014 08:52:11 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAQDq9DK023410 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 26 Nov 2014 08:52:09 -0500 Received: from redhat.com (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id sAQDq7kR027225; Wed, 26 Nov 2014 08:52:08 -0500 Date: Wed, 26 Nov 2014 15:52:07 +0200 From: "Michael S. Tsirkin" To: Josh Triplett Cc: linux-sparse@vger.kernel.org Subject: sparse false positive in net/packet/af_packet.c Message-ID: <20141126135207.GA5480@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sparse triggers warnings in net/packet/af_packet.c in upstream Linux. This is with sparse 0.5.0 in Fedora 20. See below for more info. I worked around this in source, but I think it's a good idea to fix it in sparse as well, isn't it? ----- Forwarded message from "Michael S. Tsirkin" ----- Date: Mon, 24 Nov 2014 13:32:16 +0200 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: "David S. Miller" , Daniel Borkmann , Eric Dumazet , Atzm Watanabe , Hannes Frederic Sowa , Tom Herbert , netdev@vger.kernel.org Subject: [PATCH] af_packet: fix sparse warning Message-ID: <1416828696-3989-1-git-send-email-mst@redhat.com> af_packet produces lots of these: net/packet/af_packet.c:384:39: warning: incorrect type in return expression (different modifiers) net/packet/af_packet.c:384:39: expected struct page [pure] * net/packet/af_packet.c:384:39: got struct page * this seems to be because sparse does not realize that _pure refers to function, not the returned pointer. Tweak code slightly to avoid the warning. Signed-off-by: Michael S. Tsirkin --- net/packet/af_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d4a877e..586229a 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -378,7 +378,7 @@ static void unregister_prot_hook(struct sock *sk, bool sync) __unregister_prot_hook(sk, sync); } -static inline __pure struct page *pgv_to_page(void *addr) +static inline struct page * __pure pgv_to_page(void *addr) { if (is_vmalloc_addr(addr)) return vmalloc_to_page(addr);