Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: <igt-dev@lists.freedesktop.org>,
	Peter Senna Tschudin <peter.senna@linux.intel.com>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	Ryszard Knop <ryszard.knop@intel.com>
Subject: Re: [PATCH i-g-t v2 3/7] runner/settings: Drop extra strdup
Date: Thu, 23 Jan 2025 08:15:26 -0300	[thread overview]
Message-ID: <173763092635.4470.1458104714049106290@intel.com> (raw)
In-Reply-To: <b3i67cnrhinttegakwojidl55gvtlkn3nt5nwiqqpy3b57bwmi@fcvr5opjxjpx>

Quoting Lucas De Marchi (2025-01-23 03:23:46-03:00)
>On Wed, Jan 22, 2025 at 08:34:21AM -0300, Gustavo Sousa wrote:
>>Quoting Lucas De Marchi (2025-01-21 19:57:29-03:00)
>>>No need to strdup() again since the fscanf() function is already
>>>allocating the variable. Just set the pointer to NULL so we "leak" our
>>>variable to be saved in the settings.
>>>
>>>Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>>>---
>>> runner/settings.c | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>>diff --git a/runner/settings.c b/runner/settings.c
>>>index 13694a51c..96377f1de 100644
>>>--- a/runner/settings.c
>>>+++ b/runner/settings.c
>>>@@ -1164,7 +1164,11 @@ static unsigned long parse_ul(char **pval)
>>>
>>> static char *parse_str(char **pval)
>>> {
>>>-        return *pval ? strdup(*pval) : NULL;
>>>+        char *ret = *pval;
>>>+
>>>+        *pval = NULL;
>>
>>Okay. This explains the need for char **pval in the previous patch.
>>Maybe a heads up in #2's commit message would clarify things :-)
>
>yeah, sorry. What about naming it "leak_str()"?

I think parse_str() is okay.

I just really missed a heads up in the previous commit message that
using a char ** was being done for an upcoming change.

Or even, you could change it to char ** in this patch.

--
Gustavo Sousa

>
>Lucas De Marchi
>
>>
>>Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
>>
>>>+
>>>+        return ret;
>>> }
>>>
>>> #define PARSE_LINE(s, name, val, field, _f)        \
>>>--
>>>2.48.0
>>>

  reply	other threads:[~2025-01-23 11:15 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21 22:57 [PATCH i-g-t v2 0/7] Add igt_runner's cmdline to results Lucas De Marchi
2025-01-21 22:57 ` [PATCH i-g-t v2 1/7] runner/settings: Deduplicate cleanup Lucas De Marchi
2025-01-22 10:50   ` Gustavo Sousa
2025-01-22 12:22     ` Peter Senna Tschudin
2025-01-21 22:57 ` [PATCH i-g-t v2 2/7] runner/settings: Use wrapper functions for each type Lucas De Marchi
2025-01-22 11:20   ` Gustavo Sousa
2025-01-23  6:07     ` Lucas De Marchi
2025-01-23 11:20       ` Gustavo Sousa
2025-01-22 12:21   ` Peter Senna Tschudin
2025-01-23  6:22     ` Lucas De Marchi
2025-01-21 22:57 ` [PATCH i-g-t v2 3/7] runner/settings: Drop extra strdup Lucas De Marchi
2025-01-22 11:34   ` Gustavo Sousa
2025-01-22 12:22     ` Peter Senna Tschudin
2025-01-23  6:23     ` Lucas De Marchi
2025-01-23 11:15       ` Gustavo Sousa [this message]
2025-01-21 22:57 ` [PATCH i-g-t v2 4/7] runner/settings: Fix code_coverage_script leak Lucas De Marchi
2025-01-22 11:37   ` Gustavo Sousa
2025-01-22 12:23     ` Peter Senna Tschudin
2025-01-21 22:57 ` [PATCH i-g-t v2 5/7] runner: Free settings at the end Lucas De Marchi
2025-01-22 11:46   ` Gustavo Sousa
2025-01-22 12:23     ` Peter Senna Tschudin
2025-01-23  6:28     ` Lucas De Marchi
2025-01-24 17:25       ` Lucas De Marchi
2025-01-21 22:57 ` [PATCH i-g-t v2 6/7] runner/settings: Serialize command line Lucas De Marchi
2025-01-22 12:25   ` Peter Senna Tschudin
2025-01-22 12:40   ` Gustavo Sousa
2025-01-22 18:16     ` Peter Senna Tschudin
2025-01-22 18:26       ` Gustavo Sousa
2025-01-22 18:35         ` Peter Senna Tschudin
2025-01-22 18:55           ` Gustavo Sousa
2025-01-23  6:43             ` Lucas De Marchi
2025-01-22 18:53         ` Peter Senna Tschudin
2025-01-28 18:37   ` Kamil Konieczny
2025-01-28 19:34     ` Lucas De Marchi
2025-01-29 17:23       ` Kamil Konieczny
2025-01-29 18:09         ` Petri Latvala
2025-01-29 20:29           ` Lucas De Marchi
2025-01-29 20:15         ` Lucas De Marchi
2025-01-21 22:57 ` [PATCH i-g-t v2 7/7] runner/resultgen: Add cmdline to results.json Lucas De Marchi
2025-01-22 12:25   ` Peter Senna Tschudin
2025-01-22 12:51   ` Gustavo Sousa
2025-01-23  6:50     ` Lucas De Marchi
2025-01-24 14:20       ` Knop, Ryszard
2025-01-29 18:14         ` Petri Latvala
2025-01-22  1:45 ` ✓ Xe.CI.BAT: success for Add igt_runner's cmdline to results (rev2) Patchwork
2025-01-22  1:49 ` ✓ i915.CI.BAT: " Patchwork
2025-01-22 10:11 ` ✗ Xe.CI.Full: failure " Patchwork
2025-01-23 10:42 ` ✗ i915.CI.Full: " Patchwork

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=173763092635.4470.1458104714049106290@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=lucas.demarchi@intel.com \
    --cc=peter.senna@linux.intel.com \
    --cc=ryszard.knop@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox