From nobody Tue Dec 16 23:59:21 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 42085285418 for ; Wed, 10 Dec 2025 22:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765406798; cv=none; b=Qj+Bgd2WC+L2wGQABz+b8w20jCi2pS0mToqlS1PC8g6Kpx2U+5vTINA7A4u3b+FRldkvKjOxixuvQ1gRT6CF2gTM6EIjbi9lc63bLFDlQ81De+2mJgY2LELF5ztr2fo/lGtt/HHZRu41P0W/G2lN8VZusWo9TbH9T3pdAa8Yuns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765406798; c=relaxed/simple; bh=2xVmGhP0PFx/hs6+oME8OSKXBynf/1IS5/aMFkAz6UI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QnCWHxoCb73Mfev0rqH3jNTMaFy4+jmvBCg0kttzFhMvBTFpJDdH9mWusDMZ/gkkavUrkOIk68KUUkcsRYY9lymG4yUr07Witrn2aOEP1vzAkKwNbdW7HPa0zX3EcklxNJXeE5rdnycydcfJrmeaLDgWfWMKLnbKdrtWTxO4dZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p0j+r5f9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p0j+r5f9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF61DC4CEF7; Wed, 10 Dec 2025 22:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765406797; bh=2xVmGhP0PFx/hs6+oME8OSKXBynf/1IS5/aMFkAz6UI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=p0j+r5f9ceLd8JHdJaXG7/kP8pHtSxWUPFhU+TbgylfEi6XsCOmOT7ltMtjUZtofz Qs1F+acTHhoCLqplDmCTxk9we3iblfj2QoOLV78cMgJf2XnhfPwfuXrjyBm0TgaIuP D5OMULpUvRNtf24eC2PYQhofqtglZFrh2rA5QOqN0vK/E6WtbZ22LfeQD4pTYsuqye s3IZnsmwfqd1GpC8sFO37M4ynILFwQuQST9kbk47DJm6ArDM/BTk3WhCTA99mwg4iR ehvsbtK5Kwr39gN2HxoYTOuanvMnE16zsb0qeY/eVBI6ELoiJucKZE4NdeX2Fxt7ca nPMzwhrijLiww== Date: Wed, 10 Dec 2025 23:46:32 +0100 From: Alejandro Colomar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Alejandro Colomar , Kees Cook , Christopher Bazley , Rasmus Villemoes , Marco Elver , Michal Hocko , Linus Torvalds , Al Viro , Alexander Potapenko , Dmitry Vyukov , Jann Horn , Andrew Morton , "Maciej W. Rozycki" Subject: [PATCH v5 1/4] array_size.h: Add ARRAY_END() Message-ID: <5973cfb674192bc8e533485dbfb54e3062896be1.1765406337.git.alx@kernel.org> X-Mailer: git-send-email 2.51.0 References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ARRAY_END() returns a pointer one past the end of the last element in the array argument. This pointer is useful for iterating over the elements of an array: for (T *p =3D a, p < ARRAY_END(a); p++) ... Cc: Kees Cook Cc: Christopher Bazley Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Cc: "Maciej W. Rozycki" Signed-off-by: Alejandro Colomar Message-ID: <37b1088dbd01a21d2f9d460aa510726119b3bcb0.1752193588.git.alx@ke= rnel.org> --- drivers/block/floppy.c | 2 -- include/linux/array_size.h | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 5336c3c5ca36..69661840397e 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4802,8 +4802,6 @@ static void floppy_release_allocated_regions(int fdc,= const struct io_region *p) } } =20 -#define ARRAY_END(X) (&((X)[ARRAY_SIZE(X)])) - static int floppy_request_regions(int fdc) { const struct io_region *p; diff --git a/include/linux/array_size.h b/include/linux/array_size.h index 06d7d83196ca..0c4fec98822e 100644 --- a/include/linux/array_size.h +++ b/include/linux/array_size.h @@ -10,4 +10,10 @@ */ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(= arr)) =20 +/** + * ARRAY_END - get a pointer to one past the last element in array @arr + * @arr: array + */ +#define ARRAY_END(arr) (&(arr)[ARRAY_SIZE(arr)]) + #endif /* _LINUX_ARRAY_SIZE_H */ --=20 2.51.0