[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a1c19dfca4 01/11: Pacify GCC 12 -Wanalyzer-use-of-uninitialized-v
From: |
Paul Eggert |
Subject: |
master a1c19dfca4 01/11: Pacify GCC 12 -Wanalyzer-use-of-uninitialized-value |
Date: |
Tue, 31 May 2022 04:26:57 -0400 (EDT) |
branch: master
commit a1c19dfca4b1e0b84a958aee33c8212dc69cd2cb
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
Pacify GCC 12 -Wanalyzer-use-of-uninitialized-value
* lib-src/etags.c (readline_internal): Do not copy a pointer to
freed storage, as that has undefined behavior even if the pointer
is not dereferenced.
(relative_filename): Avoid a backward scan by remembering where
the last slash was. This is a bit faster, and pacifies a GCC
false alarm.
---
lib-src/etags.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib-src/etags.c b/lib-src/etags.c
index ea99ed9f39..f76dda7936 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -7248,8 +7248,8 @@ readline_internal (linebuffer *lbp, FILE *stream, char
const *filename)
{
/* We're at the end of linebuffer: expand it. */
xrnew (buffer, lbp->size, 2);
+ p = buffer + lbp->size;
lbp->size *= 2;
- p += buffer - lbp->buffer;
pend = buffer + lbp->size;
lbp->buffer = buffer;
}
@@ -7670,21 +7670,21 @@ relative_filename (char *file, char *dir)
{
char *fp, *dp, *afn, *res;
ptrdiff_t i;
+ char *dir_last_slash UNINIT;
/* Find the common root of file and dir (with a trailing slash). */
afn = absolute_filename (file, cwd);
fp = afn;
dp = dir;
while (*fp++ == *dp++)
- continue;
- fp--, dp--; /* back to the first differing char */
+ if (dp[-1] == '/')
+ dir_last_slash = dp - 1;
#ifdef DOS_NT
- if (fp == afn && afn[0] != '/') /* cannot build a relative name */
- return afn;
+ if (fp - 1 == afn && afn[0] != '/')
+ return afn; /* Cannot build a relative name. */
#endif
- do /* look at the equal chars until '/' */
- fp--, dp--;
- while (*fp != '/');
+ fp -= dp - dir_last_slash;
+ dp = dir_last_slash;
/* Build a sequence of "../" strings for the resulting relative file name. */
i = 0;
- master updated (d94890404e -> a55a0483c9), Paul Eggert, 2022/05/31
- master 1f6973241a 07/11: Pacify GCC 12 in Fx_show_tip, Paul Eggert, 2022/05/31
- master a1c19dfca4 01/11: Pacify GCC 12 -Wanalyzer-use-of-uninitialized-value,
Paul Eggert <=
- master c4da5db04b 08/11: Pacify GCC 12 in Fmove_overlay, Paul Eggert, 2022/05/31
- master 82c05c034e 03/11: Avoid undefined behavior in detect_coding routines, Paul Eggert, 2022/05/31
- master 877be9098e 02/11: Pacify GCC 12 -fanalyzer in x_popup_menu_1, Paul Eggert, 2022/05/31
- master 0614e0f3e9 10/11: Pacify GCC 12 in dump_queue_enqueue, Paul Eggert, 2022/05/31
- master 13dac6f3e9 05/11: Pacify GCC 12 false positive in ccl.c, Paul Eggert, 2022/05/31
- master 569d4c7ad6 09/11: Be more robust if doc file is corrupted, Paul Eggert, 2022/05/31
- master a55a0483c9 11/11: Pacify GCC 12 in x_get_current_wm_state, Paul Eggert, 2022/05/31
- master 30966a6e67 04/11: Simplify CHAR_TABLE_REF_ASCII, Paul Eggert, 2022/05/31
- master 920f1e68b8 06/11: Pacify GCC 12 in xrdb.c, Paul Eggert, 2022/05/31