diff options
author | Łukasz Stelmach <l.stelmach@samsung.com> | 2023-06-29 13:05:23 +0200 |
---|---|---|
committer | Łukasz Stelmach <l.stelmach@samsung.com> | 2023-06-29 13:08:39 +0200 |
commit | 39878c1fbc3ff86015e40521ddd22a3b80f82b60 (patch) | |
tree | afcd726c551dff1032a5a8ae09e3db19b9501f9e | |
parent | 631b24a6ac5e81787c118c2d174f0b99034c091e (diff) | |
download | systemd-39878c1fbc3ff86015e40521ddd22a3b80f82b60.tar.gz systemd-39878c1fbc3ff86015e40521ddd22a3b80f82b60.tar.bz2 systemd-39878c1fbc3ff86015e40521ddd22a3b80f82b60.zip |
Avoid passing NULL as format parameteraccepted/tizen/unified/dev/20230726.115516
GCC reported possible problem with passing NULL returned from
*_to_string() helpers as an argument for '%s' in a format string.
../src/core/job.c: In function 'job_finish_and_invalidate':
../src/core/job.c:976:27: error: '%s' directive argument is null [-Werror=format-overflow=]
976 | log_unit_debug(u, "Job %" PRIu32 " %s/%s finished, result=%s", j->id, u->id, job_type_to_string(t), job_result_to_string(result));
| ^~~~~~~
../src/core/unit.h:878:190: note: in definition of macro 'log_unit_full'
878 | _u ? log_object_internal(level, error, PROJECT_FILE, __LINE__, __func__, _u->manager->unit_log_field, _u->id, _u->manager->invocation_log_field, _u->invocation_id_string, ##__VA_ARGS__) : \
| ^~~~~~~~~~~
../src/core/job.c:976:9: note: in expansion of macro 'log_unit_debug'
976 | log_unit_debug(u, "Job %" PRIu32 " %s/%s finished, result=%s", j->id, u->id, job_type_to_string(t), job_result_to_string(result));
| ^~~~~~~~~~~~~~
Wrapping the helpers in strna() prevents this from happening.
Further fixes may be applied depending on the outcomes of the discussion
on the systemd-devel mailing list.
Change-Id: Id73f2bc887f46bb07fc960d264953cd5dfce82de
Link: https://lists.freedesktop.org/archives/systemd-devel/2023-June/049215.html
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
-rw-r--r-- | src/core/job.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/core/job.c b/src/core/job.c index 5048a5093e..ffd7cd8b2f 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -973,7 +973,9 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool alr j->result = result; - log_unit_debug(u, "Job %" PRIu32 " %s/%s finished, result=%s", j->id, u->id, job_type_to_string(t), job_result_to_string(result)); + log_unit_debug(u, "Job %" PRIu32 " %s/%s finished, result=%s", + j->id, u->id, strna(job_type_to_string(t)), + strna(job_result_to_string(result))); /* If this job did nothing to respective unit we don't log the status message */ if (!already) |