Skip to content

Commit 791e562

Browse files
fs/ntfs3: Minor ntfs_list_ea refactoring
For easy internal debugging. Signed-off-by: Konstantin Komarov <[email protected]>
1 parent 7443753 commit 791e562

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

fs/ntfs3/xattr.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,8 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer,
195195
{
196196
const struct EA_INFO *info;
197197
struct EA_FULL *ea_all = NULL;
198-
const struct EA_FULL *ea;
199198
u32 off, size;
200199
int err;
201-
int ea_size;
202200
size_t ret;
203201

204202
err = ntfs_read_ea(ni, &ea_all, 0, &info);
@@ -212,16 +210,18 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer,
212210

213211
/* Enumerate all xattrs. */
214212
ret = 0;
215-
for (off = 0; off + sizeof(struct EA_FULL) < size; off += ea_size) {
216-
ea = Add2Ptr(ea_all, off);
217-
ea_size = unpacked_ea_size(ea);
213+
off = 0;
214+
while (off + sizeof(struct EA_FULL) < size) {
215+
const struct EA_FULL *ea = Add2Ptr(ea_all, off);
216+
int ea_size = unpacked_ea_size(ea);
217+
u8 name_len = ea->name_len;
218218

219-
if (!ea->name_len)
219+
if (!name_len)
220220
break;
221221

222-
if (ea->name_len > ea_size) {
222+
if (name_len > ea_size) {
223223
ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR);
224-
err = -EINVAL; /* corrupted fs */
224+
err = -EINVAL; /* corrupted fs. */
225225
break;
226226
}
227227

@@ -230,16 +230,17 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer,
230230
if (off + ea_size > size)
231231
break;
232232

233-
if (ret + ea->name_len + 1 > bytes_per_buffer) {
233+
if (ret + name_len + 1 > bytes_per_buffer) {
234234
err = -ERANGE;
235235
goto out;
236236
}
237237

238-
memcpy(buffer + ret, ea->name, ea->name_len);
239-
buffer[ret + ea->name_len] = 0;
238+
memcpy(buffer + ret, ea->name, name_len);
239+
buffer[ret + name_len] = 0;
240240
}
241241

242-
ret += ea->name_len + 1;
242+
ret += name_len + 1;
243+
off += ea_size;
243244
}
244245

245246
out:

0 commit comments

Comments
 (0)