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 3D9AF428D4; Wed, 5 Apr 2023 18:05:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41EF942D3A; Wed, 5 Apr 2023 18:04:49 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 9506042C24 for ; Wed, 5 Apr 2023 18:04:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680710686; x=1712246686; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kmwz0JZLMz/PYB9q+460ZarpveznP3XHVPXKHnvqjbk=; b=NAhzmwV87OL+o/3xLXeBUUesHUhFaOH8zVEmyqQ8FbHnnlT9YpR1xDWN EaFlTLcP+x664KejE5HudjEbjX2nvQFNq5CLwr4dwDQL9nslwws/w8IOD oFYh/GNuHJYmjkRtYNitWCSgZkuWd9yfwn578DHAMApoU6vvWCm9as+lQ qE2JiTyNwytutP5IQrqRrMsDS2c/lgY9TzJ2+n2X+1e21BZwDdr2rtutr ExBsic2AzMhohZErbB2RGJghVrCWCnIyzrB5auJLCYZoQSBghJRGUXlfV kMa0khW42aiPYA+CYhf9C8VFKoXiZRmmeh1N8Y6Ink4YcYcmlYeSZmnOQ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="341218622" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="341218622" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 09:04:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="830405825" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="830405825" Received: from silpixa00401385.ir.intel.com ([10.237.214.40]) by fmsmga001.fm.intel.com with ESMTP; 05 Apr 2023 09:04:20 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ciara.power@intel.com, roretzla@linux.microsoft.com, Bruce Richardson Subject: [PATCH v3 4/5] telemetry: rename local variables Date: Wed, 5 Apr 2023 17:03:25 +0100 Message-Id: <20230405160326.186921-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230405160326.186921-1-bruce.richardson@intel.com> References: <20230310181836.162336-1-bruce.richardson@intel.com> <20230405160326.186921-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 aada523a27..c087b833eb 100644 --- a/lib/telemetry/telemetry_json.h +++ b/lib/telemetry/telemetry_json.h @@ -84,44 +84,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