]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
string-util: use mempcpy where appropriate
authorMike Yuan <me@yhndnzj.com>
Wed, 17 Apr 2024 08:48:00 +0000 (16:48 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 17 Apr 2024 09:04:23 +0000 (17:04 +0800)
src/basic/string-util.c

index 0a108f4b119a1f12c563f152ab2adc7bf2f86df9..d0d33a407a673bfe2fe6ec3027d74569e0fb9547 100644 (file)
@@ -392,8 +392,7 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
         x = ((new_length - need_space) * percent + 50) / 100;
         assert(x <= new_length - need_space);
 
-        memcpy(t, s, x);
-        write_ellipsis(t + x, /* unicode = */ false);
+        write_ellipsis(mempcpy(t, s, x), /* unicode = */ false);
         suffix_len = new_length - x - need_space;
         memcpy(t + x + 3, s + old_length - suffix_len, suffix_len);
         *(t + x + 3 + suffix_len) = '\0';