+2026-05-10 Paul Eggert <eggert@cs.ucla.edu>
+
+ canonicalize: pacify -Wmaybe-uninitialized without ignoring
+ * lib/canonicalize.c: Do not ignore -Wmaybe-uninitialized.
+ (IF_LINT): Remove; no longer used.
+ (canonicalize_filename_mode_stk): Use a single local rather than two.
+ Ordinarily portmanteau variables are iffy, but this one is a win.
+
2026-05-10 Bruno Haible <bruno@clisp.org>
string-buffer-reversed: Fix comments.
#include "hashcode-file.h"
#include "xalloc.h"
-/* Suppress bogus GCC -Wmaybe-uninitialized warnings. */
-#if defined GCC_LINT || defined lint
-# define IF_LINT(Code) Code
-#else
-# define IF_LINT(Code) /* empty */
-#endif
-
#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
# define DOUBLE_SLASH_IS_DISTINCT_ROOT false
#endif
# define SLASHES "/"
#endif
-/* Avoid false GCC warning "'end_idx' may be used uninitialized". */
-#if _GL_GNUC_PREREQ (4, 7)
-# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#endif
-
/* Return true if FILE's existence can be shown, false (setting errno)
otherwise. Follow symbolic links. */
static bool
bool logical = (can_mode & CAN_NOLINKS) != 0;
int num_links = 0;
- bool end_in_extra_buffer = false;
+
+ /* If nonnegative, the nonnegative offset (or former offset) in
+ BUFS->extra of the component end. It never goes negative after
+ becoming nonnegative. */
+ ptrdiff_t end_extra_offset = -1;
for (; *start;)
{
buf[n] = '\0';
char *extra_buf = bufs->extra.data;
- idx_t end_idx IF_LINT (= 0);
- if (end_in_extra_buffer)
- end_idx = end - extra_buf;
+ if (0 <= end_extra_offset)
+ end_extra_offset = end - extra_buf;
size_t len = strlen (end);
if (INT_ADD_OVERFLOW (len, n))
xalloc_die ();
xalloc_die ();
extra_buf = bufs->extra.data;
}
- if (end_in_extra_buffer)
- end = extra_buf + end_idx;
+ if (0 <= end_extra_offset)
+ end = extra_buf + end_extra_offset;
/* Careful here, end may be a pointer into extra_buf... */
memmove (&extra_buf[n], end, len + 1);
name = end = memcpy (extra_buf, buf, n);
- end_in_extra_buffer = true;
+ end_extra_offset = 0;
if (IS_ABSOLUTE_FILE_NAME (buf))
{