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=-8.5 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT 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 4FD4AC43381 for ; Fri, 22 Feb 2019 09:08:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0E63B2077B for ; Fri, 22 Feb 2019 09:08:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="NCYy68dg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726919AbfBVJIQ (ORCPT ); Fri, 22 Feb 2019 04:08:16 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37073 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfBVJIQ (ORCPT ); Fri, 22 Feb 2019 04:08:16 -0500 Received: by mail-wr1-f66.google.com with SMTP id c8so1514835wrs.4 for ; Fri, 22 Feb 2019 01:08:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=yGE/jl9ZO4uPPJV9Q1HwUGo/Y5qssvmkUZxp27rL02I=; b=NCYy68dgEvmvwuJKHCFUNdASGj7hIMlm7xzMSQvFELKLgxGQprK5S3Xn3e0OPnIppt Yph/lN8T39e5EW/kccMGxbrIXfV4z5dqOx009f693Ztdr3XQSGrSkjJndqbwEM9WfkOw foyNChwn33j85zkbDbvGABigY43aELgGQ/b361A/Ns9Ovp3B1a0bBQ2HjvOU2ENpYOKg ASBCI8krLPUGW+ZzOJbAfbfaQJkcgCxbE/LZfTAFrrdMX1CKwZPorU7FK+UeaO6J15YA OGzyRDuFORLGJQRpJ1V5u/FIE7MZRh9eBumHdWPlTq0wji9j8pxOmxqsr8fkdXFwLRbS qFbQ== 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:in-reply-to:user-agent; bh=yGE/jl9ZO4uPPJV9Q1HwUGo/Y5qssvmkUZxp27rL02I=; b=gWSJvrP9dJ4s9PdhdJpasrl97zdeWie8pk1ySZ6og863+WsNLs++Jy+q4/v6M/AUFK us8LKrvwNHiwa7hM9bI/evyjFvleFSrIqHqnDEz30Y0vU/qx0fo3TIup2dfuGWTvb6DS 6+Pze36t++2a4YJWbFnQg+8NOb+fcNQGgAKv6/LZGsf6ag/7OZfkJgBWEfCp0aa3E3A9 VVwtIYYq/vR6UAT3aU77PqJH1fLHCwgVE4DbHmw110OSaErXoYZFMpPObYan6qQwe0FI 6nbF0YqE9Torv0Ugph9miNSVFYInYd/yNoXh/laxMhiBzkDsMYR+fsu5oXcvp1q0/KSm xXFg== X-Gm-Message-State: AHQUAuYfEl/aVsYNzM3gTy90oRLDbC5Doo6K/5vfZhEYszatocVje5kq W9JAiSwytts4HPfixbJ+j49NqQ== X-Google-Smtp-Source: AHgI3Ib9EdEd4LfSq/+7Xe/jLVqQHJascBiqsX0V2T19JnSKdD9JSnZHkr0BIgJNh78gH2Iwv0CYlA== X-Received: by 2002:a5d:4149:: with SMTP id c9mr2187851wrq.58.1550826494141; Fri, 22 Feb 2019 01:08:14 -0800 (PST) Received: from localhost (mail.chocen-mesto.cz. [85.163.43.2]) by smtp.gmail.com with ESMTPSA id w23sm436416wmc.38.2019.02.22.01.08.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 01:08:13 -0800 (PST) Date: Fri, 22 Feb 2019 09:58:32 +0100 From: Jiri Pirko To: Stephen Hemminger Cc: Aya Levin , David Ahern , netdev@vger.kernel.org, Jiri Pirko , Moshe Shemesh , Eran Ben Elisha Subject: Re: [PATCH v2 iproute2-next 04/11] devlink: Add helper functions for name and value separately Message-ID: <20190222085832.GA2254@nanopsycho> References: <1550756567-18227-1-git-send-email-ayal@mellanox.com> <1550756567-18227-5-git-send-email-ayal@mellanox.com> <20190221100211.28cef41a@shemminger-XPS-13-9360> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190221100211.28cef41a@shemminger-XPS-13-9360> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Thu, Feb 21, 2019 at 07:02:11PM CET, stephen@networkplumber.org wrote: >On Thu, 21 Feb 2019 15:42:40 +0200 >Aya Levin wrote: > >> Add a new helper functions which outputs only values (without name >> label) for different types: boolean, uint, uint64, string and binary. >> In addition add a helper function which prints only the name label. >> >> Signed-off-by: Aya Levin >> Reviewed-by: Moshe Shemesh >> --- >> devlink/devlink.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 65 insertions(+), 1 deletion(-) >> >> diff --git a/devlink/devlink.c b/devlink/devlink.c >> index b073ae020d52..5d69c4f24f29 100644 >> --- a/devlink/devlink.c >> +++ b/devlink/devlink.c >> @@ -1588,7 +1588,6 @@ static void pr_out_port_handle_end(struct dl *dl) >> pr_out("\n"); >> } >> >> - >> static void pr_out_str(struct dl *dl, const char *name, const char *val) >> { >> if (dl->json_output) { >> @@ -1636,6 +1635,71 @@ static void pr_out_u64(struct dl *dl, const char *name, uint64_t val) >> } >> } >> >> +static void pr_out_bool_value(struct dl *dl, bool value) >> +{ >> + if (dl->json_output) >> + jsonw_bool(dl->jw, value); >> + else >> + pr_out(" %s", value ? "true" : "false"); >> +} >> + >> +static void pr_out_uint_value(struct dl *dl, unsigned int value) >> +{ >> + if (dl->json_output) >> + jsonw_uint(dl->jw, value); >> + else >> + pr_out(" %u", value); >> +} >> + >> +static void pr_out_uint64_value(struct dl *dl, uint64_t value) >> +{ >> + if (dl->json_output) >> + jsonw_u64(dl->jw, value); >> + else >> + pr_out(" %lu", value); >> +} >> + >> +static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len) >> +{ >> + int i = 1; >> + >> + if (dl->json_output) >> + jsonw_start_array(dl->jw); >> + else >> + pr_out("\n"); >> + >> + while (i < len) { >> + if (dl->json_output) { >> + jsonw_printf(dl->jw, "%d", data[i]); >> + } else { >> + pr_out(" %02x", data[i]); >> + if (!(i % 16)) >> + pr_out("\n"); >> + } >> + i++; >> + } >> + if (dl->json_output) >> + jsonw_end_array(dl->jw); >> + else if ((i - 1) % 16) >> + pr_out("\n"); >> +} >> + >> +static void pr_out_str_value(struct dl *dl, const char *value) >> +{ >> + if (dl->json_output) >> + jsonw_string(dl->jw, value); >> + else >> + pr_out(" %s", value); >> +} >> + >> +static void pr_out_name(struct dl *dl, const char *name) >> +{ >> + if (dl->json_output) >> + jsonw_name(dl->jw, name); >> + else >> + pr_out(" %s:", name); >> +} >> + >> static void pr_out_region_chunk_start(struct dl *dl, uint64_t addr) >> { >> if (dl->json_output) { > >NAK > >Please convert devlink to use existing iproute2 json_print infrasructure >rather than reinventing it. That requires whole devlink/devlink.c code change. Could this be done as a follow-up?