🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27173

[PATCH net-next 3/5] ixgbe: use int instead of u32 for error code variables

#27173
From: Tony Nguyen
Date: Fri, 04 Dec 2026 22:38
140 lines
14175 bytes
From: Aleksandr Loktionov <aleksandr.loktionov@intel.com>

The variables used to store return values of kernel and driver functions
throughout the ixgbe driver are declared as u32 in several places.  Such
functions return negative errno values on error (e.g. -EIO, -EFAULT),
which are sign-extended negative integers.  Storing them in an unsigned
u32 silently wraps the value: -EIO (0xFFFFFFF7) stored in u32 becomes a
large positive number, so any "if (status)" truthiness check still works
by accident, but comparisons against specific negative error codes or
propagation up the call stack produce wrong results.

In the Linux kernel, u32 is reserved for fixed-width quantities used in
hardware interfaces or protocol structures.  Using it for generic error
codes misleads reviewers into thinking the value is hardware-constrained.

Change all such local variables from u32 to int driver-wide: one in
ixgbe_main.c (ixgbe_resume), three in ixgbe_phy.c
(ixgbe_identify_phy_generic, ixgbe_tn_check_overtemp,
ixgbe_set_copper_phy_power), and six in ixgbe_x550.c
(ixgbe_check_link_t_X550em, ixgbe_get_lasi_ext_t_x550em,
ixgbe_enable_lasi_ext_t_x550em, ixgbe_handle_lasi_ext_t_x550em,
ixgbe_ext_phy_t_x550em_get_link, ixgbe_setup_internal_phy_t_x550em).

No functional change.

Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Alexander Nowlin <alexander.nowlin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c  |  6 +++---
 drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 12 ++++++------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 9266a920d279..b23a482c4460 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7560,7 +7560,7 @@ static int ixgbe_resume(struct device *dev_d)
 	struct pci_dev *pdev = to_pci_dev(dev_d);
 	struct ixgbe_adapter *adapter = pci_get_drvdata(pdev);
 	struct net_device *netdev = adapter->netdev;
