From patchwork Sun Apr 17 09:10:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Janda X-Patchwork-Id: 8862591 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A49F49F1D3 for ; Sun, 17 Apr 2016 09:10:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E5192017D for ; Sun, 17 Apr 2016 09:10:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9325120173 for ; Sun, 17 Apr 2016 09:10:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751400AbcDQJKy (ORCPT ); Sun, 17 Apr 2016 05:10:54 -0400 Received: from mout01.posteo.de ([185.67.36.65]:57720 "EHLO mout01.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbcDQJKy (ORCPT ); Sun, 17 Apr 2016 05:10:54 -0400 Received: from dovecot03.posteo.de (dovecot03.posteo.de [172.16.0.13]) by mout01.posteo.de (Postfix) with ESMTPS id 031CB20AA8 for ; Sun, 17 Apr 2016 11:10:52 +0200 (CEST) Received: from mail.posteo.de (localhost [127.0.0.1]) by dovecot03.posteo.de (Postfix) with ESMTPSA id 3qnlqv63sbz5vND; Sun, 17 Apr 2016 11:10:51 +0200 (CEST) Date: Sun, 17 Apr 2016 11:10:13 +0200 From: Felix Janda To: libtirpc-devel@lists.sourceforge.net Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/7] clnt_bcast: Remove dependency on Message-ID: <20160417091013.GB2737@nyan> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Unlike glibc, musl libc does not ship with the header and suggests for distros or upstream projects to supply the header. is used only in clnt_bcast.c and only very few TAILQ_* macros are used there. Therefore, just expand these macros, simplify the structure names (e.g. tqh_first -> first) and inline struct link in struct broadif. Signed-off-by: Felix Janda --- src/clnt_bcast.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/clnt_bcast.c b/src/clnt_bcast.c index 98cf061..cb6510e 100644 --- a/src/clnt_bcast.c +++ b/src/clnt_bcast.c @@ -40,8 +40,6 @@ */ #include #include -#include - #include #include #include @@ -97,18 +95,17 @@ * also here it will get two responses ... inefficient and clumsy. */ -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define TAILQ_FIRST(head) ((head)->tqh_first) - - struct broadif { int index; struct sockaddr_storage broadaddr; - TAILQ_ENTRY(broadif) link; + struct broadif *next; + struct broadif **prev; }; -typedef TAILQ_HEAD(, broadif) broadlist_t; +typedef struct { + struct broadif *first; + struct broadif **last; +} broadlist_t; int __rpc_getbroadifs(int, int, int, broadlist_t *); void __rpc_freebroadifs(broadlist_t *); @@ -179,7 +176,10 @@ __rpc_getbroadifs(int af, int proto, int socktype, broadlist_t *list) free(bip); continue; } - TAILQ_INSERT_TAIL(list, bip, link); + bip->next = NULL; + bip->prev = list->last; + *list->last = bip; + list->last = &bip->next; count++; } freeifaddrs(ifp); @@ -193,10 +193,10 @@ __rpc_freebroadifs(broadlist_t *list) { struct broadif *bip, *next; - bip = TAILQ_FIRST(list); + bip = list->first; while (bip != NULL) { - next = TAILQ_NEXT(bip, link); + next = bip->next; free(bip); bip = next; } @@ -343,7 +343,8 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, if (!__rpc_nconf2sockinfo(nconf, &si)) continue; - TAILQ_INIT(&fdlist[fdlistno].nal); + fdlist[fdlistno].nal.first = NULL; + fdlist[fdlistno].nal.last = &fdlist[fdlistno].nal.first; if (__rpc_getbroadifs(si.si_af, si.si_proto, si.si_socktype, &fdlist[fdlistno].nal) == 0) continue; @@ -468,8 +469,8 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, stat = RPC_CANTSEND; continue; } - for (bip = TAILQ_FIRST(&fdlist[i].nal); bip != NULL; - bip = TAILQ_NEXT(bip, link)) { + for (bip = fdlist[i].nal.first; bip != NULL; + bip = bip->next) { void *addr; addr = &bip->broadaddr;