sd-journal: make sure sd_journal_add_match() also accepts SIZE_MAX as size
In many of our internal functions that take a pointer + a size we have introduced the rule that SIZE_MAX as size means: take strlen(). sd_journal_add_match() has something similar, but the special value is 0, not SIZE_MAX. This is a bit ugly, since a zero size data block is theoretically fine. The only reason sd_journal_add_match() gets away with using this special value is because valid matches must consist of at least 2 chars, hence cannot be zero. But let's make this more robust and less surprising when compared to the rest of our code, and *also* accept SIZE_MAX to mean strlen(). No actual code changes, just some clean-up.
This commit is contained in:
committed by
Yu Watanabe
parent
7072777163
commit
e1771c8ee6
+2
-2
@@ -75,12 +75,12 @@ static int acquire_first_emergency_log_message(char **ret) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add boot ID filter: %m");
|
||||
|
||||
r = sd_journal_add_match(j, "_UID=0", 0);
|
||||
r = sd_journal_add_match(j, "_UID=0", SIZE_MAX);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add User ID filter: %m");
|
||||
|
||||
assert_cc(0 == LOG_EMERG);
|
||||
r = sd_journal_add_match(j, "PRIORITY=0", 0);
|
||||
r = sd_journal_add_match(j, "PRIORITY=0", SIZE_MAX);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add Emergency filter: %m");
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ static int add_dmesg(sd_journal *j) {
|
||||
if (!arg_dmesg)
|
||||
return 0;
|
||||
|
||||
r = sd_journal_add_match(j, "_TRANSPORT=kernel", 0);
|
||||
r = sd_journal_add_match(j, "_TRANSPORT=kernel", SIZE_MAX);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -440,7 +440,7 @@ static int add_matches(sd_journal *j, char **args) {
|
||||
have_term = true;
|
||||
|
||||
} else {
|
||||
r = sd_journal_add_match(j, *i, 0);
|
||||
r = sd_journal_add_match(j, *i, SIZE_MAX);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add match '%s': %m", *i);
|
||||
have_term = true;
|
||||
|
||||
Reference in New Issue
Block a user