nw="$nw -Wmissing-format-attribute" # copy.c
nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
- nw="$nw -Wsuggest-attribute=format" # warns about copy.c and factor.c
nw="$nw -Wvector-operation-performance" # warns about randperm.c
nw="$nw -Wstrict-prototypes"
# It's not worth being this picky about test programs.
nw="$nw -Wsuggest-attribute=const"
+ nw="$nw -Wsuggest-attribute=format"
nw="$nw -Wsuggest-attribute=pure"
gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
[$GNULIB_WARN_CFLAGS], [$nw])
}
#if USE_XATTR
+ATTRIBUTE_FORMAT ((printf, 2, 3))
static void
copy_attr_error (struct error_context *ctx _GL_UNUSED,
char const *fmt, ...)
}
}
+ATTRIBUTE_FORMAT ((printf, 2, 3))
static void
copy_attr_allerror (struct error_context *ctx _GL_UNUSED,
- char const *fmt, ...)
+ char const *fmt, ...)
{
int err = errno;
va_list ap;
copy_attr (char const *src_path, int src_fd,
char const *dst_path, int dst_fd, struct cp_options const *x)
{
- int ret;
bool all_errors = (!x->data_copy_required || x->require_preserve_xattr);
bool some_errors = (!all_errors && !x->reduce_diagnostics);
- bool selinux_done = (x->preserve_security_context || x->set_security_context);
- struct error_context ctx =
- {
- .error = all_errors ? copy_attr_allerror : copy_attr_error,
- .quote = copy_attr_quote,
- .quote_free = copy_attr_free
- };
- if (0 <= src_fd && 0 <= dst_fd)
- ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd,
- selinux_done ? check_selinux_attr : NULL,
- (all_errors || some_errors ? &ctx : NULL));
- else
- ret = attr_copy_file (src_path, dst_path,
- selinux_done ? check_selinux_attr : NULL,
- (all_errors || some_errors ? &ctx : NULL));
+ int (*check) (char const *, struct error_context *)
+ = (x->preserve_security_context || x->set_security_context
+ ? check_selinux_attr : NULL);
+
+# if 4 < __GNUC__ + (8 <= __GNUC_MINOR__)
+ /* Pacify gcc -Wsuggest-attribute=format through at least GCC 11.2.1. */
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
+# endif
+ struct error_context *ctx
+ = (all_errors || some_errors
+ ? (&(struct error_context) {
+ .error = all_errors ? copy_attr_allerror : copy_attr_error,
+ .quote = copy_attr_quote,
+ .quote_free = copy_attr_free
+ })
+ : NULL);
+# if 4 < __GNUC__ + (8 <= __GNUC_MINOR__)
+# pragma GCC diagnostic pop
+# endif
- return ret == 0;
+ return ! (0 <= src_fd && 0 <= dst_fd
+ ? attr_copy_fd (src_path, src_fd, dst_path, dst_fd, check, ctx)
+ : attr_copy_file (src_path, dst_path, check, ctx));
}
#else /* USE_XATTR */
static void beyond (void);
+ATTRIBUTE_FORMAT ((printf, 1, 2))
static _Noreturn void
test_syntax_error (char const *format, ...)
{
bool le, re;
pos += 3;
if (l_is_l || r_is_l)
- test_syntax_error (_("-nt does not accept -l"), NULL);
+ test_syntax_error (_("-nt does not accept -l"));
le = get_mtime (argv[op - 1], <);
re = get_mtime (argv[op + 1], &rt);
return le && (!re || timespec_cmp (lt, rt) > 0);
/* ef - hard link? */
pos += 3;
if (l_is_l || r_is_l)
- test_syntax_error (_("-ef does not accept -l"), NULL);
+ test_syntax_error (_("-ef does not accept -l"));
return (stat (argv[op - 1], &stat_buf) == 0
&& stat (argv[op + 1], &stat_spare) == 0
&& stat_buf.st_dev == stat_spare.st_dev
bool le, re;
pos += 3;
if (l_is_l || r_is_l)
- test_syntax_error (_("-ot does not accept -l"), NULL);
+ test_syntax_error (_("-ot does not accept -l"));
le = get_mtime (argv[op - 1], <);
re = get_mtime (argv[op + 1], &rt);
return re && (!le || timespec_cmp (lt, rt) < 0);