From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id A94274CBD for ; Mon, 5 Nov 2018 17:26:57 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Nov 2018 08:26:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,468,1534834800"; d="scan'208";a="105431641" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by fmsmga001.fm.intel.com with ESMTP; 05 Nov 2018 08:26:55 -0800 From: Jasvinder Singh To: dev@dpdk.org Cc: ferruh.yigit@intel.com, jingjing.wu@intel.com, bernard.iremonger@intel.com Date: Mon, 5 Nov 2018 16:26:54 +0000 Message-Id: <20181105162654.31505-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105162202.31346-1-jasvinder.singh@intel.com> References: <20181105162202.31346-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH v2] testpmd: fix memory alloc for dscp table X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Nov 2018 16:26:58 -0000 The patch fixes the memory allocation for the meter dscp table. Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing commands") Signed-off-by: Jasvinder Singh --- v2 - fix checkpatch errors app/test-pmd/cmdline_mtr.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c index 63f32828f..846de88db 100644 --- a/app/test-pmd/cmdline_mtr.c +++ b/app/test-pmd/cmdline_mtr.c @@ -74,7 +74,7 @@ parse_uint(uint64_t *value, const char *str) } static int -parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table) +parse_dscp_table_entries(char *str, enum rte_mtr_color **dscp_table) { char *token; int i = 0; @@ -84,23 +84,23 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table) return 0; /* Allocate memory for dscp table */ - dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES * + *dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES * sizeof(enum rte_mtr_color)); - if (dscp_table == NULL) + if (*dscp_table == NULL) return -1; while (1) { if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0) - dscp_table[i++] = RTE_MTR_GREEN; + *dscp_table[i++] = RTE_MTR_GREEN; else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0) - dscp_table[i++] = RTE_MTR_YELLOW; + *dscp_table[i++] = RTE_MTR_YELLOW; else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0) - dscp_table[i++] = RTE_MTR_RED; + *dscp_table[i++] = RTE_MTR_RED; else { - free(dscp_table); + free(*dscp_table); return -1; } if (i == MAX_DSCP_TABLE_ENTRIES) @@ -108,7 +108,7 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table) token = strtok_r(str, PARSE_DELIMITER, &str); if (token == NULL) { - free(dscp_table); + free(*dscp_table); return -1; } } @@ -117,7 +117,7 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table) static int parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color, - enum rte_mtr_color *dscp_table) + enum rte_mtr_color **dscp_table) { char *token; uint64_t previous_mtr_color = 0; @@ -195,7 +195,7 @@ parse_policer_action_string(char *p_str, uint32_t action_mask, static int parse_multi_token_string(char *t_str, uint16_t *port_id, - uint32_t *mtr_id, enum rte_mtr_color *dscp_table) + uint32_t *mtr_id, enum rte_mtr_color **dscp_table) { char *token; uint64_t val; @@ -794,7 +794,7 @@ static void cmd_create_port_meter_parsed(void *parsed_result, params.meter_profile_id = res->profile_id; /* Parse meter input color string params */ - ret = parse_meter_color_str(c_str, &use_prev_meter_color, dscp_table); + ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table); if (ret) { printf(" Meter input color params string parse error\n"); return; @@ -1141,7 +1141,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result, int ret; /* Parse string */ - ret = parse_multi_token_string(t_str, &port_id, &mtr_id, dscp_table); + ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &dscp_table); if (ret) { printf(" Multi token string parse error\n"); return; -- 2.17.1