From c47a5fa25bcc1032bbc51ccb005b8f1ea3bf8fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 1 Sep 2026 14:39:43 +0200 Subject: [PATCH] hostname-wordlist: fix comment and downgrade warning The comment was wrong. The average word is about 6 characters, so in 64 iterations, the probability of never landing on a word boundary is ~(1 - 1/7)**64, about 0.01%. --- src/shared/hostname-setup.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/shared/hostname-setup.c b/src/shared/hostname-setup.c index 194ce01080..4abf662002 100644 --- a/src/shared/hostname-setup.c +++ b/src/shared/hostname-setup.c @@ -455,9 +455,10 @@ int hostname_pick_word(sd_id128_t mid, size_t pos, char **ret) { /* Comment/empty/invalid line: resample rather than advancing, to keep the pick uniform. */ } - /* We exhausted the uniform attempts, this should never happen but if it does fallback to picking the - * next word after our last attempt. */ - log_warning("hostname_pick_word did not find a usable word after %u in wordlist %zu", MAX_ITERATIONS, pos); + /* We exhausted the uniform attempts, this occasionally happens, so fall back to picking the next + * word after our last offset. */ + log_debug("Falling back to linear scan for a word in wordlist %zu after trying %u random offsets.", + pos, MAX_ITERATIONS); return pick_word_linear_scan(words, size, offset, ret); }