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 4D8C3A0547 for ; Thu, 24 Jun 2021 14:07:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 242394003C; Thu, 24 Jun 2021 14:07:57 +0200 (CEST) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mails.dpdk.org (Postfix) with ESMTP id C23084003C for ; Thu, 24 Jun 2021 14:07:56 +0200 (CEST) Received: by mail-wr1-f42.google.com with SMTP id j1so6374284wrn.9 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=O3B5fjyf5vyNvzov2HJbJy9IxPfoOLogKHlW543Replt20GRse5gaEetm7YzAf/cny FfvGycHLWvdakUG6FOm+JwSTdMR3rHJZdSXLbNBIKeKi+2OzWP+A+i7AZx/TIN8Gdxui eprtjJ8+RxMyk1OpWbDHS/DUvpVEdyBLSfy9e8BkwfNctXtodv0u3mCkj9pezLqDo2+u 4MZXrKsoyq7S6M46l/NEJrvLa7fwH1o3Ls60sSe3VotKGIqDaH6Q5EKWBB6hfXJRO2Hu EAbjMcGnLs1upy0SzQN3PjqQMVbU34+QcIMEok9Aty80Mm0sZoZy3ZLdc1fftVWSGQ1E Vdfg== X-Gm-Message-State: AOAM532JUdWeujmgC9bwOq0mz5pTWyStuf9V7QilocgztNVmeKHEDvoz TQDsgL4h8W5OCAef8vcHuCKT/w== 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-stable] [PATCH v3] tests/cmdline: fix memory leaks X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 >