https://github.com/rohanjr created https://github.com/llvm/llvm-project/pull/180629
None >From 433b994b57ea446b7a4d7291c508b8b6872244db Mon Sep 17 00:00:00 2001 From: Rohan Jacob-Rao <[email protected]> Date: Mon, 9 Feb 2026 21:31:44 +0000 Subject: [PATCH] [NFC][Clang][SafeBuffers] Correct naming (sz -> size). --- clang/docs/SafeBuffers.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/docs/SafeBuffers.rst b/clang/docs/SafeBuffers.rst index 205e621e9d0eb..a11fc317736cf 100644 --- a/clang/docs/SafeBuffers.rst +++ b/clang/docs/SafeBuffers.rst @@ -135,7 +135,7 @@ the only formal "hint" in the program that the pointer does indeed point to a buffer of multiple objects:: int get_last_element(int *pointer, size_t size) { - return ptr[sz - 1]; // warning: unsafe buffer access + return ptr[size - 1]; // warning: unsafe buffer access } int *get_last_element_ptr(int *pointer, size_t size) { @@ -177,9 +177,9 @@ section can be made **slightly** safer this way:: } Here ``std::span`` eliminates the potential concern that the operation -``size - 1`` may overflow when ``sz`` is equal to ``0``, leading to a buffer +``size - 1`` may overflow when ``size`` is equal to ``0``, leading to a buffer "underrun". However, such program does not provide a guarantee that -the variable ``sz`` correctly represents the **actual** size fo the buffer +the variable ``size`` correctly represents the **actual** size fo the buffer pointed to by ``ptr``. The ``std::span`` constructed this way may be ill-formed. It may fail to protect you from overrunning the original buffer. @@ -320,7 +320,7 @@ here is how you can suppress it:: int get_last_element(int *pointer, size_t size) { #pragma clang unsafe_buffer_usage begin - return ptr[sz - 1]; // warning suppressed + return ptr[size - 1]; // warning suppressed #pragma clang unsafe_buffer_usage end } @@ -484,7 +484,7 @@ and undesirable than the previous solution:: // This access is still completely unchecked. What's the point of having // perfect bounds information if you aren't performing runtime checks? #pragma clang unsafe_buffer_usage begin - return ptr[sz - 1]; + return ptr[size - 1]; #pragma clang unsafe_buffer_usage end } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
