Skip to contentSkip to conversation

pids: Introduce for_each_tgid() macro

PATCH In review Anton Vorontsov 1 participant 1 message Jan 30, 2012 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 pids: Introduce for_each_tgid() macro

Just a handy macro. This patch converts procfs user to this new macro, plus android lowmemorykiller driver will use it as well.

---
 fs/proc/base.c      |    4 +---
 include/linux/pid.h |    5 +++++
 2 files changed, 6 insertions(+), 3 deletions(-)
fs/proc/base.c +1 -3
index 84b8625..e815d63 100644
@@ -3367,9 +3367,7 @@ int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
 	ns = filp->f_dentry->d_sb->s_fs_info;
 	iter.task = NULL;
 	iter.tgid = filp->f_pos - TGID_OFFSET;
-	for (iter = next_tgid(ns, iter);
-	     iter.task;
-	     iter.tgid += 1, iter = next_tgid(ns, iter)) {
+	for_each_tgid(ns, iter) {
 		if (has_pid_permissions(ns, iter.task, 2))
 			__filldir = filldir;
 		else
include/linux/pid.h +5 -0
index 33e350b..da87cae 100644
@@ -206,4 +206,9 @@ struct tgid_iter {
 
 struct tgid_iter next_tgid(struct pid_namespace *ns, struct tgid_iter iter);
 
+#define for_each_tgid(ns, iter)					\
+	for (iter = next_tgid(ns, iter);			\
+	     iter.task;						\
+	     iter.tgid += 1, iter = next_tgid(ns, iter))	\
+
 #endif /* _LINUX_PID_H */
Signature · 1 line
1.7.7