[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z_PVztG9gGd7g03N@smile.fi.intel.com>
Date: Mon, 7 Apr 2025 16:40:30 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Raag Jadav <raag.jadav@...el.com>
Cc: gregkh@...uxfoundation.org, rafael@...nel.org, dakr@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] devres: simplify devm_kstrdup() using devm_kmemdup()
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
Powered by blists - more mailing lists