* [PATCH] 9p: simplify v9fs_cache_session_get_cookie()
@ 2026-08-14 4:08 Dmitry Antipov
2026-09-13 13:38 ` Dominique Martinet
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Antipov @ 2026-08-14 4:08 UTC (permalink / raw)
To: Dominique Martinet
Cc: Eric Van Hensbergen, Latchesar Ionkov, Christian Schoenebeck,
v9fs, Dmitry Antipov
Use the convenient 'strreplace()' to simplify
'v9fs_cache_session_get_cookie()'.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
fs/9p/cache.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/fs/9p/cache.c b/fs/9p/cache.c
index 12c0ae29f185..cb0e5b61e131 100644
--- a/fs/9p/cache.c
+++ b/fs/9p/cache.c
@@ -20,18 +20,15 @@ int v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses,
const char *dev_name)
{
struct fscache_volume *vcookie;
- char *name, *p;
+ char *name;
name = kasprintf(GFP_KERNEL, "9p,%s,%s",
dev_name, v9ses->cachetag ?: v9ses->aname);
if (!name)
return -ENOMEM;
- for (p = name; *p; p++)
- if (*p == '/')
- *p = ';';
-
- vcookie = fscache_acquire_volume(name, NULL, NULL, 0);
+ vcookie = fscache_acquire_volume(strreplace(name, '/', ';'),
+ NULL, NULL, 0);
p9_debug(P9_DEBUG_FSC, "session %p get volume %p (%s)\n",
v9ses, vcookie, name);
if (IS_ERR(vcookie)) {
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] 9p: simplify v9fs_cache_session_get_cookie()
2026-08-14 4:08 [PATCH] 9p: simplify v9fs_cache_session_get_cookie() Dmitry Antipov
@ 2026-09-13 13:38 ` Dominique Martinet
0 siblings, 0 replies; 2+ messages in thread
From: Dominique Martinet @ 2026-09-13 13:38 UTC (permalink / raw)
To: Dmitry Antipov
Cc: Eric Van Hensbergen, Latchesar Ionkov, Christian Schoenebeck,
v9fs
Dmitry Antipov wrote on Fri, Aug 14, 2026 at 07:08:26AM +0300:
> Use the convenient 'strreplace()' to simplify
> 'v9fs_cache_session_get_cookie()'.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> fs/9p/cache.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/fs/9p/cache.c b/fs/9p/cache.c
> index 12c0ae29f185..cb0e5b61e131 100644
> --- a/fs/9p/cache.c
> +++ b/fs/9p/cache.c
> @@ -20,18 +20,15 @@ int v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses,
> const char *dev_name)
> {
> struct fscache_volume *vcookie;
> - char *name, *p;
> + char *name;
>
> name = kasprintf(GFP_KERNEL, "9p,%s,%s",
> dev_name, v9ses->cachetag ?: v9ses->aname);
> if (!name)
> return -ENOMEM;
>
> - for (p = name; *p; p++)
> - if (*p == '/')
> - *p = ';';
> -
> - vcookie = fscache_acquire_volume(name, NULL, NULL, 0);
> + vcookie = fscache_acquire_volume(strreplace(name, '/', ';'),
> + NULL, NULL, 0);
Thanks
I find it more readable to split the two e.g. keep the replace separate
from the fscache call:
+ strreplace(name, '/', ';');
+ vcookie = fscache_acquire_volume(name, NULL, NULL, 0);
(this is fine because strreplace does a replace in place as well as
returning the string)
If you're ok with this I'll change in place, this doesn't need a v2
> p9_debug(P9_DEBUG_FSC, "session %p get volume %p (%s)\n",
> v9ses, vcookie, name);
> if (IS_ERR(vcookie)) {
--
Dominique Martinet | Asmadeus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-13 13:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 4:08 [PATCH] 9p: simplify v9fs_cache_session_get_cookie() Dmitry Antipov
2026-09-13 13:38 ` Dominique Martinet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox