mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] fs: make dpath always panic on OOM
@ 2025-10-15  8:16 Ahmad Fatoum
  2025-10-15  8:16 ` [PATCH 2/2] fs: add filepath helper Ahmad Fatoum
  2025-10-20 11:14 ` [PATCH 1/2] fs: make dpath always panic on OOM Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-10-15  8:16 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

This is effectively already the case since basprintf was changed to be
equivalent to xasprintf. Replace basprintf with xasprintf to make this
clearer and use xstrdup instead of strdup for the root node.

All users, except one, didn't bother to check dpath return value for NULL
anyway.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 fs/fs.c     | 6 +++---
 fs/legacy.c | 2 --
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 529c328f26fc..528299e039d2 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -3022,9 +3022,9 @@ static char *__dpath(struct dentry *dentry, struct dentry *root)
 
 	ppath = __dpath(dentry->d_parent, root);
 	if (ppath)
-		res = basprintf("%s/%s", ppath, dentry->d_name.name);
+		res = xasprintf("%s/%s", ppath, dentry->d_name.name);
 	else
-		res = basprintf("/%s", dentry->d_name.name);
+		res = xasprintf("/%s", dentry->d_name.name);
 	free(ppath);
 
 	return res;
@@ -3058,7 +3058,7 @@ char *dpath(struct dentry *dentry, struct dentry *root)
 	char *res;
 
 	if (dentry == root)
-		return strdup("/");
+		return xstrdup("/");
 
 	res = __dpath(dentry, root);
 
diff --git a/fs/legacy.c b/fs/legacy.c
index 7c73ad7c41e4..c2170f52a40b 100644
--- a/fs/legacy.c
+++ b/fs/legacy.c
@@ -60,8 +60,6 @@ static struct dentry *legacy_lookup(struct inode *dir, struct dentry *dentry,
 	int ret;
 
 	pathname = dpath(dentry, fsdev->vfsmount.mnt_root);
-	if (!pathname)
-		return NULL;
 
 	ret = legacy_ops->stat(&fsdev->dev, pathname, &s);
 	if (!ret) {
-- 
2.47.3




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-20 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-15  8:16 [PATCH 1/2] fs: make dpath always panic on OOM Ahmad Fatoum
2025-10-15  8:16 ` [PATCH 2/2] fs: add filepath helper Ahmad Fatoum
2025-10-20 11:14 ` [PATCH 1/2] fs: make dpath always panic on OOM Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox