From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v7 2/7] SAFE_MACROS: Add socket(), bind(), listen(), connect() and getsockname()
Date: Wed, 7 Oct 2015 15:28:57 +0200 [thread overview]
Message-ID: <20151007132856.GD2608@rei.suse.cz> (raw)
In-Reply-To: <1444214869-3597-2-git-send-email-zenglg.jy@cn.fujitsu.com>
Hi!
> +char *ltp_sock_addr(const struct sockaddr *sa, socklen_t salen)
> +{
> + char portstr[8];
> + static char str[128];
Also this is not thread safe and the testcases that use these fucntions
run in several threads. Even if the race condition where two threads
write to the str buffer at the same time is unlikely we should rather
change the interface to print the result into user supplied buffer.
So it reads:
char *tst_sock_addr(const struct sockaddr *sa, socklen_t salen,
char *res, size_t res_len);
And the caller would just define array and pass it to the function as:
char buf[128];
...
tst_resm(..., tst_sock_addr(sa, salen, buf, sizeof(buf)), ...);
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2015-10-07 13:28 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-07 10:47 [LTP] [PATCH v7 1/7] lib6: Remove runcc.* and the testcases that use it Zeng Linggang
2015-10-07 10:47 ` [LTP] [PATCH v7 2/7] SAFE_MACROS: Add socket(), bind(), listen(), connect() and getsockname() Zeng Linggang
2015-10-07 13:07 ` Cyril Hrubis
2015-10-08 1:34 ` Zeng Linggang
2015-10-07 13:28 ` Cyril Hrubis [this message]
2015-10-08 11:29 ` [LTP] [PATCH v8 1/7] lib6: Remove runcc.* and the testcases that use it Zeng Linggang
2015-10-08 11:29 ` [LTP] [PATCH v8 2/7] SAFE_MACROS: Add socket(), bind(), listen(), connect() and getsockname() Zeng Linggang
2015-10-13 10:45 ` Alexey Kodanev
2015-10-14 6:27 ` Zeng Linggang
2015-10-14 8:21 ` [LTP] [PATCH v9 1/8] lib6: Remove runcc.* and the testcases that use it Zeng Linggang
2015-10-14 8:21 ` [LTP] [PATCH v9 2/8] SAFE_MACROS: Add socket(), bind(), listen(), connect() and getsockname() Zeng Linggang
2015-10-14 8:21 ` [LTP] [PATCH v9 3/8] lib6/asapi_04.c: Cleanup Zeng Linggang
2015-10-14 8:21 ` [LTP] [PATCH v9 4/8] lib6/asapi_05.c: Cleanup Zeng Linggang
2015-10-14 8:21 ` [LTP] [PATCH v9 5/8] lib6/asapi_06.c: Cleanup Zeng Linggang
2015-10-14 8:21 ` [LTP] [PATCH v9 6/8] lib6/getaddrinfo_01.c: Cleanup Zeng Linggang
2015-10-20 8:07 ` Alexey Kodanev
2015-10-21 2:47 ` Zeng Linggang
2015-10-21 3:15 ` [LTP] [PATCH v10 1/8] lib6: Remove runcc.* and the testcases that use it Zeng Linggang
2015-10-21 3:15 ` [LTP] [PATCH v10 2/8] SAFE_MACROS: Add socket(), bind(), listen(), connect() and getsockname() Zeng Linggang
2015-10-21 3:15 ` [LTP] [PATCH v10 3/8] lib6/asapi_04.c: Cleanup Zeng Linggang
2015-10-21 3:15 ` [LTP] [PATCH v10 4/8] lib6/asapi_05.c: Cleanup Zeng Linggang
2015-10-21 3:15 ` [LTP] [PATCH v10 5/8] lib6/asapi_06.c: Cleanup Zeng Linggang
2015-10-21 3:15 ` [LTP] [PATCH v10 6/8] lib6/getaddrinfo_01.c: Cleanup Zeng Linggang
2015-10-21 3:15 ` [LTP] [PATCH v10 7/8] lib6: Rename Zeng Linggang
2015-10-21 3:15 ` [LTP] [PATCH v10 8/8] ipv6_lib: Add it into default Zeng Linggang
2015-10-22 11:12 ` [LTP] [PATCH v10 1/8] lib6: Remove runcc.* and the testcases that use it Alexey Kodanev
2015-10-14 8:21 ` [LTP] [PATCH v9 7/8] lib6: Rename Zeng Linggang
2015-10-14 8:21 ` [LTP] [PATCH v9 8/8] ipv6_lib: Add it into default Zeng Linggang
2015-10-08 11:29 ` [LTP] [PATCH v8 3/7] lib6/asapi_04.c: Cleanup Zeng Linggang
2015-10-08 11:29 ` [LTP] [PATCH v8 4/7] lib6/asapi_05.c: Cleanup Zeng Linggang
2015-10-08 11:29 ` [LTP] [PATCH v8 5/7] lib6/asapi_06.c: Cleanup Zeng Linggang
2015-10-08 11:29 ` [LTP] [PATCH v8 6/7] lib6/getaddrinfo_01.c: Cleanup Zeng Linggang
2015-10-08 11:29 ` [LTP] [PATCH v8 7/7] ipv6_lib: Add it into default Zeng Linggang
2015-10-07 10:47 ` [LTP] [PATCH v7 3/7] lib6/asapi_04.c: Cleanup Zeng Linggang
2015-10-07 10:47 ` [LTP] [PATCH v7 4/7] lib6/asapi_05.c: Cleanup Zeng Linggang
2015-10-07 10:47 ` [LTP] [PATCH v7 5/7] lib6/asapi_06.c: Cleanup Zeng Linggang
2015-10-07 10:47 ` [LTP] [PATCH v7 6/7] lib6/getaddrinfo_01.c: Cleanup Zeng Linggang
2015-10-07 10:47 ` [LTP] [PATCH v7 7/7] ipv6_lib: Add it into default Zeng Linggang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151007132856.GD2608@rei.suse.cz \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox