From patchwork Fri Jun 7 07:17:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1111597 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Kv4x5cqVz9s4Y for ; Fri, 7 Jun 2019 17:18:09 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D91DE3EA67C for ; Fri, 7 Jun 2019 09:18:06 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id F3F7B3EA5E4 for ; Fri, 7 Jun 2019 09:18:04 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 17184601251 for ; Fri, 7 Jun 2019 09:18:05 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A3725AED7; Fri, 7 Jun 2019 07:18:02 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 7 Jun 2019 09:17:51 +0200 Message-Id: <20190607071751.9225-1-pvorel@suse.cz> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Cc: Christian Amann Subject: [LTP] [PATCH 1/1] lib: Document the endianity in tst_get_unused_port() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "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 Reviewed-by: Christian Amann --- 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) {