]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core,shared: add a couple of asserts 27840/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 30 May 2023 10:40:19 +0000 (12:40 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 30 May 2023 14:23:40 +0000 (16:23 +0200)
To appease the LTO overlords:

In file included from ../../../../src/basic/macro.h:446,
                 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:379:52: error: '%s' directive argument is null [-Werror=format-overflow=]
  379 |                                 log_debug_errno(r, "Credential secret %s/%s appeared while we were creating it, rereading.",
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../src/basic/log.h:214:86: note: in definition of macro 'log_full_errno_zerook'
  214 |                         ? 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_debug_errno(error, ...)     log_full_errno(LOG_DEBUG,   error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../../../../src/shared/creds-util.c:379:33: note: in expansion of macro 'log_debug_errno'
  379 |                                 log_debug_errno(r, "Credential secret %s/%s appeared while we were creating it, rereading.",
      |                                 ^~~~~~~~~~~~~~~
../../../../src/shared/creds-util.c:379:74: note: format string is defined here
  379 |                                 log_debug_errno(r, "Credential secret %s/%s appeared while we were creating it, rereading.",
      |                                                                          ^~
cc1: some warnings being treated as errors

../../../../src/core/transaction.c: In function 'transaction_verify_order_one':
../../../../src/core/transaction.c:338:38: error: '%s' directive argument is null [-Werror=format-overflow=]
  338 |                 sprintf(ans + size, "%s%s", unit_log_field, *unit_id);
      |                                      ^~
cc1: some warnings being treated as errors

src/core/transaction.c
src/shared/creds-util.c

index c3d6ffccc1692548a57b838e301329736441f124..65a00bd9284e4762b0c42aa845a8d68d52fe63b9 100644 (file)
@@ -325,6 +325,8 @@ static char* merge_unit_ids(const char* unit_log_field, char * const* pairs) {
         _cleanup_free_ char *ans = NULL;
         size_t size = 0;
 
+        assert(unit_log_field);
+
         STRV_FOREACH_PAIR(unit_id, job_type, pairs) {
                 size_t next;
 
index 59f580775dcd4e2818205667b8fc9c812623f56b..efc36e2d6d629e385b87f7c67a81ad640083a027 100644 (file)
@@ -342,6 +342,9 @@ int get_credential_host_secret(CredentialSecretFlags flags, void **ret, size_t *
                 filename = "credential.secret";
         }
 
+        assert(dirname);
+        assert(filename);
+
         mkdir_parents(dirname, 0755);
         dfd = open_mkdir_at(AT_FDCWD, dirname, O_CLOEXEC, 0755);
         if (dfd < 0)