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 BEBCBA0C43; Wed, 16 Jun 2021 20:07:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 01305410DA; Wed, 16 Jun 2021 20:07:30 +0200 (CEST) Received: from mail-ua1-f99.google.com (mail-ua1-f99.google.com [209.85.222.99]) by mails.dpdk.org (Postfix) with ESMTP id 299A940683 for ; Wed, 16 Jun 2021 20:07:29 +0200 (CEST) Received: by mail-ua1-f99.google.com with SMTP id f34so1094881uae.4 for ; Wed, 16 Jun 2021 11:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OGyFlzWCfQIxD4ZcKldWiRHStRmEHk5zBxu1qYGJyks=; b=GvzRGkscJoZfgi0APV855Bdf+ccmlhtWIh4LzVzKqO4g3AUf11df0evJ30NbUsNz7g SblsrV6KkYQnNMueaTkglaHn93ok9791v/ZNNSJbgIqKbppuj7TVUGfbN+/rGdzK77si SJs9kJC2vOgm/yf/Mm6qatpVELeLazBjxSUoY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OGyFlzWCfQIxD4ZcKldWiRHStRmEHk5zBxu1qYGJyks=; b=LwV8CgSmdFIdeIlSh7wDOxMxvT+uz/rOY0mxUFt0KhX9RVR34vdbK3DsIUtsjwEi34 3W4wcJjkdvfOewoniEaXEdmg9onoOPOc8ERoGc61N/kIsmc0L6q7NuotUy/yq+6lyVEd XQoYutM4SegXTGygn6x1rBFk/fmM0OzBrHtJo1Iqyp/8nVaaw9j+DOhe995yipiA0gHJ McQ/35CQ4+K7t+mPU5PHVDCbS2b0nhDwafL9e0W15wOpuLBHCgw7GEA9378i8MQvfhKw 1qoyxb4AkZkTy+aKQWw1sZR/U262KL7Y3wGptBO3bS4UhigldlDsiYpzcHd9atf3ECDr 67mQ== X-Gm-Message-State: AOAM533aIa/j031BPT4f1SN+GE7B7Qn1gCy0a5e3SpdLOvxhacK4dLdu TmCXk9EP/RFM2DYkvhelHpgfkxWmuAiiU3XG0yiZ3yXEOK1xwg== X-Google-Smtp-Source: ABdhPJwnf5bz1JjStqCGUnVPzi89fBeO+vYD4u7r7Rza2LF4a/MmpYjktW4LtXybZgbo7/3c7kUVpRGZh92S X-Received: by 2002:a9f:374c:: with SMTP id a12mr994122uae.91.1623866847891; Wed, 16 Jun 2021 11:07:27 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id d72sm1137530vkf.7.2021.06.16.11.07.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jun 2021 11:07:27 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1220:5e2f:685e:142b:54c3]) by postal.iol.unh.edu (Postfix) with ESMTP id 39F21605246B; Wed, 16 Jun 2021 14:07:27 -0400 (EDT) From: ohilyard@iol.unh.edu To: olivier.matz@6wind.com Cc: dev@dpdk.org, david.marchand@redhat.com, stable@dpdk.org, Owen Hilyard Date: Wed, 16 Jun 2021 14:07:24 -0400 Message-Id: <20210616180724.355217-1-ohilyard@iol.unh.edu> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616162553.350074-1-ohilyard@iol.unh.edu> References: <20210616162553.350074-1-ohilyard@iol.unh.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] tests/cmdline: fix memory leaks 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 Sender: "dev" From: Owen Hilyard Fixes for a few memory leaks in the cmdline_autotest unit test. All of the leaks were related to not freeing the commandline struct after testing had completed. Fixes: dbb860e03e ("cmdline: tests") Signed-off-by: Owen Hilyard Reviewed-by: David Marchand --- app/test/test_cmdline_lib.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c index bd72df0da..19228c9a5 100644 --- a/app/test/test_cmdline_lib.c +++ b/app/test/test_cmdline_lib.c @@ -71,10 +71,12 @@ test_cmdline_parse_fns(void) if (cmdline_complete(cl, "buffer", &i, NULL, sizeof(dst)) >= 0) goto error; + cmdline_free(cl); return 0; error: printf("Error: function accepted null parameter!\n"); + cmdline_free(cl); return -1; } @@ -140,32 +142,43 @@ static int test_cmdline_socket_fns(void) { cmdline_parse_ctx_t ctx; + struct cmdline *cl; - if (cmdline_stdin_new(NULL, "prompt") != NULL) + cl = cmdline_stdin_new(NULL, "prompt"); + if (cl != NULL) goto error; - if (cmdline_stdin_new(&ctx, NULL) != NULL) + cl = cmdline_stdin_new(&ctx, NULL); + if (cl != NULL) goto error; - if (cmdline_file_new(NULL, "prompt", "/dev/null") != NULL) + cl = cmdline_file_new(NULL, "prompt", "/dev/null"); + if (cl != NULL) goto error; - if (cmdline_file_new(&ctx, NULL, "/dev/null") != NULL) + cl = cmdline_file_new(&ctx, NULL, "/dev/null"); + if (cl != NULL) goto error; - if (cmdline_file_new(&ctx, "prompt", NULL) != NULL) + cl = cmdline_file_new(&ctx, "prompt", NULL); + if (cl != NULL) goto error; - if (cmdline_file_new(&ctx, "prompt", "-/invalid/~/path") != NULL) { + cl = cmdline_file_new(&ctx, "prompt", "-/invalid/~/path"); + if (cl != NULL) { printf("Error: succeeded in opening invalid file for reading!"); + cmdline_free(cl); return -1; } - if (cmdline_file_new(&ctx, "prompt", "/dev/null") == NULL) { + cl = cmdline_file_new(&ctx, "prompt", "/dev/null"); + if (cl == NULL) { printf("Error: failed to open /dev/null for reading!"); + cmdline_free(cl); return -1; } /* void functions */ cmdline_stdin_exit(NULL); - + cmdline_free(cl); return 0; error: printf("Error: function accepted null parameter!\n"); + cmdline_free(cl); return -1; } @@ -198,6 +211,7 @@ test_cmdline_fns(void) cmdline_interact(NULL); cmdline_quit(NULL); + cmdline_free(cl); return 0; error: -- 2.30.2