From 8942e3a723acae088771c5c4521f816b955712cc Mon Sep 17 00:00:00 2001
From: Matteo Croce <teknoraver@meta.com>
Date: Wed, 12 Nov 2025 17:45:18 +0100
Subject: [PATCH] fix build error when compiling with --without-xattrs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When compiling with --without-xattrs there is the following build error.
Fix it by using MAYBE_UNUSED.

extract.c: In function ‘set_xattr’:
extract.c:968:24: error: unused parameter ‘file_name’ [-Werror=unused-parameter]
  968 | set_xattr (char const *file_name, struct tar_stat_info const *st,
      |            ~~~~~~~~~~~~^~~~~~~~~
extract.c:968:63: error: unused parameter ‘st’ [-Werror=unused-parameter]
  968 | set_xattr (char const *file_name, struct tar_stat_info const *st,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
extract.c:969:19: error: unused parameter ‘mode’ [-Werror=unused-parameter]
  969 |            mode_t mode, char typeflag)
      |            ~~~~~~~^~~~
extract.c:969:30: error: unused parameter ‘typeflag’ [-Werror=unused-parameter]
  969 |            mode_t mode, char typeflag)
      |                         ~~~~~^~~~~~~~
xattrs.c: In function ‘xattrs_xattrs_get’:
xattrs.c:524:24: error: unused parameter ‘parentfd’ [-Werror=unused-parameter]
  524 | xattrs_xattrs_get (int parentfd, char const *file_name,
      |                    ~~~~^~~~~~~~
xattrs.c:524:46: error: unused parameter ‘file_name’ [-Werror=unused-parameter]
  524 | xattrs_xattrs_get (int parentfd, char const *file_name,
      |                                  ~~~~~~~~~~~~^~~~~~~~~
xattrs.c:525:42: error: unused parameter ‘st’ [-Werror=unused-parameter]
  525 |                    struct tar_stat_info *st, int fd)
      |                    ~~~~~~~~~~~~~~~~~~~~~~^~
xattrs.c:525:50: error: unused parameter ‘fd’ [-Werror=unused-parameter]
  525 |                    struct tar_stat_info *st, int fd)
      |                                              ~~~~^~
xattrs.c: In function ‘xattrs_xattrs_set’:
xattrs.c:725:48: error: unused parameter ‘st’ [-Werror=unused-parameter]
  725 | xattrs_xattrs_set (struct tar_stat_info const *st,
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
xattrs.c:726:32: error: unused parameter ‘file_name’ [-Werror=unused-parameter]
  726 |                    char const *file_name, char typeflag, bool later_run)
      |                    ~~~~~~~~~~~~^~~~~~~~~
xattrs.c:726:48: error: unused parameter ‘typeflag’ [-Werror=unused-parameter]
  726 |                    char const *file_name, char typeflag, bool later_run)
      |                                           ~~~~~^~~~~~~~
xattrs.c:726:63: error: unused parameter ‘later_run’ [-Werror=unused-parameter]
  726 |                    char const *file_name, char typeflag, bool later_run)
      |                                                          ~~~~~^~~~~~~~~
xattrs.c: At top level:
xattrs.c:80:1: error: ‘xheader_xattr_add’ defined but not used [-Werror=unused-function]
   80 | xheader_xattr_add (struct tar_stat_info *st,
      | ^~~~~~~~~~~~~~~~~
xattrs.c: In function ‘xattrs_xattrs_set’:
xattrs.c:727:48: error: unused parameter ‘st’ [-Werror=unused-parameter]
  727 | xattrs_xattrs_set (struct tar_stat_info const *st,
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
xattrs.c:728:32: error: unused parameter ‘file_name’ [-Werror=unused-parameter]
  728 |                    char const *file_name, char typeflag, bool later_run)
      |                    ~~~~~~~~~~~~^~~~~~~~~
xattrs.c:728:48: error: unused parameter ‘typeflag’ [-Werror=unused-parameter]
  728 |                    char const *file_name, char typeflag, bool later_run)
      |                                           ~~~~~^~~~~~~~
xattrs.c:728:63: error: unused parameter ‘later_run’ [-Werror=unused-parameter]
  728 |                    char const *file_name, char typeflag, bool later_run)
      |                                                          ~~~~~^~~~~~~~~
xattrs.c: At top level:
xattrs.c:80:1: error: ‘xheader_xattr_add’ defined but not used [-Werror=unused-function]
   80 | xheader_xattr_add (struct tar_stat_info *st,
      | ^~~~~~~~~~~~~~~~~
---
 src/extract.c |  5 +++--
 src/xattrs.c  | 14 +++++++++-----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/extract.c b/src/extract.c
index 010966ba..1d1c8226 100644
--- a/src/extract.c
+++ b/src/extract.c
@@ -965,8 +965,9 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
    created (e.g., xattrs not available), and a positive number if FILE_NAME was
    created.  */
 static int
-set_xattr (char const *file_name, struct tar_stat_info const *st,
-           mode_t mode, char typeflag)
+set_xattr (MAYBE_UNUSED char const *file_name,
+	   MAYBE_UNUSED struct tar_stat_info const *st,
+           MAYBE_UNUSED mode_t mode, MAYBE_UNUSED char typeflag)
 {
 #ifdef HAVE_XATTRS
   if (xattrs_option && st->xattr_map.xm_size)
diff --git a/src/xattrs.c b/src/xattrs.c
index 445dde34..00db40a3 100644
--- a/src/xattrs.c
+++ b/src/xattrs.c
@@ -76,7 +76,7 @@ xattr_map_add (struct xattr_map *map,
   map->xm_size++;
 }
 
-static void
+MAYBE_UNUSED static void
 xheader_xattr_add (struct tar_stat_info *st,
 		   const char *key, const char *val, idx_t len)
 {
@@ -521,8 +521,10 @@ static bool xattrs_masked_out (const char *kw, bool archiving);
    if no mask is given this includes all the user.*, security.*, system.*,
    etc. available domains */
 void
-xattrs_xattrs_get (int parentfd, char const *file_name,
-                   struct tar_stat_info *st, int fd)
+xattrs_xattrs_get (MAYBE_UNUSED int parentfd,
+		   MAYBE_UNUSED char const *file_name,
+                   MAYBE_UNUSED struct tar_stat_info *st,
+		   MAYBE_UNUSED int fd)
 {
   if (xattrs_option)
     {
@@ -722,8 +724,10 @@ xattrs_masked_out (const char *kw, bool archiving)
 }
 
 void
-xattrs_xattrs_set (struct tar_stat_info const *st,
-                   char const *file_name, char typeflag, bool later_run)
+xattrs_xattrs_set (MAYBE_UNUSED struct tar_stat_info const *st,
+                   MAYBE_UNUSED char const *file_name,
+		   MAYBE_UNUSED char typeflag,
+		   MAYBE_UNUSED bool later_run)
 {
   if (xattrs_option)
     {
