From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F24C4428D4; Wed, 5 Apr 2023 17:45:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8602742D2D; Wed, 5 Apr 2023 17:44:39 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 34D6E42D13 for ; Wed, 5 Apr 2023 17:44:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680709478; x=1712245478; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fNu55pEca/MaDdDy6qY7lvnjZ3nahCffEj5thK9tnxc=; b=DdPGScRXsD1kG22AirNwtPygB60n2pX8U0XenyttPXAw77qXD+RR4Y9B pJSIOqhNawrMmZxeM10WPUiNaOOU01zaoknVWDbvP2fI3q62aRCzyWjB8 KwLENfR5HAHX0oqMqc4Cnp8KB7xzHmb/6V5ci0kGTDXadsiCsYc2sqItm ia8rn9miNqcoUp16eKIqcR9v73X/DWUZww4tUnGGJQqfr6hG9pLPkyAJL 6qw8A5ObeUX0Drdf0i8Kydun/kBVIKiQJEOIYisLs5xRcTcfN9N7jy6sG Lsbs+8d5n7M3Ip1kLhnoFZtm/mwf1oRSxJ1ryABzzVs+xOS4Ux4ESVxyx Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="339980393" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="339980393" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 08:44:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="686790302" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="686790302" Received: from silpixa00401385.ir.intel.com ([10.237.214.40]) by orsmga002.jf.intel.com with ESMTP; 05 Apr 2023 08:44:36 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ciara.power@intel.com, roretzla@linux.microsoft.com, Bruce Richardson Subject: [PATCH v2 4/5] telemetry: rename local variables Date: Wed, 5 Apr 2023 16:44:13 +0100 Message-Id: <20230405154414.183915-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230405154414.183915-1-bruce.richardson@intel.com> References: <20230310181836.162336-1-bruce.richardson@intel.com> <20230405154414.183915-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org In the newly separated out function, rename "tmp" to "buf" to have more meaningful variable names. Signed-off-by: Bruce Richardson --- When committing, this patch can be merged with the previous. I've kept them separate for now, as it makes reviewing a lot easier. --- lib/telemetry/telemetry_json.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h index 4c1941ad15..4d725d938b 100644 --- a/lib/telemetry/telemetry_json.h +++ b/lib/telemetry/telemetry_json.h @@ -80,44 +80,44 @@ static const char control_chars[0x20] = { * directly, but returns 0 on overflow. Otherwise returns number of chars written to buffer. */ static inline int -__json_format_str_to_buf(char *tmp, const int len, +__json_format_str_to_buf(char *buf, const int len, const char *prefix, const char *str, const char *suffix) { - int tmpidx = 0; + int bufidx = 0; - while (*prefix != '\0' && tmpidx < len) - tmp[tmpidx++] = *prefix++; - if (tmpidx >= len) + while (*prefix != '\0' && bufidx < len) + buf[bufidx++] = *prefix++; + if (bufidx >= len) return 0; while (*str != '\0') { if (*str < (int)RTE_DIM(control_chars)) { int idx = *str; /* compilers don't like char type as index */ if (control_chars[idx] != 0) { - tmp[tmpidx++] = '\\'; - tmp[tmpidx++] = control_chars[idx]; + buf[bufidx++] = '\\'; + buf[bufidx++] = control_chars[idx]; } } else if (*str == '"' || *str == '\\') { - tmp[tmpidx++] = '\\'; - tmp[tmpidx++] = *str; + buf[bufidx++] = '\\'; + buf[bufidx++] = *str; } else - tmp[tmpidx++] = *str; + buf[bufidx++] = *str; /* we always need space for (at minimum) closing quote and null character. * Ensuring at least two free characters also means we can always take an * escaped character like "\n" without overflowing */ - if (tmpidx > len - 2) + if (bufidx > len - 2) return 0; str++; } - while (*suffix != '\0' && tmpidx < len) - tmp[tmpidx++] = *suffix++; - if (tmpidx >= len) + while (*suffix != '\0' && bufidx < len) + buf[bufidx++] = *suffix++; + if (bufidx >= len) return 0; - tmp[tmpidx] = '\0'; - return tmpidx; + buf[bufidx] = '\0'; + return bufidx; } /** -- 2.37.2