-	u32 err;
+	int err;
 
 	adapter->hw.hw_addr = adapter->io_addr;
 
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
index ab733e73927d..de8f6c61082d 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
@@ -262,7 +262,7 @@ static bool ixgbe_probe_phy(struct ixgbe_hw *hw, u16 phy_addr)
  **/
 int ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
 {
-	u32 status = -EFAULT;
+	int status = -EFAULT;
 	u32 phy_addr;
 
 	if (!hw->phy.phy_semaphore_mask) {
@@ -2811,7 +2811,7 @@ static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
 bool ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
 {
 	u16 phy_data = 0;
-	u32 status;
+	int status;
 
 	if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
 		return false;
@@ -2831,7 +2831,7 @@ bool ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
  **/
 int ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
 {
-	u32 status;
+	int status;
 	u16 reg;
 
 	/* Bail if we don't have copper phy */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
index 4a0ccbf448a2..b41b0676e177 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
@@ -1911,7 +1911,7 @@ static int ixgbe_check_link_t_X550em(struct ixgbe_hw *hw,
 				     bool *link_up,
 				     bool link_up_wait_to_complete)
 {
-	u32 status;
+	int status;
 	u16 i, autoneg_status;
 
 	if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
@@ -2330,7 +2330,7 @@ static int ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
 static int ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc,
 				       bool *is_overtemp)
 {
-	u32 status;
+	int status;
 	u16 reg;
 
 	*is_overtemp = false;
@@ -2418,7 +2418,7 @@ static int ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc,
 static int ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
 {
 	bool lsc, overtemp;
-	u32 status;
+	int status;
 	u16 reg;
 
 	/* Clear interrupt flags */
@@ -2512,7 +2512,7 @@ static int ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw,
 {
 	struct ixgbe_phy_info *phy = &hw->phy;
 	bool lsc;
-	u32 status;
+	int status;
 
 	status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc, is_overtemp);
 	if (status)
@@ -2606,7 +2606,7 @@ static int ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
  **/
 static int ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
 {
-	u32 ret;
+	int ret;
 	u16 autoneg_status;
 
 	*link_up = false;
@@ -2642,7 +2642,7 @@ static int ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
 {
 	ixgbe_link_speed force_speed;
 	bool link_up;
-	u32 status;
+	int status;
 	u16 speed;
 
 	if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
-- 
2.47.1
Technical Details
Message-ID: <20261204223807.3920143-4-anthony.l.nguyen@intel.com>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377711-linux-kernel-netdev=dewy.ru
References: <20261204223807.3920143-1-anthony.l.nguyen@intel.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377711-linux-kernel-netdev=dewy.ru
From: anthony.l.nguyen@intel.com (Tony Nguyen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 3/5] ixgbe: use int instead of u32 for error code variables
Date: Fri,  4 Dec 2026 14:38:03 -0800
Organization: Usenet Network
Message-ID: <20261204223807.3920143-4-anthony.l.nguyen@intel.com>
References: <20261204223807.3920143-1-anthony.l.nguyen@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2891959"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:tfF/Xdsj4P3KeVQyFblW0bWL3DY= sha256:w60bp7oQTGU2bsRneMTvJI6S35duQ7mD08LLXLSJlpc=
	sha1:ckAvLQ4GTBf3mqrv36BaE/Ql8VU= sha256:1igE/L4YOA7KqejiLoCuxrnyECRlsxhHu6+lnJwmauM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 8CB6D117D18; Sat,  5 Dec 2026 01:38:33 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.541
X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=intel.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id j1UYUdWTXYS9;
	Sat,  5 Dec 2026 01:38:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-377711-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=intel.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 0D775117D17; Sat,  5 Dec 2026 01:38:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 03115605B53; Fri,  4 Dec 2026 22:38:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796423898;
	b=jHbqs7gLuF0thVVeDOwQGIJtCqn3hbUz5E+uiJYPpDPG9QPv5cIAIW4uYB8AI+m7qFw4
	 FPpAqzNS5EIGqLYlcwMPAoe61+6FSzi7/2pwsnjiNcD8SlQX4zg5DGv3KhDqX6xp5m5QY
	 gNjOjejJVqqFz6/k+g3E+pV1bMx6WtQh7y0TvwQ63Dfrc9h3oTuzbudecj/NkF946O3J1
	 fM6dmhT/QOMSjP7OGmEJO+onTbYepQA8SOu8x7pSx3hggvOMdNOwwEbc/vPb+3XePjnYS
	 SXa4UdYEb09dYluMeBMJNbl3LsAfZMSgUjgxVvBhGAJSETbloqEpXRI2OdaksJ7HwHQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796423898;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
	 X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV:X-IronPort-AV:
	 Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=p3yunLTT+2oIKqkuki8Zv6EQ5OARLyQoRGRt+3wXgt4=;
	b=2ePpsvlCnECD1VLCybgP2UZHSlRJVPQqJRBVTgzT2ojalogERA+McYvo67+Zkx2Iy+W3
	 qjF5Q3AAau6j9Pt2nh+leJCgSzigFlNsKuxZcAwNpVneQ6sMrwSNFjABVqZnoLncz4xSd
	 a8J0qG/L1igXAKPCwUmh3KVsTVKTULTK22foMd+M/uLA3CPmOrWt7IDdpVfE/GqtPwNvM
	 KvllEPNZ0DI21/CrOaKwz+9YK5ovau3hgcfYH1TYUfsyB76fw5+40P246I+gCT64tFgaQ
	 zdA6CuGuhYbzsbDhBpnXE4uanK91RQCMEE/luOmgA1HBDFMjzF8YKt68YRtNH+6M7qA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=eU9iHYHd;
	dmarc=pass header.from=intel.com;
	spf=pass smtp.mailfrom=intel.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 28B2B606A339;
	Fri,  4 Dec 2026 22:38:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=eU9iHYHd
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.11
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796423897;
	b=QwOe4n4KBGOA6/iAdYQuYdsPzIVgrUDzyDswXFrf0wtslhoP0e+h2f9egHSHwmppod/s
	 5B224cMa5od95QXQ3Paj6q1swhDhSRUWymt4ExsBdU2uSRLjUTICvNNms+xsvrsxOu56t
	 cM8ITV8yroxYUMCu6wctamFz8ty99Juv058fF2a6/ZzchMhWN8Yjm4Qeu5EyFBTdhKb7l
	 PKj5WGSkXT3gFQzVajrftd1yOfkZlby6GO2fmgVXhqE985B9czRy1IKZ8GiDZqLvVJOQB
	 uPBPSuCX9VV/qU9En2dkckZ/qP03Hwtz1A3ynNXwWg4e3QRMSxtooy1sOJ1K+RjOjXw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796423897;
	h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:
	 X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID:
	 X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=p3yunLTT+2oIKqkuki8Zv6EQ5OARLyQoRGRt+3wXgt4=;
	b=nPAwnynlEMH2yEMcy+EbBOeW8PNejrD3+nol5flHx9vBjWOVsityjXYZM4uCGsY4jqG0
	 73HGEolCQhy4FDfXnaC2bbLNpa1BxPeToWFNNCK5AS80CbdE0lFzUMeckSOzcDaWGI8uD
	 493EsKwol70d+MQGJU758lRh4FZp1C6VuisP4n+hgZY9vT7r0Z1u5WmSn7oMOmGFcnbsq
	 siCoZSPvYYmF50ljwG2sHj9MWUbR0uAK0uH/ZbqfRBJmSGCNxoR981SqK5MM29WttDjY/
	 AIOEdN0ASpqvzcwF7p31/p0fr7akfpVSLvtWGsMXUxZsu2fPIRvsYOM0qw1H0jFOTTg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=intel.com;
	spf=pass smtp.mailfrom=intel.com;
	dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=eU9iHYHd;
	arc=none smtp.remote-ip=198.175.65.11
X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id E786A606A335
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 22:38:16 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E786A606A335
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1796423897; x=1827959897;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=p3yunLTT+2oIKqkuki8Zv6EQ5OARLyQoRGRt+3wXgt4=;
  b=eU9iHYHdlW93lK2sADeXJ68QC6Lm62U8n2oC9kcI3vCaoHA4OF/XMq0m
   PKcXjCeNjCLRlWL9hT9EQD+41LeC1lqwLmcPteRGWTgqLpbd1cL+Cpl7p
   IUEINwN260n14J4dHhEcl/OYPyEMuYHodaUj39SHzEMNm1jFcYqADu6Pp
   JpJQmifkAwGIZz517dAcBGPADKaCVn2TyVACcJnhxS+fiN3lWX/PqK/E/
   QZKIOkbZfJzpEMT74ludjeaS+UxYbVtQQ2q7OZYXyf5R/qJbeiTKG+1y4
   dIgZ39xKXZqlhrrcDRxLas+w/bwZyP+L2uK3Bi83ukv6RUxoWW/NAnANK
   g==;
X-CSE-ConnectionGUID: POSBhpkyRiSTTLqMSAVZcg==
X-CSE-MsgGUID: H2N3F00HS1ekNxgrgydeKA==
X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="5316107"
X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; 
   d="scan'208";a="5316107"
X-Received: from orviesa008.jf.intel.com ([10.64.159.148])
  by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 14:38:15 -0800
X-CSE-ConnectionGUID: w8Svx5XtSHGW2BuvWrl+mA==
X-CSE-MsgGUID: 6z6H1eMCQyyxdc/BoWWQcg==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; 
   d="scan'208";a="13966839"
X-Received: from anguy11-upstream.jf.intel.com ([10.166.9.133])
  by orviesa008.jf.intel.com with ESMTP; 04 Dec 2026 14:38:14 -0800
X-Cc: Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
	anthony.l.nguyen@intel.com,
	jedrzej.jagielski@intel.com,
	jacob.e.keller@intel.com,
	adiyenga@cisco.com,
	Simon Horman <horms@kernel.org>,
	Alexander Nowlin <alexander.nowlin@intel.com>
X-Mailer: git-send-email 2.47.1
X-In-Reply-To: <20261204223807.3920143-1-anthony.l.nguyen@intel.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list