From 8f6b9b66be6672bed1045c27e606dd9fcedcf022 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 1 Jan 2021 15:54:43 -0800 Subject: [PATCH] canonicalize: remove NARROW_ADDRESSES optimization * lib/canonicalize-lgpl.c, lib/canonicalize.c (NARROW_ADDRESSES): Remove, and remove all uses, as the optimization is arguably not worth the extra complexity. Suggested by Adhemerval Zanella in: https://sourceware.org/pipermail/libc-alpha/2020-December/121203.html --- ChangeLog | 8 ++++++++ lib/canonicalize-lgpl.c | 6 +----- lib/canonicalize.c | 6 +----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d498a5e9..fc45e1176 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2021-01-01 Paul Eggert + + canonicalize: remove NARROW_ADDRESSES optimization + * lib/canonicalize-lgpl.c, lib/canonicalize.c (NARROW_ADDRESSES): + Remove, and remove all uses, as the optimization is arguably not + worth the extra complexity. Suggested by Adhemerval Zanella in: + https://sourceware.org/pipermail/libc-alpha/2020-December/121203.html + 2021-01-01 Bruno Haible stddef: Try harder to get max_align_t defined on OpenBSD. diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index 560e24288..698f9ede2 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -85,10 +85,6 @@ # define IF_LINT(Code) /* empty */ #endif -/* True if adding two valid object sizes might overflow idx_t. - As a practical matter, this cannot happen on 64-bit machines. */ -enum { NARROW_ADDRESSES = IDX_MAX >> 31 >> 31 == 0 }; - #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT # define DOUBLE_SLASH_IS_DISTINCT_ROOT false #endif @@ -343,7 +339,7 @@ realpath_stk (const char *name, char *resolved, if (end_in_extra_buffer) end_idx = end - extra_buf; size_t len = strlen (end); - if (NARROW_ADDRESSES && INT_ADD_OVERFLOW (len, n)) + if (INT_ADD_OVERFLOW (len, n)) { __set_errno (ENOMEM); goto error_nomem; diff --git a/lib/canonicalize.c b/lib/canonicalize.c index cc32260a8..3a1c8098b 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -42,10 +42,6 @@ # define IF_LINT(Code) /* empty */ #endif -/* True if adding two valid object sizes might overflow idx_t. - As a practical matter, this cannot happen on 64-bit machines. */ -enum { NARROW_ADDRESSES = IDX_MAX >> 31 >> 31 == 0 }; - #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT # define DOUBLE_SLASH_IS_DISTINCT_ROOT false #endif @@ -393,7 +389,7 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode, if (end_in_extra_buffer) end_idx = end - extra_buf; size_t len = strlen (end); - if (NARROW_ADDRESSES && INT_ADD_OVERFLOW (len, n)) + if (INT_ADD_OVERFLOW (len, n)) xalloc_die (); while (extra_buffer.length <= len + n) { -- 2.27.0