>From 0eec786d489ebaed246d6dbdc48c131742c90e42 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 5 Dec 2020 11:45:15 +0100 Subject: [PATCH 2/6] c-stack: Use idx_t for nonnegative ptrdiff_t variables. * lib/c-stack.c: Include idx.h. (die): Mark buflen as nonnegative. * modules/c-stack (Depends-on): Add idx. --- ChangeLog | 7 +++++++ lib/c-stack.c | 10 ++++++---- modules/c-stack | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3281f74..6d32664 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2020-12-05 Bruno Haible + c-stack: Use idx_t for nonnegative ptrdiff_t variables. + * lib/c-stack.c: Include idx.h. + (die): Mark buflen as nonnegative. + * modules/c-stack (Depends-on): Add idx. + +2020-12-05 Bruno Haible + backupfile: Use idx_t for nonnegative ptrdiff_t variables. * lib/backupfile.c: Include idx.h. (numbered_backup): Mark base_offset as nonnegative. diff --git a/lib/c-stack.c b/lib/c-stack.c index 3aea16a..c5bb74a 100644 --- a/lib/c-stack.c +++ b/lib/c-stack.c @@ -37,9 +37,6 @@ #include "c-stack.h" -#include "gettext.h" -#define _(msgid) gettext (msgid) - #include #include @@ -64,6 +61,11 @@ typedef struct sigaltstack stack_t; # include #endif +#include "idx.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + /* Use libsigsegv only if needed; kernels like Solaris can detect stack overflow without the overhead of an external library. */ #define USE_LIBSIGSEGV (!HAVE_XSI_STACK_OVERFLOW_HEURISTIC && HAVE_LIBSIGSEGV) @@ -134,7 +136,7 @@ die (int signo) size_t messagelen = strlen (message); static char const separator[] = {':', ' '}; char buf[sizeof alternate_signal_stack / 16 + sizeof separator]; - ptrdiff_t buflen; + idx_t buflen; if (prognamelen + messagelen < sizeof buf - sizeof separator) { char *p = mempcpy (buf, progname, prognamelen); diff --git a/modules/c-stack b/modules/c-stack index 77cf6aa..4c80f31 100644 --- a/modules/c-stack +++ b/modules/c-stack @@ -14,6 +14,7 @@ exitfail getprogname gettext-h havelib +idx ignore-value intprops inttypes -- 2.7.4