public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5 1/2] Add SAFE_SETHOSTNAME macro
Date: Tue, 14 Feb 2023 10:00:29 +0000	[thread overview]
Message-ID: <87ilg4o9ac.fsf@suse.de> (raw)
In-Reply-To: <20230210171601.19047-2-andrea.cervesato@suse.com>

Hello,

I think you forgot my existing Reviewed-by tag on this patch.

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

  reply	other threads:[~2023-02-14 10:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10 17:15 [LTP] [PATCH v5 0/2] Rewrite utstest suite Andrea Cervesato via ltp
2023-02-10 17:16 ` [LTP] [PATCH v5 1/2] Add SAFE_SETHOSTNAME macro Andrea Cervesato via ltp
2023-02-14 10:00   ` Richard Palethorpe [this message]
2023-02-10 17:16 ` [LTP] [PATCH v5 2/2] Rewrite utsname testing suite Andrea Cervesato via ltp
2023-02-14 10:36 ` [LTP] [PATCH v5 0/2] Rewrite utstest suite Richard Palethorpe

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=87ilg4o9ac.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox