On 17 Apr 2023, at 8:54, Songtao Zhan wrote:
> To: d...@openvswitch.org,
> i.maxim...@ovn.org
>
> The name of the current thread consists of a name with a maximum
> length of 16 bytes and a thread ID. The final name may be longer
> than 16 bytes. If the name is longer than 16 bytes, the thread
> name will fail to be set
Some inline comments below.
Cheers,
Eelco
> Signed-off-by: Songtao Zhan <zhan...@chinatelecom.cn>
> ---
> lib/util.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/lib/util.c b/lib/util.c
> index 96a71550d..60a1e56a2 100644
> --- a/lib/util.c
> +++ b/lib/util.c
> @@ -645,6 +645,13 @@ set_subprogram_name(const char *subprogram_name)
> free(subprogram_name_set(pname));
>
> #if HAVE_GLIBC_PTHREAD_SETNAME_NP
> + /* The maximum thead name including '\0' supported is 16.
> + * add '>' at 0th position to highlight that the name was truncated. */
> + if (strlen(pname) > 15) {
> + memcpy(pname, &pname[strlen(pname) - 15], 15);
I think you need to use memmove() as srd/dst can overlap.
> + pname[15] = '\0';
If you make the memmove + 1, i.e. memmove(pname, &pname[strlen(pname) - 15], 15
+ 1);, you can skip the above line.
> + pname[0] = '>';
> + }
> pthread_setname_np(pthread_self(), pname);
> #elif HAVE_NETBSD_PTHREAD_SETNAME_NP
> pthread_setname_np(pthread_self(), "%s", pname);
> --
> 2.39.1
>
>
>
> zhan...@chinatelecom.cn
> _______________________________________________
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev