0001-install-fix-compiler-warning-about-empty-directive-argument.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. From 8040fa55a1cbc34dede3205a902095ecd26c21e3 Mon Sep 17 00:00:00 2001
  2. From: Luca Boccassi <bluca@debian.org>
  3. Date: Sat, 24 Feb 2024 12:05:44 +0000
  4. Subject: [PATCH] install: fix compiler warning about empty directive argument
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. On ppc64el with gcc 13.2 on Ubuntu 24.04:
  9. 3s In file included from ../src/basic/macro.h:386,
  10. 483s from ../src/basic/alloc-util.h:10,
  11. 483s from ../src/shared/install.c:12:
  12. 483s ../src/shared/install.c: In function ‘install_changes_dump’:
  13. 483s ../src/shared/install.c:432:64: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  14. 483s 432 | err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s does not exist.",
  15. 483s | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16. 483s ../src/shared/install.c:432:75: note: format string is defined here
  17. 483s 432 | err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s does not exist.",
  18. Upstream: https://github.com/systemd/systemd/commit/8040fa55a1cbc34dede3205a902095ecd26c21e3
  19. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  20. ---
  21. src/shared/install.c | 7 +++++--
  22. 1 file changed, 5 insertions(+), 2 deletions(-)
  23. diff --git a/src/shared/install.c b/src/shared/install.c
  24. index fabf5db7ed2e1..c3a94d1912165 100644
  25. --- a/src/shared/install.c
  26. +++ b/src/shared/install.c
  27. @@ -340,9 +340,12 @@ void install_changes_dump(int r, const char *verb, const InstallChange *changes,
  28. assert(verb || r >= 0);
  29. for (size_t i = 0; i < n_changes; i++) {
  30. - if (changes[i].type < 0)
  31. - assert(verb);
  32. assert(changes[i].path);
  33. + /* This tries to tell the compiler that it's safe to use 'verb' in a string format if there
  34. + * was an error, but the compiler doesn't care and fails anyway, so strna(verb) is used
  35. + * too. */
  36. + assert(verb || changes[i].type >= 0);
  37. + verb = strna(verb);
  38. /* When making changes here, make sure to also change install_error() in dbus-manager.c. */