diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2025-03-08 23:42:40 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2025-03-08 23:42:40 +0100 |
commit | a6ca036fb236a01c137e933d237f4075aaefaac5 (patch) | |
tree | 2f3ae2412e163a45263e658aa48bfd1abe1241f2 | |
parent | e936891c0691269280f245f2679da9cdab39b578 (diff) |
Calc string length once
-rw-r--r-- | FICS/comproc.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/FICS/comproc.c b/FICS/comproc.c index f1a95d4..da5d7a7 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -866,8 +866,10 @@ who_terse(int p, int num, int *plist, int type) } if (p == p1) { - psprintf_highlight(p, ptmp + strlen(ptmp), - sizeof ptmp - strlen(ptmp), "%s", parray[p1].name); + const size_t len = strlen(ptmp); + + psprintf_highlight(p, ptmp + len, + sizeof ptmp - len, "%s", parray[p1].name); } else { strlcat(ptmp, parray[p1].name, sizeof ptmp); } @@ -929,9 +931,12 @@ who_verbose(int p, int num, int plist[]) p1WithAttrs[17] = '\0'; if (p == p1) { + size_t len; + strlcpy(tmp, " ", sizeof tmp); - psprintf_highlight(p, tmp + strlen(tmp), - sizeof tmp - strlen(tmp), "%-17s", p1WithAttrs); + len = strlen(tmp); + psprintf_highlight(p, tmp + len, sizeof tmp - len, + "%-17s", p1WithAttrs); } else { ret = snprintf(tmp, sizeof tmp, " %-17s", p1WithAttrs); |