Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2383341yba; Sat, 27 Apr 2019 23:02:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDMZVV2ZrzLDmapZdWAnDS1vIv+VZQCvYE1EB7BKROHE2VbQr423WWA7PpAKCj6R1K8ZBJ X-Received: by 2002:a63:de0a:: with SMTP id f10mr42547206pgg.418.1556431353927; Sat, 27 Apr 2019 23:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556431353; cv=none; d=google.com; s=arc-20160816; b=AwpUji7Heiy1tm+6WZRbQt/YFdZ6KwKpuOjsM2op8xkEMEh2tFglbP9JDfa2uvZ2GB Qq8y+rrX+vHpRzGLk41wAEI/lgO27WboHRV3S+6ERWIVr+73daaLc0WCtAIPSTaE0GVA Ug7UiuAywpECT7bHJFjz3zugJOXmlW/bHvNynk0X5mJl5ukpIPZ3Y0dut/hW2zQBkDuX eSPwLzMq5DPw41WgV6TgWavG5SgyghFrziWHaMwp62j/4lqoNduI/yz5Ngk1Z5O3QPiY xd+HMNSwSeqdaexfwMCrXNJugseVfrwJZBM0zOVgmmQbf3n2Mlabz+3XGTbK4I+LSyJ1 QNeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=mT78fvk1XUXUu7KREoYCUBZSju7K01Ug5ehcVbM3eP8=; b=PDLVeoc/FtTPAKpj2Ojn5x4C0ptUJK1Inh8vbgGFbjxR8wJcZtT4d0Qq7JICJBGFYe 5H2jvzha7YuABqXp/hSlWjxlIlWZi0Yu5CxQlUKu55rEXZwGNwbKr5/TpVGoNxn6LIus Taio7IeNPsfmZN0D8hhjKpOHrtf9oQtZoP3blOuWZWHD23k9nZeHc0pujaMga4aO7jS9 E3E/5TI3Vn0VdQ/bq8lsM4FwJrf/IDDXPrbZh6uMVNPizUsJvs1AXymZWfsQ03vnxRwl JNK1UHxNK2X7CiYBvSz6wG6tDpcW8lulEfaTRCMg83DIInm1tHxFoff1fEsTbG9uOlaf 7DzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h65si32271658pfd.232.2019.04.27.23.02.08; Sat, 27 Apr 2019 23:02:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726425AbfD1GAt (ORCPT + 99 others); Sun, 28 Apr 2019 02:00:49 -0400 Received: from www.osadl.org ([62.245.132.105]:57046 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbfD1GAt (ORCPT ); Sun, 28 Apr 2019 02:00:49 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id x3S60YrZ009468; Sun, 28 Apr 2019 08:00:35 +0200 From: Nicholas Mc Guire To: Jamal Hadi Salim Cc: Cong Wang , Jiri Pirko , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] net_sched: force endianness annotation Date: Sun, 28 Apr 2019 07:54:59 +0200 Message-Id: <1556430899-11018-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While the endiannes is being handled correctly sparse was unhappy with the missing annotation as be16_to_cpu()/be32_to_cpu() expects a __be16 respectively __be32. To mitigate this annotation issue forced annotation is introduced. Note that this patch has no impact on the generated binary. Signed-off-by: Nicholas Mc Guire --- Problem located by an experimental cocci script to locate sparse annontation isues. net/sched/em_cmp.c:44:31: warning: cast to restricted __be16 net/sched/em_cmp.c:44:31: warning: cast to restricted __be16 net/sched/em_cmp.c:44:31: warning: cast to restricted __be16 net/sched/em_cmp.c:44:31: warning: cast to restricted __be16 net/sched/em_cmp.c:54:31: warning: cast to restricted __be32 net/sched/em_cmp.c:54:31: warning: cast to restricted __be32 net/sched/em_cmp.c:54:31: warning: cast to restricted __be32 net/sched/em_cmp.c:54:31: warning: cast to restricted __be32 net/sched/em_cmp.c:54:31: warning: cast to restricted __be32 net/sched/em_cmp.c:54:31: warning: cast to restricted __be32 This is due to the variable being converted and thus the type is the teget system type and it must be caset to __be16/__be32 here for sparse to understand that endianness is adequately handled. Patch was compile-tested with: x86_64_defconfig Verification that the patch has no impact on the binary being generated was done by diff on the binary before and after applying the patch. Patch is against 5.1-rc6 (localversion-next is next-20190426) net/sched/em_cmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sched/em_cmp.c b/net/sched/em_cmp.c index 1c8360a..3045ee1 100644 --- a/net/sched/em_cmp.c +++ b/net/sched/em_cmp.c @@ -41,7 +41,7 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em, val = get_unaligned_be16(ptr); if (cmp_needs_transformation(cmp)) - val = be16_to_cpu(val); + val = be16_to_cpu((__force __be16)val); break; case TCF_EM_ALIGN_U32: @@ -51,7 +51,7 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em, val = get_unaligned_be32(ptr); if (cmp_needs_transformation(cmp)) - val = be32_to_cpu(val); + val = be32_to_cpu((__force __be32)val); break; default: -- 2.1.4