]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: do not use PROJECT_FILE in one more generated file
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 1 Aug 2025 04:37:11 +0000 (13:37 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 1 Aug 2025 08:49:23 +0000 (09:49 +0100)
Fixes the following build warning:
```
In file included from ../../../home/runner/work/systemd/systemd/src/basic/assert-util.h:4,
                 from ../../../home/runner/work/systemd/systemd/src/basic/forward.h:17,
                 from ../../../home/runner/work/systemd/systemd/src/basic/filesystems.h:4,
                 from src/basic/filesystem-sets.c:2:
src/basic/filesystem-sets.c: In function ‘fs_in_group’:
../../../home/runner/work/systemd/systemd/src/fundamental/assert-fundamental.h:76:9: warning: array subscript 42 is above array bounds of ‘const char[28]’ [-Warray-bounds=]
   76 |         log_assert_failed_unreachable(PROJECT_FILE, __LINE__, __func__)
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/basic/filesystem-sets.c:559:18: note: in expansion of macro ‘assert_not_reached’
  559 |         default: assert_not_reached();
      |                  ^~~~~~~~~~~~~~~~~~
```

Follow-up for aca4353ab2b928e669e1b649a9f6987df1efb084.
Similar to fc4a9c9ce6eebbc472fc2947ae371f5925011545.

src/basic/filesystem-sets.py

index 7cf73aaefb881b3c82522e4080bcb40148e4a4ae..6520f45b89e3e3239d0e8b615182886763827289 100755 (executable)
@@ -282,6 +282,11 @@ def generate_fs_type_to_string():
 #include <linux/magic.h>
 #include "filesystems.h"
 
+/* PROJECT_FILE, which is used by log_xyz() thus also used by assert_not_reached(), cannot be used in
+ * generated files, as the build directory may be outside of the source directory. */
+#undef PROJECT_FILE
+#define PROJECT_FILE __FILE__
+
 const char* fs_type_to_string(statfs_f_type_t magic) {
         switch (magic) {""")