From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 7AC332144CF for ; Mon, 10 Nov 2025 14:46:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762785991; cv=none; b=uH+IiWfzn0WrWPIUcr7JErY1ILzqF8NoMJkAWHjM6N6PUcTF+9ayYesNaXd+Q2Xb56CgGG9JxQORCqFmf1FhrzOzbms+5bb2kADMOfCV44jJHrEE0RrUPcUeu1yWXB9MHFWCweuO9ap15YruYaMwPbD2YsAemyYllcNxfzml2rM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762785991; c=relaxed/simple; bh=hNYPNXkZfEkeQ3fadek900BypbpKuNUggnRflRe9x44=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fAsEvhVttnDML83NCn7M3srFsRIoX0goxTUsHUhaBapa1pd8e/HSRtSEEClvYvxmoYYBhEOT8O5xYNdcS/HN5chzyuBWmk55kFC+1kg5SptDG9Zp8jsQQj95ITiYvFZ4DhobQJTkvosPRw6hJgan023rEEIJxLpOmMNlw0HMQLA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gV570sKi; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gV570sKi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1762785989; x=1794321989; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=hNYPNXkZfEkeQ3fadek900BypbpKuNUggnRflRe9x44=; b=gV570sKiVB8/x6kJopJV6G2pIKcA6WyzQyheyXIBKoARae2NIM+Wa6lr uLct3eK3sTqhbCHW+SMF45EKg/hT92FACHYsYtbMUAW42AJUzR5IixIW6 na2moITy3brasUrWhd5yIEpNqVhp++AlcF8FGkM5W/NrXSw0hvrvVMCt0 5jBFVHkeWC86pmbz5TXzQjl7UgxdlC2mkot+bibtER/QMBzP6KaheWecJ jqUlPsD4xmBRvXaymW6lDOZwjtIgS51GN445Mz9G+WhqpNpfn/+jpSMRm c1XD76tAhnjEpZyY5qQ85ws8NHkbOOWh5mMTRWGfNc6FutbzBOrtfF/Jp Q==; X-CSE-ConnectionGUID: zdOOgmkATiWg6Boeh5ocdg== X-CSE-MsgGUID: vuBjB1DrRzugb9mCj4/jUw== X-IronPort-AV: E=McAfee;i="6800,10657,11531"; a="64744923" X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="64744923" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2025 06:46:29 -0800 X-CSE-ConnectionGUID: g9jy/EdTRX6uBcXlthhDww== X-CSE-MsgGUID: +pPfAfxOQ42eJoBumt+V4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,293,1754982000"; d="scan'208";a="187997955" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa010.jf.intel.com with ESMTP; 10 Nov 2025 06:46:27 -0800 Received: by black.igk.intel.com (Postfix, from userid 1003) id 1EB6595; Mon, 10 Nov 2025 15:46:26 +0100 (CET) From: Andy Shevchenko To: Andy Shevchenko , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Xiubo Li , Ilya Dryomov , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Subject: [PATCH v1 1/1] ceph: Amend checking to fix `make W=1` build breakage Date: Mon, 10 Nov 2025 15:44:04 +0100 Message-ID: <20251110144404.369928-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In a few cases the code compares 32-bit value to a SIZE_MAX derived constant which is much higher than that value on 64-bit platforms, Clang, in particular, is not happy about this fs/ceph/snap.c:377:10: error: result of comparison of constant 2305843009213693948 with expression of type 'u32' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] 377 | if (num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64)) | ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix this by casting to size_t. Note, that possible replacement of SIZE_MAX by U32_MAX may lead to the behaviour changes on the corner cases. Signed-off-by: Andy Shevchenko --- fs/ceph/snap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c index c65f2b202b2b..521507ea8260 100644 --- a/fs/ceph/snap.c +++ b/fs/ceph/snap.c @@ -374,7 +374,7 @@ static int build_snap_context(struct ceph_mds_client *mdsc, /* alloc new snap context */ err = -ENOMEM; - if (num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64)) + if ((size_t)num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64)) goto fail; snapc = ceph_create_snap_context(num, GFP_NOFS); if (!snapc) -- 2.50.1