mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
debug: Optimise to avoid walking the header string
strlcat() needs to walk to the end of its first argument. However, but the length of state.header_str is already known, so optimise by manually appending the extra characters if they will fit. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Volker Lendecke <vl@samba.org>
This commit is contained in:
parent
ee17f5306c
commit
c5061ebe21
@ -1740,13 +1740,16 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* No +=, see man man strlcat
|
||||
*/
|
||||
state.hs_len = strlcat(state.header_str, "] ", sizeof(state.header_str));
|
||||
if (state.hs_len >= sizeof(state.header_str)) {
|
||||
if (state.hs_len >= sizeof(state.header_str) - 1) {
|
||||
goto full;
|
||||
}
|
||||
state.header_str[state.hs_len] = ']';
|
||||
state.hs_len++;
|
||||
if (state.hs_len < sizeof(state.header_str) - 1) {
|
||||
state.header_str[state.hs_len] = ' ';
|
||||
state.hs_len++;
|
||||
}
|
||||
state.header_str[state.hs_len] = '\0';
|
||||
|
||||
if (!state.settings.debug_prefix_timestamp) {
|
||||
state.hs_len += snprintf(state.header_str + state.hs_len,
|
||||
|
Loading…
x
Reference in New Issue
Block a user