Skip to content

Commit f631bf0

Browse files
committed
core/unit: don't log 0 values in unit_log_resources
Prompted by systemd#30573
1 parent 38617c5 commit f631bf0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/core/unit.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,6 +2411,10 @@ static int unit_log_resources(Unit *u) {
24112411
return log_oom();
24122412
iovec[n_iovec++] = IOVEC_MAKE_STRING(TAKE_PTR(t));
24132413

2414+
/* If value is 0, we don't log it in the MESSAGE= field. */
2415+
if (v == 0)
2416+
continue;
2417+
24142418
if (strextendf_with_separator(&message, ", ", "%s %s",
24152419
FORMAT_BYTES(v), memory_fields[metric].message_suffix) < 0)
24162420
return log_oom();
@@ -2434,6 +2438,10 @@ static int unit_log_resources(Unit *u) {
24342438
return log_oom();
24352439
iovec[n_iovec++] = IOVEC_MAKE_STRING(TAKE_PTR(t));
24362440

2441+
/* If value is 0, we don't log it in the MESSAGE= field. */
2442+
if (value == 0)
2443+
continue;
2444+
24372445
/* Format the IO accounting data for inclusion in the human language message string, but only
24382446
* for the bytes counters (and not for the operations counters) */
24392447
if (io_fields[k].message_suffix) {
@@ -2461,6 +2469,10 @@ static int unit_log_resources(Unit *u) {
24612469
return log_oom();
24622470
iovec[n_iovec++] = IOVEC_MAKE_STRING(TAKE_PTR(t));
24632471

2472+
/* If value is 0, we don't log it in the MESSAGE= field. */
2473+
if (value == 0)
2474+
continue;
2475+
24642476
/* Format the IP accounting data for inclusion in the human language message string, but only
24652477
* for the bytes counters (and not for the packets counters) */
24662478
if (ip_fields[m].message_suffix) {

0 commit comments

Comments
 (0)