From f8b7343a29ffae3906d616dc4f6fa4185341e159 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 24 Apr 2022 11:02:09 +0100 Subject: console: Mark an unused parameter as such This signal handler is only called for SIGWINCH, so it doesn't need to look at its parameter. Signed-off-by: Simon McVittie --- glnx-console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glnx-console.c b/glnx-console.c index 3ce2452..f6ce0d4 100644 --- a/glnx-console.c +++ b/glnx-console.c @@ -143,7 +143,7 @@ glnx_console_lines (void) } static void -on_sigwinch (int signum) +on_sigwinch (G_GNUC_UNUSED int signum) { cached_columns = 0; cached_lines = 0; -- cgit v1.2.1 From 2d007fa1c0dcbd93206139ed10e238f3696c5206 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 24 Apr 2022 11:02:48 +0100 Subject: fdio, xattrs: Mark unused cancellables as such These functions take a GCancellable for consistency with other file APIs, but are not actually cancellable at the moment. Signed-off-by: Simon McVittie --- glnx-fdio.c | 4 ++-- glnx-xattrs.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/glnx-fdio.c b/glnx-fdio.c index b3a6239..c2896f3 100644 --- a/glnx-fdio.c +++ b/glnx-fdio.c @@ -660,7 +660,7 @@ glnx_file_get_contents_utf8_at (int dfd, char * glnx_readlinkat_malloc (int dfd, const char *subpath, - GCancellable *cancellable, + G_GNUC_UNUSED GCancellable *cancellable, GError **error) { dfd = glnx_dirfd_canonicalize (dfd); @@ -1106,7 +1106,7 @@ glnx_file_replace_contents_with_perms_at (int dfd, uid_t uid, gid_t gid, GLnxFileReplaceFlags flags, - GCancellable *cancellable, + G_GNUC_UNUSED GCancellable *cancellable, GError **error) { char *dnbuf = strdupa (subpath); diff --git a/glnx-xattrs.c b/glnx-xattrs.c index 32479cc..d0e6ab3 100644 --- a/glnx-xattrs.c +++ b/glnx-xattrs.c @@ -141,7 +141,7 @@ static gboolean get_xattrs_impl (const char *path, int fd, GVariant **out_xattrs, - GCancellable *cancellable, + G_GNUC_UNUSED GCancellable *cancellable, GError **error) { gboolean ret = FALSE; @@ -269,7 +269,7 @@ glnx_dfd_name_get_all_xattrs (int dfd, static gboolean set_all_xattrs_for_path (const char *path, GVariant *xattrs, - GCancellable *cancellable, + G_GNUC_UNUSED GCancellable *cancellable, GError **error) { const guint n = g_variant_n_children (xattrs); @@ -337,7 +337,7 @@ glnx_dfd_name_set_all_xattrs (int dfd, gboolean glnx_fd_set_all_xattrs (int fd, GVariant *xattrs, - GCancellable *cancellable, + G_GNUC_UNUSED GCancellable *cancellable, GError **error) { const guint n = g_variant_n_children (xattrs); -- cgit v1.2.1 From d78121a6997c833cf3c367b432f668551ee3ae1e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 24 Apr 2022 11:04:00 +0100 Subject: fdio: Make signedness of iterator consistent with limit gcc -Wsign-compare warns about this. The iteration limit is constant and small enough that either int or guint would be fine. Signed-off-by: Simon McVittie --- glnx-fdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glnx-fdio.c b/glnx-fdio.c index c2896f3..c601f08 100644 --- a/glnx-fdio.c +++ b/glnx-fdio.c @@ -229,7 +229,7 @@ open_tmpfile_core (int dfd, const char *subpath, const guint count_max = 100; { g_autofree char *tmp = g_strconcat (subpath, "/tmp.XXXXXX", NULL); - for (int count = 0; count < count_max; count++) + for (guint count = 0; count < count_max; count++) { glnx_gen_temp_name (tmp); -- cgit v1.2.1 From f65b05f2d540e8560fde374c206f872e24436e32 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 24 Apr 2022 11:04:58 +0100 Subject: fdio: Match signedness of length parameter This is documented as taking a length of -1, but the parameter is unsigned, so it's more correctly ((gsize) -1). This silences a warning from gcc -Wsign-compare. Signed-off-by: Simon McVittie --- glnx-fdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glnx-fdio.c b/glnx-fdio.c index c601f08..ee69aa1 100644 --- a/glnx-fdio.c +++ b/glnx-fdio.c @@ -1130,7 +1130,7 @@ glnx_file_replace_contents_with_perms_at (int dfd, &tmpf, error)) return FALSE; - if (len == -1) + if (len == (gsize) -1) len = strlen ((char*)buf); if (!glnx_try_fallocate (tmpf.fd, 0, len, error)) -- cgit v1.2.1 From 4c51a54c36eb1a9d728acb14a700271adc7e0ee4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 24 Apr 2022 11:06:51 +0100 Subject: tests: Make iterator signedness agree with limit g_variant_n_children() returns a size_t (or gsize, which is equivalent) so in principle it could overflow an int, although in practice we are not going to have that many extended attributes. This silences a warning from gcc -Wsign-compare. Signed-off-by: Simon McVittie --- tests/test-libglnx-xattrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-libglnx-xattrs.c b/tests/test-libglnx-xattrs.c index b72b0d0..ad52b76 100644 --- a/tests/test-libglnx-xattrs.c +++ b/tests/test-libglnx-xattrs.c @@ -122,7 +122,7 @@ do_write_run (GLnxDirFdIterator *dfd_iter, GError **error) if (!glnx_fd_get_all_xattrs (fd, ¤t_xattrs, NULL, error)) return FALSE; - for (int i = 0; i < g_variant_n_children (current_xattrs); i++) + for (size_t i = 0; i < g_variant_n_children (current_xattrs); i++) { const char *name, *value; g_variant_get_child (current_xattrs, i, "(^&ay^&ay)", &name, &value); -- cgit v1.2.1 From 7b26e39a1f687b1a209b73fecd76c083037d5c2f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 24 Apr 2022 11:07:38 +0100 Subject: tests: Make signedness of timestamp agree This silences a warning from gcc -Wsign-compare. g_get_monotonic_time() returns a signed int64. Signed-off-by: Simon McVittie --- tests/test-libglnx-xattrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-libglnx-xattrs.c b/tests/test-libglnx-xattrs.c index ad52b76..1de9acd 100644 --- a/tests/test-libglnx-xattrs.c +++ b/tests/test-libglnx-xattrs.c @@ -182,7 +182,7 @@ xattr_thread (gpointer data) g_autoptr(GError) local_error = NULL; GError **error = &local_error; struct XattrWorker *worker = data; - guint64 end_time = g_get_monotonic_time () + XATTR_THREAD_RUN_TIME_USECS; + gint64 end_time = g_get_monotonic_time () + XATTR_THREAD_RUN_TIME_USECS; guint n_read = 0; while (g_get_monotonic_time () < end_time) -- cgit v1.2.1 From 9f033ee2f6fb2b7ef238b4d6609d55a1e1e8e3e2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 24 Apr 2022 11:08:01 +0100 Subject: meson: Build with more warnings by default If we keep this module closer to warnings-clean, then it can be submoduled into Meson projects that enable warnings by default without having to override it to a lower warning-level. Signed-off-by: Simon McVittie --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index 6714dc2..08622f2 100644 --- a/meson.build +++ b/meson.build @@ -7,6 +7,7 @@ project( 'c', default_options : [ 'c_std=gnu99', + 'warning_level=3', ], ) -- cgit v1.2.1