From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f172.google.com (mail-wr0-f172.google.com [209.85.128.172]) by dpdk.org (Postfix) with ESMTP id 7C8FF7CC9 for ; Fri, 18 Aug 2017 09:43:12 +0200 (CEST) Received: by mail-wr0-f172.google.com with SMTP id z91so54633625wrc.4 for ; Fri, 18 Aug 2017 00:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=ECWR4QyqGf3tAlX+6RAIsO8SlmHZV0mGdILk87pmCn8=; b=Wz2kElkarJQE+05LbOFJnH9rA6GM5cpABLXX0QHynwttvxwWA1iyhwjrs1d4Jvcpry gFn829r66QTa1Ef9y4hWBLj3JbdR8yemCXq9A/pxOEKB8YahcUDcijUwFE5UFpw9UyCx ZbOhAnZUXmUYR8aThtOVaTlGIYz3AKyDCYQQWRHExLyvUMG0zMBELbRz3JbMBIN/t3kg jB4/73Ldc0jyhIdmeElp0iDk3xo2G3pVlgMox2xcEGd6Mx0f25ziE/5wlMGZMOZYxVzz Y2DoQ2n8I0Dx54T4/JIHxY3M2FT8ce63RaznUFfIoARijfBSIk3ywrqt90vglSKBUoKC RHlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=ECWR4QyqGf3tAlX+6RAIsO8SlmHZV0mGdILk87pmCn8=; b=SwAZcBef47Dbo+iF2Zebq7P/DRfPXHKs1hgWm4tv2s28ZkRZGC+lmPoQe4YGeCDd2h 4k40LsiAa7xpAGuobeONTFl1k2SDvFAF+l/1amp+StDpXDNYlrQ6fV5Fa22fOy0MgUY8 PsHVdi6nA+m/05opf+ZlUwJo319zezlLhWqvmgGI429Y9GwWfrmaD8NohvBAYGYTUsaa 92RtOHFBe7HB2Nc0BvCSm0fzkOhn54ZGxVA/TMmTJHoNBANHcYgubbeal0NtoFPzY7dM n8kea2cI68UhOn0OyepkxQ7nAnDgwzXE3eWqN4x7taA1bYGjw7cf9AOZUZx1lz5tpjFK pMyg== X-Gm-Message-State: AHYfb5gc/usXTPM64QHWG0pbFpkUdzRRsoqGt+GEfVD2GbkW4KeAjwlv 3Qy9UbppKQ9aZxrw X-Received: by 10.28.29.2 with SMTP id d2mr868128wmd.152.1503042192048; Fri, 18 Aug 2017 00:43:12 -0700 (PDT) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id w73sm733984wmw.20.2017.08.18.00.43.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 00:43:11 -0700 (PDT) Date: Fri, 18 Aug 2017 09:43:01 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Stephen Hemminger Cc: dev@dpdk.org Message-ID: <20170818074301.GR8124@bidouze.vm.6wind.com> References: <1502985129-7461-1-git-send-email-gaetan.rivet@6wind.com> <20170817173929.4f8951c3@xeon-e3> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170817173929.4f8951c3@xeon-e3> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH] net/failsafe: safer subdev iterator X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Aug 2017 07:43:12 -0000 On Thu, Aug 17, 2017 at 05:39:29PM -0700, Stephen Hemminger wrote: > On Thu, 17 Aug 2017 17:52:09 +0200 > Gaetan Rivet wrote: > > > The sub_device iterator macro should follow the general gist of the > > tailq API for an easier understanding and safer use. > > > > Once the loop has finished, the iterator should be set to NULL. > > If no sub_device was iterated upon, the iterator should still be NULL. > > > > Signed-off-by: Gaetan Rivet > > --- > > drivers/net/failsafe/failsafe_private.h | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h > > index 0361cf4..6fa8de5 100644 > > --- a/drivers/net/failsafe/failsafe_private.h > > +++ b/drivers/net/failsafe/failsafe_private.h > > @@ -222,6 +222,7 @@ extern int mac_from_arg; > > */ > > #define FOREACH_SUBDEV_STATE(s, i, dev, state) \ > > for (i = fs_find_next((dev), 0, state); \ > > + ((s = NULL) == NULL) && \ > I assume you are trying to do assignment inside an expression and just expect that > to always to be true and go onto next part of assignment. This is a convulted > way to put code in the loop iterator. > > But this macro is way too complex. Please break it up into inline functions or > figure out how to simplify the logic better. I think you are right, thanks for the wake-up call. -- Gaëtan Rivet 6WIND