From: Richard Palethorpe <rpalethorpe@suse.de>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v4 1/2] Add SAFE_SETHOSTNAME macro
Date: Thu, 09 Feb 2023 10:10:21 +0000 [thread overview]
Message-ID: <877cwrrvwk.fsf@suse.de> (raw)
In-Reply-To: <20230125100043.32349-2-andrea.cervesato@suse.com>
Hello,
Reviewed-by: Richard Palethorpe <rpalethorpe@suse.com>
Andrea Cervesato via ltp <ltp@lists.linux.it> writes:
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> include/safe_net_fn.h | 3 +++
> include/tst_safe_net.h | 3 +++
> lib/safe_net.c | 17 +++++++++++++++++
> 3 files changed, 23 insertions(+)
>
> diff --git a/include/safe_net_fn.h b/include/safe_net_fn.h
> index ff81b1337..6c63cb2cf 100644
> --- a/include/safe_net_fn.h
> +++ b/include/safe_net_fn.h
> @@ -73,6 +73,9 @@ int safe_getsockname(const char *file, const int lineno,
> int safe_gethostname(const char *file, const int lineno,
> char *name, size_t size);
>
> +int safe_sethostname(const char *file, const int lineno,
> + const char *name, size_t size);
> +
> int tst_getsockport(const char *file, const int lineno, int sockfd);
>
> unsigned short tst_get_unused_port(const char *file, const int lineno,
> diff --git a/include/tst_safe_net.h b/include/tst_safe_net.h
> index e85b79a3e..98f0256fd 100644
> --- a/include/tst_safe_net.h
> +++ b/include/tst_safe_net.h
> @@ -68,6 +68,9 @@
> #define SAFE_GETHOSTNAME(name, size) \
> safe_gethostname(__FILE__, __LINE__, name, size)
>
> +#define SAFE_SETHOSTNAME(name, size) \
> + safe_sethostname(__FILE__, __LINE__, name, size)
> +
> #define TST_GETSOCKPORT(sockfd) \
> tst_getsockport(__FILE__, __LINE__, sockfd)
>
> diff --git a/lib/safe_net.c b/lib/safe_net.c
> index 1717f0745..5dec0de11 100644
> --- a/lib/safe_net.c
> +++ b/lib/safe_net.c
> @@ -469,6 +469,23 @@ int safe_gethostname(const char *file, const int lineno,
> return rval;
> }
>
> +int safe_sethostname(const char *file, const int lineno,
> + const char *name, size_t size)
> +{
> + int rval = sethostname(name, size);
> +
> + if (rval == -1) {
> + tst_brkm_(file, lineno, TBROK | TERRNO, NULL,
> + "sethostname(%p, %zu) failed", name, size);
> + } else if (rval) {
> + tst_brkm_(file, lineno, TBROK | TERRNO, NULL,
> + "Invalid sethostname(%p, %zu) return value %d", name,
> + size, rval);
> + }
> +
> + return rval;
> +}
> +
> /*
> * @return port in network byte order.
> */
> --
> 2.35.3
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-02-09 10:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 10:00 [LTP] [PATCH v4 0/2] Rewrite utstest suite Andrea Cervesato via ltp
2023-01-25 10:00 ` [LTP] [PATCH v4 1/2] Add SAFE_SETHOSTNAME macro Andrea Cervesato via ltp
2023-02-09 10:10 ` Richard Palethorpe [this message]
2023-01-25 10:00 ` [LTP] [PATCH v4 2/2] Rewrite utsname testing suite Andrea Cervesato via ltp
2023-02-09 10:11 ` Richard Palethorpe
2023-02-10 17:03 ` Andrea Cervesato via ltp
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=877cwrrvwk.fsf@suse.de \
--to=rpalethorpe@suse.de \
--cc=andrea.cervesato@suse.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.