Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1659429pxy; Thu, 6 May 2021 12:34:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVONo3EdGCMdeVrqQlsl6ZHGR7zGjTLx2c2Qb7VWuqG8tzvvPtr2X7kE2ZFrI9sF5cQohJ X-Received: by 2002:a63:1165:: with SMTP id 37mr6071866pgr.295.1620329641312; Thu, 06 May 2021 12:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620329641; cv=none; d=google.com; s=arc-20160816; b=wYgRUaM/06TmJ/qjVYTm1H02zHyhf1AhtVHIDnmX0ECwS36oDbTy7zyS89tyQNGjTj ADiNDZ0miVMVB6jC7ToMfKWPuy1iWma6yjQDCTVxQ9nIpDFX3GutKmDjj+P0n4mUN+/6 M2vmm9SVAYwA3uhL5D6p/dFFoJmAGMUz6U/StnD62AKjDNYpfmejPdbjKgRQGrq/h1AT sV3KryN3cDcBa4MG8mCSAlA3TB1ivnT/XcEIF7sYYjQGz14GKht6nz18U3lN0Qd+QVx8 vNccr5SRBQYDkaFM5aw1YbPeFIOYKIAAo0Yv/y4Ek1EKSgo5lRHR1rr/Qx9ANUnJt1Lg 9lBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Q38PAJ9+uMS5LIyUmdseGu2IcazIhzhvbZQsCgfZzn4=; b=soLDu4bFiO2Ru8M1G3eqDkBKbxbhTviBLfVYm85iZteQALbRBsEEjd92tycnhxpxh3 Zsf1RsIU3BBOTLESGpVGpmdSQAM88QlNTEFltua8ANW0IodbDmTLLOyK1E90mQmEOKd4 zfMeV0ghcrKe/Ei31nq3Gq5/4Sui1aYIGGr0iG8WkG3sPt89IpjIbOqQxdz4Y84C3Yom ZX4pmaOjY+Jgl4W23I8D8kbLCaqBWag1sbbwf5vsnabz+2qz+LfkFPK2GrElN3fHbVAG WexIEOWKgeom+sh/Z/zvepPLVVzRAdjoJ3rALt0exRY2a7oHILgCkr8uEYHtnMUX9q9S n1iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=1cUZc1c2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r15si4984858pgv.80.2021.05.06.12.33.35; Thu, 06 May 2021 12:34:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=1cUZc1c2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235716AbhEFPvp (ORCPT + 99 others); Thu, 6 May 2021 11:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235136AbhEFPvn (ORCPT ); Thu, 6 May 2021 11:51:43 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A612BC061574 for ; Thu, 6 May 2021 08:50:44 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id h127so5422902pfe.9 for ; Thu, 06 May 2021 08:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q38PAJ9+uMS5LIyUmdseGu2IcazIhzhvbZQsCgfZzn4=; b=1cUZc1c2lIsjBJsJ4rOOvLJzMepMGS/DzSPn09nST1vPpjvY9wgA70C4DBLt5bGDLJ WPaAXEaZgEjBu4Q0C88uBp5IWO1zeRjgwNNzt/vB7YfXxhyoT9XA1jkn4QHpn0qYJCaM oxXiurTz9jG3MEFWRmuKrqTmV5VJy0v+51oSeAQ0aWNCOI0ParK4dXwosAl0qVpmGIv/ CDCsMnSmjisWdGai9oQyt1T9HZzUTym6xYlpNa/YP5ZUT/SP+yREFbbbALXzRei9J6jB reDLe2tSkqnnkAttGhpPxy3nUjTOLA4TtzbfshBodbwN1QaHhboQmjUlEPSKAM4BU/X+ tt5w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q38PAJ9+uMS5LIyUmdseGu2IcazIhzhvbZQsCgfZzn4=; b=rGDz/TR67x0a/fb0Kkf/TDP48WwRKMSZDAP1CnrWb/GIXhh7MUw3C8+aUqK5GT03aY y4MKZsMbW1V/NLBa9FHfJ+PJJQ6wsx4BvRujVb0Ll4D3il0kfC1m34+dCSW/3hLZKdpL VusLOj6+TYFpBC/E2OzqGYSGxoLWe5GmGbzpoIVkMjxyEUWY3wCetsxEoVyGGYBB95PW 4Hbf1Sfnz8a/5IJz7UwYVok/0sQ+qQkbIAhjQm+cvpgC6vsVHLG1e2VA8bYOiC1Q8aTc xI0iGbE05eTZ70+6Jg7yzygmGarbP7eFLlu7XlFeun5y0L3yjmu1+kVqzUBcw8znqAbC puog== X-Gm-Message-State: AOAM530WgMaVhBxUdMki0zbbuGtZ54Mp1dVl5tjd2LMLK+y20oaIYm9J mAw6XmDGwkBLWilIu6WVRDtufg== X-Received: by 2002:a63:bd49:: with SMTP id d9mr4884354pgp.311.1620316244117; Thu, 06 May 2021 08:50:44 -0700 (PDT) Received: from hermes.local (76-14-218-44.or.wavecable.com. [76.14.218.44]) by smtp.gmail.com with ESMTPSA id d8sm2329844pfl.156.2021.05.06.08.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 08:50:43 -0700 (PDT) Date: Thu, 6 May 2021 08:50:35 -0700 From: Stephen Hemminger To: Vincent Mailhol Cc: Marc Kleine-Budde , linux-can@vger.kernel.org, Oliver Hartkopp , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v1 1/1] iplink_can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC) Message-ID: <20210506085035.2fc33bf3@hermes.local> In-Reply-To: <20210506112007.1666738-2-mailhol.vincent@wanadoo.fr> References: <20210506112007.1666738-1-mailhol.vincent@wanadoo.fr> <20210506112007.1666738-2-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 May 2021 20:20:07 +0900 Vincent Mailhol wrote: > + if (tb[IFLA_CAN_TDC_TDCV] && tb[IFLA_CAN_TDC_TDCO] && > + tb[IFLA_CAN_TDC_TDCF]) { > + __u32 *tdcv = RTA_DATA(tb[IFLA_CAN_TDC_TDCV]); > + __u32 *tdco = RTA_DATA(tb[IFLA_CAN_TDC_TDCO]); > + __u32 *tdcf = RTA_DATA(tb[IFLA_CAN_TDC_TDCF]); > + > + if (is_json_context()) { > + open_json_object("tdc"); > + print_int(PRINT_JSON, "tdcv", NULL, *tdcv); > + print_int(PRINT_JSON, "tdco", NULL, *tdco); > + print_int(PRINT_JSON, "tdcf", NULL, *tdcf); > + close_json_object(); > + } else { > + fprintf(f, "\n tdcv %d tdco %d tdcf %d", > + *tdcv, *tdco, *tdcf); > + } > + } > + The most common pattern in iproute2 is to let json/non-json be decided inside the print routine. I search for all instances of fprintf as indication of broken code. Also these are not signed values so please print unsigned. The code should use print_nl() to handle the single line case. Also, there is helper to handle Something like: __u32 tdc = rte_getattr_u32(tb[IFLA_CAN_TDC_TDCV]); open_json_object("tdc"); print_nl(); print_u32(PRINT_ANY, "tdcv", " tdcv %u", tdcv); ...