Skip to contentSkip to conversation

fs/file.c: remove useless xchg and NULL check in close_files

PATCH New Mateusz Guzik 1 participant 1 message Apr 15, 2015 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/file.c: remove useless xchg and NULL check in close_files

Since the table is about to be freed, there is no reason to set file pointer to NULL on closing.

At this point open_fd map is supposed to indicate whether a file is installed, so NULL-checking it is unnecessary.

---
 fs/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/file.c +2 -5
index 93c5f89..35a024a 100644
@@ -364,11 +364,8 @@ static struct fdtable *close_files(struct files_struct * files)
 		set = fdt->open_fds[j++];
 		while (set) {
 			if (set & 1) {
-				struct file * file = xchg(&fdt->fd[i], NULL);
-				if (file) {
-					filp_close(file, files);
-					cond_resched_rcu_qs();
-				}
+				filp_close(fdt->fd[i], files);
+				cond_resched_rcu_qs();
 			}
 			i++;
 			set >>= 1;
Signature · 1 line
1.8.3.1