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 0B4DEA0547; Thu, 24 Jun 2021 14:07:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4717640683; Thu, 24 Jun 2021 14:07:57 +0200 (CEST) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mails.dpdk.org (Postfix) with ESMTP id C33BF40040 for ; Thu, 24 Jun 2021 14:07:56 +0200 (CEST) Received: by mail-wr1-f47.google.com with SMTP id h11so6379179wrx.5 for ; Thu, 24 Jun 2021 05:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wbnSc/zkyV30k10qtV11gCnJxxQJTEBha20tuing2ig=; b=kFjVmw/nWD+XKij8PsNQStJ4wdsDyM+fH8a8LbX/io9UmlRxbtBp3trZIQjakucggq lx8zSu8MZ765dBCa+qOiki39BIfEopgJa3Xvb4xyvoD5gr/3VKfJObuxkyCDz3Cd+4HS zAeo3qMDmx1e2pu4uk+6vnKjSBy5cW1eZPoEsv4gl1Dj1KASHk2GKMcIXzNHszmvsAxj qOGS9zyM1wOZT6N5NfiUX/lQN59eBCAVNI2sEkFdBsDiN/dSpcXvu3n8xb1iGwKCAqs9 7GOAu34QJM2tPbERXdw4WEagbDfC50vZHrSEipGuCcdSDDq9ixELy4zuhkjEyhAKQRew +K7A== 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:references :mime-version:content-disposition:in-reply-to; bh=wbnSc/zkyV30k10qtV11gCnJxxQJTEBha20tuing2ig=; b=f5hw8h6E4UZXNpSI1Wo8MbcBnyTV+G4Nml5OWNSFMQhb5Lckep5bpF3F6v1wJ1qGWI 6F8lCWf3DO6X8OoEbMsib/0WG2li+/dPEHc8BRtaP1E2dS1X6yLthTeIEJfNsXRtIOuM F4aT70r664mYAjOv3EsaA5kTyUZCdXbI32pAW/V88Wxp6EjAMKFJ/O5hX94FBycJK+wy EVadsszwWFG2NmqdzCW6cB4dW2huduWABK4sHjgg237fKqu6yeNEOakhC2ckIgRecn/P cCO1VeI9Jn5C4q9Fr6mqc4G4H+VsgAcrsdDU78djJYpXIwcC4toh9woy10wondMn7Z3j cKnw== X-Gm-Message-State: AOAM531Twhnbl5DKE1dglsBNYqyEMzfjaz/g7KzcJeB3g+/UyP1zw8vu dEA/0EGYlZYr/hQiio/X+3eicg== X-Google-Smtp-Source: ABdhPJxZeJSkLRs8VG8HKjc2mdZgqHaohyzxnJyfLB7F0oM5BrU5M/Z+au/7hM9ZyBydD9DDtZFYpQ== X-Received: by 2002:adf:ef92:: with SMTP id d18mr4041674wro.219.1624536476383; Thu, 24 Jun 2021 05:07:56 -0700 (PDT) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id t9sm2859034wmq.14.2021.06.24.05.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 05:07:55 -0700 (PDT) Date: Thu, 24 Jun 2021 14:07:54 +0200 From: Olivier Matz To: ohilyard@iol.unh.edu Cc: dev@dpdk.org, stable@dpdk.org, david.marchand@redhat.com Message-ID: References: <20210616180724.355217-1-ohilyard@iol.unh.edu> <20210623180645.91942-1-ohilyard@iol.unh.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210623180645.91942-1-ohilyard@iol.unh.edu> Subject: Re: [dpdk-dev] [PATCH v3] 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" Hi Owen, One small issue remain, please see below. On Wed, Jun 23, 2021 at 02:06:45PM -0400, ohilyard@iol.unh.edu wrote: > 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 | 40 ++++++++++++++++++++++++++----------- > 1 file changed, 28 insertions(+), 12 deletions(-) > > diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c > index bd72df0da..b476b2594 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,44 @@ 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; > } The cmdline_free(cl) after a if (cl == NULL) is not needed. After that change, you can add my ack in v4. Thanks, Olivier > > /* void functions */ > cmdline_stdin_exit(NULL); > > + cmdline_free(cl); > return 0; > error: > printf("Error: function accepted null parameter!\n"); > + cmdline_free(cl); > return -1; > } > > @@ -176,13 +190,14 @@ test_cmdline_fns(void) > struct cmdline *cl; > > memset(&ctx, 0, sizeof(ctx)); > - cl = cmdline_new(&ctx, "test", -1, -1); > - if (cl == NULL) > + cl = cmdline_new(NULL, "prompt", 0, 0); > + if (cl != NULL) > goto error; > - > - if (cmdline_new(NULL, "prompt", 0, 0) != NULL) > + cl = cmdline_new(&ctx, NULL, 0, 0); > + if (cl != NULL) > goto error; > - if (cmdline_new(&ctx, NULL, 0, 0) != NULL) > + cl = cmdline_new(&ctx, "test", -1, -1); > + if (cl == NULL) > goto error; > if (cmdline_in(NULL, "buffer", CMDLINE_TEST_BUFSIZE) >= 0) > goto error; > @@ -198,6 +213,7 @@ test_cmdline_fns(void) > cmdline_interact(NULL); > cmdline_quit(NULL); > > + cmdline_free(cl); > return 0; > > error: > -- > 2.30.2 >