All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Cc: igt-dev@lists.freedesktop.org, Petri Latvala <petri.latvala@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t 2/4] Introduce device selection API
Date: Mon, 28 Oct 2019 15:06:00 +0200	[thread overview]
Message-ID: <20191028130600.6nfquyxrysbjrhgx@ahiler-desk1.fi.intel.com> (raw)
In-Reply-To: <20191024164030.GA7823@zkempczy-mobl2>

On Thu, Oct 24, 2019 at 06:40:31PM +0200, Zbigniew Kempczyński wrote:
> On Thu, Oct 24, 2019 at 02:05:13PM +0300, Arkadiusz Hiler wrote:
> 
> <cut>
> 
> I've taken a quick look and I think this require change:
> 
> > +/**
> > + * igt_device_filter_set
> > + * @filter: filter that should be set globally
> > + *
> > + * Returns number of filters added to filter array. Can be greater than
> > + * 1 if @filters contains more than one filter separated by semicolon.
> > + */
> > +void igt_device_filter_set(const char *filter)
> > +{
> > +	if (!is_filter_valid(filter)) {
> > +		igt_warn("Invalid filter: %s\n", filter);
> > +		return;
> > +	}
> > +
> > +	device_filter = strdup(filter);
> > +}
> 
> Comment informs function returns number of filters but it returns void
> now. What we should also protect is to memleak if user passes different
> filters because we don't free previous device_filter string if already
> set.
> 
> Same in the header file.
> 
> > +
> > +/**
> > + * igt_device_filter_free
> > + *
> > + * Free the filter that we store internally, effectively insetting it.
> > + */
> > +void igt_device_filter_free(void)
> > +{
> > +	if (device_filter != NULL)
> > +		free(device_filter);
> > +}
> 
> I would also add nullyfiing device_filter here.
> 
> That's for brief look.
> 
> Thanks for reviewing and rewriting patches.

The following changes will be included in the next revision. Thanks!

diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index 71d30587..c3c99001 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -1050,9 +1050,6 @@ static bool is_filter_valid(const char *fstr)
 /**
  * igt_device_filter_set
  * @filter: filter that should be set globally
- *
- * Returns number of filters added to filter array. Can be greater than
- * 1 if @filters contains more than one filter separated by semicolon.
  */
 void igt_device_filter_set(const char *filter)
 {
@@ -1061,18 +1058,23 @@ void igt_device_filter_set(const char *filter)
 		return;
 	}
 
+	if (device_filter != NULL)
+		free(device_filter);
+
 	device_filter = strdup(filter);
 }
 
 /**
  * igt_device_filter_free
  *
- * Free the filter that we store internally, effectively insetting it.
+ * Free the filter that we store internally, effectively unsetting it.
  */
 void igt_device_filter_free(void)
 {
 	if (device_filter != NULL)
 		free(device_filter);
+
+	device_filter = NULL;
 }
 
 /**
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-10-28 13:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 11:05 [igt-dev] [PATCH i-g-t 0/4] device selection && lsgpu Arkadiusz Hiler
2019-10-24 11:05 ` [igt-dev] [PATCH i-g-t 1/4] lib/igt_list: Update, clean-up and document igt_list Arkadiusz Hiler
2019-10-24 11:16   ` Chris Wilson
2019-10-24 11:20     ` Arkadiusz Hiler
2019-10-24 11:23       ` Chris Wilson
2019-10-24 11:05 ` [igt-dev] [PATCH i-g-t 2/4] Introduce device selection API Arkadiusz Hiler
     [not found]   ` <20191024164030.GA7823@zkempczy-mobl2>
2019-10-28 13:06     ` Arkadiusz Hiler [this message]
2019-11-15 13:31   ` Petri Latvala
2019-11-18 11:55   ` Petri Latvala
2019-10-24 11:05 ` [igt-dev] [PATCH i-g-t 3/4] Introduce device selection lsgpu tool Arkadiusz Hiler
2019-10-24 13:06   ` Chris Wilson
2019-10-28 11:21     ` Arkadiusz Hiler
2019-11-18 11:58   ` Petri Latvala
2019-10-24 11:05 ` [igt-dev] [PATCH i-g-t 4/4] Add device selection in IGT Arkadiusz Hiler
2019-11-18 12:14   ` Petri Latvala
2019-11-19 14:18     ` Arkadiusz Hiler
2019-11-20  9:31   ` Petri Latvala
2019-10-24 13:00 ` [igt-dev] ✓ Fi.CI.BAT: success for device selection && lsgpu Patchwork
2019-10-25 17:07 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-11-12 10:14 ` [igt-dev] [PATCH i-g-t 0/4] " Tvrtko Ursulin
2019-12-02 12:37   ` Arkadiusz Hiler
2019-12-03 13:59     ` Tvrtko Ursulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191028130600.6nfquyxrysbjrhgx@ahiler-desk1.fi.intel.com \
    --to=arkadiusz.hiler@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    --cc=zbigniew.kempczynski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.