Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build warnings/errors with gcc-13 and -O3 #26118

Closed
mrc0mmand opened this issue Jan 20, 2023 · 0 comments
Closed

Build warnings/errors with gcc-13 and -O3 #26118

mrc0mmand opened this issue Jan 20, 2023 · 0 comments
Labels
bug 🐛 Programming errors, that need preferential fixing
Milestone

Comments

@mrc0mmand
Copy link
Member

systemd version the issue has been seen with

latest main

Used distribution

Fedora Rawhide

Linux kernel version used

No response

CPU architectures issue was seen on

None

Component

No response

Expected behaviour you didn't see

No response

Unexpected behaviour you saw

While debugging #25091 I noticed that building latest systemd on Rawhide with gcc-13 and -O3 now emits several warnings/errors:

[711/2111] Compiling C object src/shared/libsystemd-shared-252.a.p/creds-util.c.o
In file included from ../src/basic/macro.h:437,
                 from ../src/shared/blockdev-util.h:8,
                 from ../src/shared/creds-util.c:11:
../src/shared/creds-util.c: In function ‘get_credential_host_secret’:
../src/shared/creds-util.c:375:52: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  375 |                                 log_debug_errno(r, "Credential secret %s/%s appeared while we were creating it, rereading.",
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:246:41: note: in expansion of macro ‘log_full_errno’
  246 | #define log_debug_errno(error, ...)     log_full_errno(LOG_DEBUG,   error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/creds-util.c:375:33: note: in expansion of macro ‘log_debug_errno’
  375 |                                 log_debug_errno(r, "Credential secret %s/%s appeared while we were creating it, rereading.",
      |                                 ^~~~~~~~~~~~~~~
../src/shared/creds-util.c:375:74: note: format string is defined here
  375 |                                 log_debug_errno(r, "Credential secret %s/%s appeared while we were creating it, rereading.",
      |                                                                          ^~
[1046/2111] Compiling C object src/core/libsystemd-core-252.so.p/transaction.c.o
../src/core/transaction.c: In function ‘transaction_verify_order_one’:
../src/core/transaction.c:335:38: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  335 |                 sprintf(ans + size, "%s%s", unit_log_field, *unit_id);
      |                                      ^~
[1141/2111] Compiling C object test-login.p/src_libsystemd_sd-login_test-login.c.o
../src/libsystemd/sd-login/test-login.c: In function ‘format_uids’:
../src/libsystemd/sd-login/test-login.c:25:17: warning: null destination pointer [-Wformat-overflow=]
   25 |                 sprintf(*buf + pos, "%s"UID_FMT"%n", k > 0 ? " " : "", uids[k], &inc);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1237/2111] Compiling C object src/shared/libsystemd-shared-252.a.p/install.c.o
In file included from ../src/basic/macro.h:437,
                 from ../src/basic/alloc-util.h:10,
                 from ../src/shared/install.c:12:
../src/shared/install.c: In function ‘install_changes_dump’:
../src/shared/install.c:429:64: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  429 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s does not exist.",
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:429:31: note: in expansion of macro ‘log_error_errno’
  429 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s does not exist.",
      |                               ^~~~~~~~~~~~~~~
../src/shared/install.c:429:75: note: format string is defined here
  429 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s does not exist.",
      |                                                                           ^~
../src/shared/install.c:388:55: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  388 |                                                       "Failed to %s unit, file \"%s\" already exists.",
      |                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:387:39: note: in expansion of macro ‘log_error_errno’
  387 |                                 err = log_error_errno(changes[i].type,
      |                                       ^~~~~~~~~~~~~~~
../src/shared/install.c:388:66: note: format string is defined here
  388 |                                                       "Failed to %s unit, file \"%s\" already exists.",
      |                                                                  ^~
../src/shared/install.c:384:55: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  384 |                                                       "Failed to %s unit, file \"%s\" already exists and is a symlink to \"%s\".",
      |                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:383:39: note: in expansion of macro ‘log_error_errno’
  383 |                                 err = log_error_errno(changes[i].type,
      |                                       ^~~~~~~~~~~~~~~
../src/shared/install.c:384:66: note: format string is defined here
  384 |                                                       "Failed to %s unit, file \"%s\" already exists and is a symlink to \"%s\".",
      |                                                                  ^~
../src/shared/install.c:425:72: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  425 |                                 err = log_error_errno(changes[i].type, "Failed to %s unit, invalid unit reference \"%s\".",
      |                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:425:39: note: in expansion of macro ‘log_error_errno’
  425 |                                 err = log_error_errno(changes[i].type, "Failed to %s unit, invalid unit reference \"%s\".",
      |                                       ^~~~~~~~~~~~~~~
../src/shared/install.c:425:83: note: format string is defined here
  425 |                                 err = log_error_errno(changes[i].type, "Failed to %s unit, invalid unit reference \"%s\".",
      |                                                                                   ^~
../src/shared/install.c:422:72: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  422 |                                 err = log_error_errno(changes[i].type, "Failed to %s unit, cannot alias %s as %s.",
      |                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:422:39: note: in expansion of macro ‘log_error_errno’
  422 |                                 err = log_error_errno(changes[i].type, "Failed to %s unit, cannot alias %s as %s.",
      |                                       ^~~~~~~~~~~~~~~
../src/shared/install.c:422:83: note: format string is defined here
  422 |                                 err = log_error_errno(changes[i].type, "Failed to %s unit, cannot alias %s as %s.",
      |                                                                                   ^~
../src/shared/install.c:400:64: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  400 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, file %s is under the systemd unit hierarchy already.",
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:400:31: note: in expansion of macro ‘log_error_errno’
  400 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, file %s is under the systemd unit hierarchy already.",
      |                               ^~~~~~~~~~~~~~~
../src/shared/install.c:400:75: note: format string is defined here
  400 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, file %s is under the systemd unit hierarchy already.",
      |                                                                           ^~
../src/shared/install.c:417:64: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  417 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, refusing to operate on linked unit file %s.",
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:417:31: note: in expansion of macro ‘log_error_errno’
  417 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, refusing to operate on linked unit file %s.",
      |                               ^~~~~~~~~~~~~~~
../src/shared/install.c:417:75: note: format string is defined here
  417 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, refusing to operate on linked unit file %s.",
      |                                                                           ^~
../src/shared/install.c:408:64: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  408 |                         err = log_error_errno(changes[i].type, "Failed to %s %s, destination unit %s is a non-template unit.",
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:408:31: note: in expansion of macro ‘log_error_errno’
  408 |                         err = log_error_errno(changes[i].type, "Failed to %s %s, destination unit %s is a non-template unit.",
      |                               ^~~~~~~~~~~~~~~
../src/shared/install.c:408:75: note: format string is defined here
  408 |                         err = log_error_errno(changes[i].type, "Failed to %s %s, destination unit %s is a non-template unit.",
      |                                                                           ^~
../src/shared/install.c:433:64: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  433 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, cannot resolve specifiers in \"%s\".",
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:433:31: note: in expansion of macro ‘log_error_errno’
  433 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, cannot resolve specifiers in \"%s\".",
      |                               ^~~~~~~~~~~~~~~
../src/shared/install.c:433:75: note: format string is defined here
  433 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, cannot resolve specifiers in \"%s\".",
      |                                                                           ^~
../src/shared/install.c:404:64: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  404 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, invalid specifier in \"%s\".",
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:404:31: note: in expansion of macro ‘log_error_errno’
  404 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, invalid specifier in \"%s\".",
      |                               ^~~~~~~~~~~~~~~
../src/shared/install.c:404:75: note: format string is defined here
  404 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, invalid specifier in \"%s\".",
      |                                                                           ^~
../src/shared/install.c:396:64: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  396 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s is transient or generated.",
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:396:31: note: in expansion of macro ‘log_error_errno’
  396 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s is transient or generated.",
      |                               ^~~~~~~~~~~~~~~
../src/shared/install.c:396:75: note: format string is defined here
  396 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s is transient or generated.",
      |                                                                           ^~
../src/shared/install.c:413:47: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  413 |                                               "Failed to %s unit, \"%s\" is not a valid unit name.",
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:412:31: note: in expansion of macro ‘log_error_errno’
  412 |                         err = log_error_errno(changes[i].type,
      |                               ^~~~~~~~~~~~~~~
../src/shared/install.c:413:58: note: format string is defined here
  413 |                                               "Failed to %s unit, \"%s\" is not a valid unit name.",
      |                                                          ^~
../src/shared/install.c:392:64: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  392 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s is masked.",
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:210:86: note: in definition of macro ‘log_full_errno_zerook’
  210 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:250:41: note: in expansion of macro ‘log_full_errno’
  250 | #define log_error_errno(error, ...)     log_full_errno(LOG_ERR,     error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../src/shared/install.c:392:31: note: in expansion of macro ‘log_error_errno’
  392 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s is masked.",
      |                               ^~~~~~~~~~~~~~~
../src/shared/install.c:392:75: note: format string is defined here
  392 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s is masked.",
      |                                                                           ^~
[2111/2111] Generating export-dbus-interfaces with a custom command

Steps to reproduce the problem

No response

Additional program output to the terminal or log subsystem illustrating the issue

No response

@mrc0mmand mrc0mmand added the bug 🐛 Programming errors, that need preferential fixing label Jan 20, 2023
@bluca bluca added this to the v253 milestone Jan 20, 2023
@bluca bluca closed this as completed in 8f5d716 Jan 23, 2023
eworm-de pushed a commit to eworm-de/systemd that referenced this issue Feb 4, 2023
With the previous form, gcc is confused and thinks that .type might be unset.

Fixes systemd#26118.

(cherry picked from commit 8f5d716)
d-hatayama pushed a commit to d-hatayama/systemd that referenced this issue Feb 15, 2023
With the previous form, gcc is confused and thinks that .type might be unset.

Fixes systemd#26118.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Programming errors, that need preferential fixing
Development

No branches or pull requests

2 participants