From patchwork Thu Oct 13 23:13:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Brandeburg X-Patchwork-Id: 682069 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.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sw6BB3l8Tz9s9N for ; Fri, 14 Oct 2016 10:19:14 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752105AbcJMXTK (ORCPT ); Thu, 13 Oct 2016 19:19:10 -0400 Received: from mga11.intel.com ([192.55.52.93]:12842 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbcJMXTJ (ORCPT ); Thu, 13 Oct 2016 19:19:09 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 13 Oct 2016 16:17:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,490,1473145200"; d="scan'208";a="1044414579" Received: from jbrandeb-hsm2.jf.intel.com ([134.134.3.81]) by orsmga001.jf.intel.com with ESMTP; 13 Oct 2016 16:17:18 -0700 From: Jesse Brandeburg To: netdev@vger.kernel.org Subject: [PATCH NET] ethtool: silence warning on bit loss Date: Thu, 13 Oct 2016 16:13:55 -0700 Message-Id: <1476400435-18400-1-git-send-email-jesse.brandeburg@intel.com> X-Mailer: git-send-email 2.1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Sparse was complaining when we went to prototype some code using ethtool_cmd_speed_set and SPEED_100000, which uses the upper 16 bits of __u32 speed for the first time. CHECK ... .../uapi/linux/ethtool.h:123:28: warning: cast truncates bits from constant value (186a0 becomes 86a0) The warning is actually bogus, as no bits are really lost, but we can get rid of the sparse warning with this one small change. Reported-by: Preethi Banala Signed-off-by: Jesse Brandeburg --- include/uapi/linux/ethtool.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 099a420..8e54723 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -119,8 +119,7 @@ struct ethtool_cmd { static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, __u32 speed) { - - ep->speed = (__u16)speed; + ep->speed = (__u16)(speed & 0xFFFF); ep->speed_hi = (__u16)(speed >> 16); }