From: Frantisek Sumsal Date: Tue, 30 May 2023 10:40:19 +0000 (+0200) Subject: core,shared: add a couple of asserts X-Git-Tag: v254-rc1~336^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=241ecd1cc262e186ba1eef79d3cf48d5ddf08c76;p=thirdparty%2Fsystemd.git core,shared: add a couple of asserts 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 --- diff --git a/src/core/transaction.c b/src/core/transaction.c index c3d6ffccc16..65a00bd9284 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -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; diff --git a/src/shared/creds-util.c b/src/shared/creds-util.c index 59f580775dc..efc36e2d6d6 100644 --- a/src/shared/creds-util.c +++ b/src/shared/creds-util.c @@ -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)