All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] fs: hpfs: remove commented out code in hpfs_set_ea
@ 2026-05-19 16:45 Thorsten Blum
  2026-05-19 16:45 ` [PATCH 2/3] fs: hpfs: calculate key length only once " Thorsten Blum
  2026-05-19 16:45 ` [PATCH 3/3] fs: hpfs: replace deprecated strcpy with memcpy " Thorsten Blum
  0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-05-19 16:45 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: Thorsten Blum, linux-kernel

The code has been commented out ever since commit 1da177e4c3f4
("Linux-2.6.12-rc2") - remove it.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 fs/hpfs/ea.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c
index 4664f9ab06ee..3f0213486c21 100644
--- a/fs/hpfs/ea.c
+++ b/fs/hpfs/ea.c
@@ -236,14 +236,8 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
 		}
 		pos += ea->namelen + ea_valuelen(ea) + 5;
 	}
-	if (!le16_to_cpu(fnode->ea_offs)) {
-		/*if (le16_to_cpu(fnode->ea_size_s)) {
-			hpfs_error(s, "fnode %08x: ea_size_s == %03x, ea_offs == 0",
-				inode->i_ino, le16_to_cpu(fnode->ea_size_s));
-			return;
-		}*/
+	if (!le16_to_cpu(fnode->ea_offs))
 		fnode->ea_offs = cpu_to_le16(0xc4);
-	}
 	if (le16_to_cpu(fnode->ea_offs) < 0xc4 || le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) > 0x200) {
 		hpfs_error(s, "fnode %08llx: ea_offs == %03x, ea_size_s == %03x",
 			inode->i_ino,
@@ -295,24 +289,6 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
 			if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) {
 				len++;
 			} else {
-				/* Aargh... don't know how to create ea anodes :-( */
-				/*struct buffer_head *bh;
-				struct anode *anode;
-				anode_secno a_s;
-				if (!(anode = hpfs_alloc_anode(s, fno, &a_s, &bh)))
-					goto bail;
-				anode->up = cpu_to_le32(fno);
-				anode->btree.fnode_parent = 1;
-				anode->btree.n_free_nodes--;
-				anode->btree.n_used_nodes++;
-				anode->btree.first_free = cpu_to_le16(le16_to_cpu(anode->btree.first_free) + 12);
-				anode->u.external[0].disk_secno = cpu_to_le32(le32_to_cpu(fnode->ea_secno));
-				anode->u.external[0].file_secno = cpu_to_le32(0);
-				anode->u.external[0].length = cpu_to_le32(len);
-				mark_buffer_dirty(bh);
-				brelse(bh);
-				fnode->flags |= FNODE_anode;
-				fnode->ea_secno = cpu_to_le32(a_s);*/
 				secno new_sec;
 				int i;
 				if (!(new_sec = hpfs_alloc_sector(s, fno, 1, 1 - ((pos + 511) >> 9))))

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

* [PATCH 2/3] fs: hpfs: calculate key length only once in hpfs_set_ea
  2026-05-19 16:45 [PATCH 1/3] fs: hpfs: remove commented out code in hpfs_set_ea Thorsten Blum
@ 2026-05-19 16:45 ` Thorsten Blum
  2026-05-19 16:45 ` [PATCH 3/3] fs: hpfs: replace deprecated strcpy with memcpy " Thorsten Blum
  1 sibling, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-05-19 16:45 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: Thorsten Blum, linux-kernel

Calculate the length of the read-only key only once and reuse it.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 fs/hpfs/ea.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c
index 3f0213486c21..1d7c1f67be9f 100644
--- a/fs/hpfs/ea.c
+++ b/fs/hpfs/ea.c
@@ -198,6 +198,8 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
 	unsigned char h[4];
 	struct extended_attribute *ea;
 	struct extended_attribute *ea_end = fnode_end_ea(fnode);
+	const size_t key_len = strlen(key);
+
 	for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea))
 		if (!strcmp(ea->name, key)) {
 			if (ea_indirect(ea)) {
@@ -245,15 +247,16 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
 		return;
 	}
 	if ((le16_to_cpu(fnode->ea_size_s) || !le32_to_cpu(fnode->ea_size_l)) &&
-	     le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) + strlen(key) + size + 5 <= 0x200) {
+	     le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) +
+	     le16_to_cpu(fnode->ea_size_s) + key_len + size + 5 <= 0x200) {
 		ea = fnode_end_ea(fnode);
 		*(char *)ea = 0;
-		ea->namelen = strlen(key);
+		ea->namelen = key_len;
 		ea->valuelen_lo = size;
 		ea->valuelen_hi = size >> 8;
 		strcpy(ea->name, key);
 		memcpy(ea_data(ea), data, size);
-		fnode->ea_size_s = cpu_to_le16(le16_to_cpu(fnode->ea_size_s) + strlen(key) + size + 5);
+		fnode->ea_size_s = cpu_to_le16(le16_to_cpu(fnode->ea_size_s) + key_len + size + 5);
 		goto ret;
 	}
 	/* Most the code here is 99.9993422% unused. I hope there are no bugs.
@@ -275,7 +278,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
 		mark_buffer_dirty(bh);
 		brelse(bh);
 	}
-	pos = le32_to_cpu(fnode->ea_size_l) + 5 + strlen(key) + size;
+	pos = le32_to_cpu(fnode->ea_size_l) + 5 + key_len + size;
 	len = (le32_to_cpu(fnode->ea_size_l) + 511) >> 9;
 	if (pos >= 30000) goto bail;
 	while (((pos + 511) >> 9) > len) {
@@ -325,7 +328,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
 		}
 	}
 	h[0] = 0;
-	h[1] = strlen(key);
+	h[1] = key_len;
 	h[2] = size & 0xff;
 	h[3] = size >> 8;
 	if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail;
@@ -333,7 +336,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
 	if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail;
 	fnode->ea_size_l = cpu_to_le32(pos);
 	ret:
-	hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size;
+	hpfs_i(inode)->i_ea_size += 5 + key_len + size;
 	return;
 	bail:
 	if (le32_to_cpu(fnode->ea_secno))

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

* [PATCH 3/3] fs: hpfs: replace deprecated strcpy with memcpy in hpfs_set_ea
  2026-05-19 16:45 [PATCH 1/3] fs: hpfs: remove commented out code in hpfs_set_ea Thorsten Blum
  2026-05-19 16:45 ` [PATCH 2/3] fs: hpfs: calculate key length only once " Thorsten Blum
@ 2026-05-19 16:45 ` Thorsten Blum
  1 sibling, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-05-19 16:45 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: Thorsten Blum, linux-kernel

strcpy() is deprecated [1] and uses an additional strlen() internally;
use memcpy() directly since we already know the length of the key and
that it is guaranteed to be NUL-terminated.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 fs/hpfs/ea.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c
index 1d7c1f67be9f..66776cb4f3fc 100644
--- a/fs/hpfs/ea.c
+++ b/fs/hpfs/ea.c
@@ -254,7 +254,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
 		ea->namelen = key_len;
 		ea->valuelen_lo = size;
 		ea->valuelen_hi = size >> 8;
-		strcpy(ea->name, key);
+		memcpy(ea->name, key, key_len + 1);
 		memcpy(ea_data(ea), data, size);
 		fnode->ea_size_s = cpu_to_le16(le16_to_cpu(fnode->ea_size_s) + key_len + size + 5);
 		goto ret;

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

end of thread, other threads:[~2026-05-19 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19 16:45 [PATCH 1/3] fs: hpfs: remove commented out code in hpfs_set_ea Thorsten Blum
2026-05-19 16:45 ` [PATCH 2/3] fs: hpfs: calculate key length only once " Thorsten Blum
2026-05-19 16:45 ` [PATCH 3/3] fs: hpfs: replace deprecated strcpy with memcpy " Thorsten Blum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.