summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2016-07-30 08:35:23 -0700
committerAndreas Gruenbacher <agruen@gnu.org>2016-07-31 10:17:52 +0200
commitb6c4780f73708cd752d212b0b1fb4acd2bd90595 (patch)
treec52244a968b615160ac5b35e534a2e2cac94577d
parent9ca38fa1e6a5c8aa4d3463b37ab12e613dac7cf0 (diff)
downloadpatch-b6c4780f73708cd752d212b0b1fb4acd2bd90595.tar.gz
maint: avoid new warning-errors from gcc-6.1
When configured with --enable-gcc-warnings and gcc-6.1, ... * src/safe.c (count_path_components): Use _GL_ATTRIBUTE_PURE, to avoid an error from -Werror=suggest-attribute=pure. * src/util.h (filename_is_safe): Likewise. * src/patch.c (main): Placate -Werror=format= by casting pch_mode's mode_t return type to the "unsigned int" required to match the %o format string. * src/patch.c (delete_files): Correct indentation, to avoid this error from -Werror=misleading-indentation: patch.c: In function 'delete_files': patch.c:1816:4: error: this 'if' clause does not guard... if (verbosity == VERBOSE) ^~ patch.c:1820:6: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' move_file (0, 0, 0, file_to_delete->name, mode, ^~~~~~~~~
-rw-r--r--src/patch.c10
-rw-r--r--src/safe.c1
-rw-r--r--src/util.h2
3 files changed, 7 insertions, 6 deletions
diff --git a/src/patch.c b/src/patch.c
index bf7e5c2..6c76276 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -241,8 +241,8 @@ main (int argc, char **argv)
{
say ("File %s: can't change file type from 0%o to 0%o.\n",
quotearg (inname),
- pch_mode (reverse) & S_IFMT,
- pch_mode (! reverse) & S_IFMT);
+ (unsigned int) (pch_mode (reverse) & S_IFMT),
+ (unsigned int) (pch_mode (! reverse) & S_IFMT));
skip_rest_of_patch = true;
somefailed = true;
}
@@ -1817,9 +1817,9 @@ delete_files (void)
say ("Removing %s %s\n",
S_ISLNK (mode) ? "symbolic link" : "file",
quotearg (file_to_delete->name));
- move_file (0, 0, 0, file_to_delete->name, mode,
- file_to_delete->backup);
- removedirs (file_to_delete->name);
+ move_file (0, 0, 0, file_to_delete->name, mode,
+ file_to_delete->backup);
+ removedirs (file_to_delete->name);
}
}
gl_list_iterator_free (&iter);
diff --git a/src/safe.c b/src/safe.c
index d2ff0d2..5a7202f 100644
--- a/src/safe.c
+++ b/src/safe.c
@@ -243,6 +243,7 @@ out:
return entry;
}
+_GL_ATTRIBUTE_PURE
static unsigned int count_path_components (const char *path)
{
unsigned int components;
diff --git a/src/util.h b/src/util.h
index ab46540..f4936ec 100644
--- a/src/util.h
+++ b/src/util.h
@@ -68,7 +68,7 @@ enum file_id_type lookup_file_id (struct stat const *);
void set_queued_output (struct stat const *, bool);
bool has_queued_output (struct stat const *);
int stat_file (char const *, struct stat *);
-bool filename_is_safe (char const *);
+bool filename_is_safe (char const *) _GL_ATTRIBUTE_PURE;
bool cwd_is_root (char const *);
enum file_attributes {