From: Paul Eggert Date: Sat, 20 Jul 2024 16:03:24 +0000 (-0700) Subject: Change list-length intptr_t to ptrdiff_t X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2e25f5b062dd6d2657ea8773ff04ad21c10b555a;p=emacs.git Change list-length intptr_t to ptrdiff_t * src/fns.c (list_length, Fsafe_length, Fproper_list_p): Use ptrdiff_t not intptr_t for accumulator, since result is ptrdiff_t. This fixes a minor glitch in 2019-01-11T05:35:31!eggert@cs.ucla.edu where I removed unnecessary overflow checks but forgot to change types. This change should alter generated code only on oddball platforms where ptrdiff_t is narrower than intptr_t, e.g., CheriBSD. (cherry picked from commit 76497a01425e19a6c3a02c1e3031061fa0e7885b) --- diff --git a/src/fns.c b/src/fns.c index dbda523d285..1b672c53e61 100644 --- a/src/fns.c +++ b/src/fns.c @@ -117,7 +117,7 @@ See Info node `(elisp)Random Numbers' for more details. */) ptrdiff_t list_length (Lisp_Object list) { - intptr_t i = 0; + ptrdiff_t i = 0; FOR_EACH_TAIL (list) i++; CHECK_LIST_END (list, list); @@ -167,7 +167,7 @@ it returns 0. If LIST is circular, it returns an integer that is at least the number of distinct elements. */) (Lisp_Object list) { - intptr_t len = 0; + ptrdiff_t len = 0; FOR_EACH_TAIL_SAFE (list) len++; return make_fixnum (len); @@ -248,7 +248,7 @@ A proper list is neither circular nor dotted (i.e., its last cdr is nil). */ attributes: const) (Lisp_Object object) { - intptr_t len = 0; + ptrdiff_t len = 0; Lisp_Object last_tail = object; Lisp_Object tail = object; FOR_EACH_TAIL_SAFE (tail)