mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Raag Jadav <raag.jadav@intel.com>
Cc: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] devres: simplify devm_kstrdup() using devm_kmemdup()
Date: Mon, 7 Apr 2025 16:40:30 +0300	[thread overview]
Message-ID: <Z_PVztG9gGd7g03N@smile.fi.intel.com> (raw)
In-Reply-To: <20250407121311.1702521-1-raag.jadav@intel.com>

On Mon, Apr 07, 2025 at 05:43:11PM +0530, Raag Jadav wrote:
> devm_kstrdup() logic pretty much reflects devm_kmemdup() for strings,
> so just reuse it.

...

>  char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp)
>  {
> -	size_t size;
> -	char *buf;

> -	if (!s)
> -		return NULL;

There is no point to touch these lines.
And this is the style used in the file elsewhere.

> -	size = strlen(s) + 1;
> -	buf = devm_kmalloc(dev, size, gfp);
> -	if (buf)
> -		memcpy(buf, s, size);
> -	return buf;
> +	return s ? devm_kmemdup(dev, s, strlen(s) + 1, gfp) : NULL;
>  }

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2025-04-07 13:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 12:13 Raag Jadav
2025-04-07 13:40 ` Andy Shevchenko [this message]

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=Z_PVztG9gGd7g03N@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raag.jadav@intel.com \
    --cc=rafael@kernel.org \
    /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

all inboxes | Powered by JetHome®