From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DE9EC282C0 for ; Thu, 24 Jan 2019 00:27:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3586E217D7 for ; Thu, 24 Jan 2019 00:27:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PaiXTyi3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726309AbfAXA1t (ORCPT ); Wed, 23 Jan 2019 19:27:49 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34798 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfAXA1s (ORCPT ); Wed, 23 Jan 2019 19:27:48 -0500 Received: by mail-pg1-f193.google.com with SMTP id j10so1856802pga.1 for ; Wed, 23 Jan 2019 16:27:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NDTJ5yK+7FFtg5TH8TR+flKuBUH/thhXdHregx7I/Z8=; b=PaiXTyi34j/co40lXhZQUhsmyUpI4jwubcdzZRwazTRxpghJryhH9DI/HL8jtX34g+ 43P1PsFyCAOmzc1k8X9DVLKRehwEY6uVjnbtb94X9j5R43QurMA0u8g+u8pZn0aMI0W3 Gi7ifJQ7hJ24yK+XuFHXfqIl4/H9K6Uf7QtbE+4DsJa0JfsJry5zqZh9HdpOSQX9mtrZ lf6Wlfwes3773Iwb4igE2RW8zbd2Pu7lUlRYV6hSyu5hLMnOuNQyXFGHd90ypZPwSrrg 6WcVH0o+giBhBBGZsUq2bLe9tNm2vWw2NB1seRf7Ez0F8Lj8JEhypAvLqshHgRTLE7zn 4M6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NDTJ5yK+7FFtg5TH8TR+flKuBUH/thhXdHregx7I/Z8=; b=OpJgPWr2PlogkD4/eSuiAKTP8LVc2IzvSEhX90haV5FpSljKjmyC9VA2jq6bT7TN7A w/FAOjNyP17Dm+KtXKvrYXirEgDJ65266JYSZPubS62xtSyiqaLwaNgQdAi1cXewfPgM GX78biRLh30Q39GK4ectLRSqFKKA9nrL/BxqRWI/5SqnAlT8vZPoXAhqEnBinUYgJ4bs KI0cV6clpn/F7sbjY5BI3+lHOEtMR+pws/e1VA2dkbcczb20uBrU73Tcbgtyd81tJxOg vKcZV0BYNrXeTdyPUoIGV/kaWQn6BsGIXzOKyut2U65+KjNoDjWj3JLzXUjpR7lAgpHG xvoA== X-Gm-Message-State: AJcUukemPUMDO0/SvhzvtUeAbwqgpI2fkWB1cPcphRvkt0e2PlBOQaDO w6oAJZpFgwceTKo6E5b4dY8= X-Google-Smtp-Source: ALg8bN498eHpB67cJBe3UUceYkvLsroM4xpLO8vL7JIBChkoqbduMNEiJbfZ2FmQpqIuLQ9yooeNgg== X-Received: by 2002:a63:ec4b:: with SMTP id r11mr3904315pgj.44.1548289668101; Wed, 23 Jan 2019 16:27:48 -0800 (PST) Received: from ?IPv6:2601:282:800:fd80:d3b:2618:8938:ee00? ([2601:282:800:fd80:d3b:2618:8938:ee00]) by smtp.googlemail.com with ESMTPSA id h8sm22383476pgv.27.2019.01.23.16.27.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 16:27:46 -0800 (PST) Subject: Re: [PATCH iproute2-next v2] devlink: Add health command support To: Aya Levin , "netdev@vger.kernel.org" , "David S. Miller" , Jiri Pirko Cc: Moshe Shemesh , Eran Ben Elisha , Tal Alon , Ariel Almog References: <1547762360-7075-1-git-send-email-eranbe@mellanox.com> <1547976434-4142-1-git-send-email-ayal@mellanox.com> <4fa4b872-1617-a795-bf86-5c02ed0d2feb@gmail.com> <801c73a5-3978-6541-8edc-f7e3036b3a80@mellanox.com> From: David Ahern Message-ID: <0ba73aaa-8fc5-d6ef-d106-b49844740df8@gmail.com> Date: Wed, 23 Jan 2019 17:27:45 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <801c73a5-3978-6541-8edc-f7e3036b3a80@mellanox.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 1/23/19 4:27 AM, Aya Levin wrote: >>> @@ -1298,6 +1322,12 @@ static int dl_argv_parse(struct dl *dl, uint32_t o_required, >>> return -EINVAL; >>> } >>> >>> + if ((o_required & DL_OPT_HEALTH_REPORTER_NAME) && >>> + !(o_found & DL_OPT_HEALTH_REPORTER_NAME)) { >>> + pr_err("Reporter name expected.\n"); >>> + return -EINVAL; >>> + } >> >> I realize your are following suit with this change, but these checks for >> 'required and not found' are getting really long. There is a better way >> to do this. > Do you mean somthing like: > #define requiered_not_found(o_found, o_required, flag, msg) \ > ({ \ > if ((o_required & flag) && !(o_found & flag)) { \ > pr_err("%s \n", msg); \ > return -EINVAL; \ > } \ > }) > That's one way. I was also thinking a helper that does a single loop with an array of bits and messages to print if required and not found. That parse function is currently 355 lines long with a lot of repetition.