public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] lib: Document the endianity in tst_get_unused_port()
@ 2019-06-07  7:17 Petr Vorel
  2019-06-07  7:34 ` Christian Amann
  2019-06-07 11:36 ` Cyril Hrubis
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Vorel @ 2019-06-07  7:17 UTC (permalink / raw)
  To: ltp

To prevent confusing [1]:

    if you want to print the port you actually have to use
    ntohs() function to convert it to the host endianity. And if you are
    passing that value in the sockaddr_in structure you must not use the
    htons() since the value is already in the correct byte order.

[1] http://lists.linux.it/pipermail/ltp/2019-June/012289.html

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/safe_net.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/safe_net.c b/lib/safe_net.c
index 970a2aba3..abebd1899 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -373,6 +373,9 @@ int safe_gethostname(const char *file, const int lineno,
 	return rval;
 }
 
+/*
+ * @return port in network byte order.
+ */
 unsigned short tst_get_unused_port(const char *file, const int lineno,
 	      void (cleanup_fn)(void), unsigned short family, int type)
 {
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 1/1] lib: Document the endianity in tst_get_unused_port()
  2019-06-07  7:17 [LTP] [PATCH 1/1] lib: Document the endianity in tst_get_unused_port() Petr Vorel
@ 2019-06-07  7:34 ` Christian Amann
  2019-06-07 11:36 ` Cyril Hrubis
  1 sibling, 0 replies; 4+ messages in thread
From: Christian Amann @ 2019-06-07  7:34 UTC (permalink / raw)
  To: ltp

Hi!

That should make things more clear, thanks!

Reviewed-by: Christian Amann <camann@suse.com>

On 07/06/2019 09:17, Petr Vorel wrote:
> To prevent confusing [1]:
>
>     if you want to print the port you actually have to use
>     ntohs() function to convert it to the host endianity. And if you are
>     passing that value in the sockaddr_in structure you must not use the
>     htons() since the value is already in the correct byte order.
>
> [1] http://lists.linux.it/pipermail/ltp/2019-June/012289.html
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  lib/safe_net.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/safe_net.c b/lib/safe_net.c
> index 970a2aba3..abebd1899 100644
> --- a/lib/safe_net.c
> +++ b/lib/safe_net.c
> @@ -373,6 +373,9 @@ int safe_gethostname(const char *file, const int lineno,
>  	return rval;
>  }
>  
> +/*
> + * @return port in network byte order.
> + */
>  unsigned short tst_get_unused_port(const char *file, const int lineno,
>  	      void (cleanup_fn)(void), unsigned short family, int type)
>  {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190607/1d359253/attachment.html>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 1/1] lib: Document the endianity in tst_get_unused_port()
  2019-06-07  7:17 [LTP] [PATCH 1/1] lib: Document the endianity in tst_get_unused_port() Petr Vorel
  2019-06-07  7:34 ` Christian Amann
@ 2019-06-07 11:36 ` Cyril Hrubis
  2019-06-07 12:46   ` Petr Vorel
  1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2019-06-07 11:36 UTC (permalink / raw)
  To: ltp

Hi!
Acked.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 1/1] lib: Document the endianity in tst_get_unused_port()
  2019-06-07 11:36 ` Cyril Hrubis
@ 2019-06-07 12:46   ` Petr Vorel
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2019-06-07 12:46 UTC (permalink / raw)
  To: ltp

Hi,

> Acked.
Thanks, merged!

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-07 12:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-07  7:17 [LTP] [PATCH 1/1] lib: Document the endianity in tst_get_unused_port() Petr Vorel
2019-06-07  7:34 ` Christian Amann
2019-06-07 11:36 ` Cyril Hrubis
2019-06-07 12:46   ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox