Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp290511rdb; Thu, 25 Jan 2024 15:59:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbe0Ly/b1hjWWYUa0d3Bb6VITw7jMQUy6vDsfKNwproHx207cLQWuVTHyZXPes8Bij/YTE X-Received: by 2002:a17:90a:e7c2:b0:290:6ba3:4689 with SMTP id kb2-20020a17090ae7c200b002906ba34689mr315715pjb.98.1706227155156; Thu, 25 Jan 2024 15:59:15 -0800 (PST) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e7-20020a17090a684700b0028d90fb49eesi132024pjm.30.2024.01.25.15.59.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 15:59:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39430-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=AsXN9eHn; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-39430-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 80FE2B26398 for ; Thu, 25 Jan 2024 23:58:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF22D1B5A0; Thu, 25 Jan 2024 23:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AsXN9eHn" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8590175A1; Thu, 25 Jan 2024 23:57:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706227058; cv=none; b=J4ouqNL1UeZ9T71jh3ph9t2+lLvf4rVGTFYft0gvVNxV6DX0tbLZNdfHlXFa8HVRdiomtLU1V9mwUmVTt+c2nhMkHajoqRz+rWWr3DS/gl/85NY9D+nM/z1fq8Jd97G3p7x51nvkvdyYqdd1gFqgOLHYcTSuEf/ZeUrdb+jMrYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706227058; c=relaxed/simple; bh=yZBuOVK56XcD+IZGWPAQUigedfDATjZAltUsMaV/oCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r0Cb6Q18M/7N8d41M04swciBYTGuNJ9DHTIAfN94cqVYtliLkLeKJi4aBf18UCcATxj/MEDiwzTp8mJP/Q/1akCmdqrvc8Sjb6L9OBCrv8QNGMzlxbdTYgvjQ3dsCcaAtdyZ1j8M9fOkJz8Z+0g7gGKAD+ZyZ4aHSC6E6AAdCYc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AsXN9eHn; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706227057; x=1737763057; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yZBuOVK56XcD+IZGWPAQUigedfDATjZAltUsMaV/oCg=; b=AsXN9eHnOETaFKprBaa7HPHK0s94neoXJrTN+3vH99Sk9bxO707483Hp Qkhufllppwk+HZi7/QRnG3b6Y8/icnD/Kpp0RFDLNxN8EkyQtfcv2mt6I Z7SnN9ZW1p1QXVoBhNMbyZE4Lp84XuCbcDz4IQTFMSzjIeyqaP7hc+Srb ZYzATNSaVvp6CGg8tugSfpu4PkWHY53ZvqNEVWrTQo9PPF8s5mUkHT09z yzgClk6rO8oj+0A8OgVr5YGXYAexbbWxatDX9TbPF/ycmfHGMwmMfvBEy Es7U8iYzSmdaDODftDzaO7d5sRVTIdgJaSzTzb9ppPWn2JKwhz3DYwU2E Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="15867562" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="15867562" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 15:57:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="930191098" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="930191098" Received: from vcostago-mobl3.jf.intel.com ([10.24.14.99]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 15:57:34 -0800 From: Vinicius Costa Gomes To: brauner@kernel.org, amir73il@gmail.com, hu1.chen@intel.com Cc: miklos@szeredi.hu, malini.bhandaru@intel.com, tim.c.chen@intel.com, mikko.ylinen@intel.com, lizhen.you@intel.com, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Vinicius Costa Gomes Subject: [RFC v2 1/4] cleanup: Fix discarded const warning when defining guards Date: Thu, 25 Jan 2024 15:57:20 -0800 Message-ID: <20240125235723.39507-2-vinicius.gomes@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240125235723.39507-1-vinicius.gomes@intel.com> References: <20240125235723.39507-1-vinicius.gomes@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When defining guards for const types the void* return implicitly discards the const modifier. Be explicit about it. Compiler warning (gcc 13.2.1): /include/linux/cleanup.h:154:18: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 154 | { return *_T; } | ^~~ /include/linux/cred.h:193:1: note: in expansion of macro ‘DEFINE_GUARD’ 193 | DEFINE_GUARD(cred, const struct cred *, _T = override_creds_light(_T), | ^~~~~~~~~~~~ Signed-off-by: Vinicius Costa Gomes --- include/linux/cleanup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h index c2d09bc4f976..ac521c4521cd 100644 --- a/include/linux/cleanup.h +++ b/include/linux/cleanup.h @@ -151,7 +151,7 @@ static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \ #define DEFINE_GUARD(_name, _type, _lock, _unlock) \ DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \ static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \ - { return *_T; } + { return (void *)*_T; } #define DEFINE_GUARD_COND(_name, _ext, _condlock) \ EXTEND_CLASS(_name, _ext, \ -- 2.43.0