aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert2022-05-31 01:19:31 -0700
committerPaul Eggert2022-05-31 01:26:47 -0700
commita1c19dfca4b1e0b84a958aee33c8212dc69cd2cb (patch)
treec89d553de7ec5710a8bde01b5fd2682b331f0cab /lib-src
parentd94890404e91d5ba50afaa4bc27b9c655dbed5f1 (diff)
downloademacs-a1c19dfca4b1e0b84a958aee33c8212dc69cd2cb.tar.gz
emacs-a1c19dfca4b1e0b84a958aee33c8212dc69cd2cb.zip
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.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index ea99ed9f396..f76dda7936b 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -7248,8 +7248,8 @@ readline_internal (linebuffer *lbp, FILE *stream, char const *filename)
7248 { 7248 {
7249 /* We're at the end of linebuffer: expand it. */ 7249 /* We're at the end of linebuffer: expand it. */
7250 xrnew (buffer, lbp->size, 2); 7250 xrnew (buffer, lbp->size, 2);
7251 p = buffer + lbp->size;
7251 lbp->size *= 2; 7252 lbp->size *= 2;
7252 p += buffer - lbp->buffer;
7253 pend = buffer + lbp->size; 7253 pend = buffer + lbp->size;
7254 lbp->buffer = buffer; 7254 lbp->buffer = buffer;
7255 } 7255 }
@@ -7670,21 +7670,21 @@ relative_filename (char *file, char *dir)
7670{ 7670{
7671 char *fp, *dp, *afn, *res; 7671 char *fp, *dp, *afn, *res;
7672 ptrdiff_t i; 7672 ptrdiff_t i;
7673 char *dir_last_slash UNINIT;
7673 7674
7674 /* Find the common root of file and dir (with a trailing slash). */ 7675 /* Find the common root of file and dir (with a trailing slash). */
7675 afn = absolute_filename (file, cwd); 7676 afn = absolute_filename (file, cwd);
7676 fp = afn; 7677 fp = afn;
7677 dp = dir; 7678 dp = dir;
7678 while (*fp++ == *dp++) 7679 while (*fp++ == *dp++)
7679 continue; 7680 if (dp[-1] == '/')
7680 fp--, dp--; /* back to the first differing char */ 7681 dir_last_slash = dp - 1;
7681#ifdef DOS_NT 7682#ifdef DOS_NT
7682 if (fp == afn && afn[0] != '/') /* cannot build a relative name */ 7683 if (fp - 1 == afn && afn[0] != '/')
7683 return afn; 7684 return afn; /* Cannot build a relative name. */
7684#endif 7685#endif
7685 do /* look at the equal chars until '/' */ 7686 fp -= dp - dir_last_slash;
7686 fp--, dp--; 7687 dp = dir_last_slash;
7687 while (*fp != '/');
7688 7688
7689 /* Build a sequence of "../" strings for the resulting relative file name. */ 7689 /* Build a sequence of "../" strings for the resulting relative file name. */
7690 i = 0; 7690 i = 0;