linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] get_binfmt/put_binfmt macros
@ 2000-12-19 23:09 Jani Monoses
  0 siblings, 0 replies; only message in thread
From: Jani Monoses @ 2000-12-19 23:09 UTC (permalink / raw)
  To: linux-kernel


Hi

	this patch replaces the binfmt module handling parts with macro
calls which do the same thing similar do the get/put_exec_domain macros.
Also changes an internal function name in fs/exec.c (put_binfmt) which
does almost the same thing as put_binfmt (one check less) to avoid
compilation conflicts.
Files affected: fork.c, exit.c, fs/exec.c ,include/linux/binfmts.h

It is against test12 but test13pre3 does not affect these files.

Comments are welcome.

Jani.	


diff -uNr -X dontdiff /usr/src/clean/linux/fs/exec.c linux/fs/exec.c
--- /usr/src/clean/linux/fs/exec.c	Tue Dec 12 11:25:55 2000
+++ linux/fs/exec.c	Wed Dec 20 00:13:55 2000
@@ -87,7 +87,7 @@
 	return -EINVAL;
 }
 
-static inline void put_binfmt(struct linux_binfmt * fmt)
+static inline void _put_binfmt(struct linux_binfmt * fmt)
 {
 	if (fmt->module)
 		__MOD_DEC_USE_COUNT(fmt->module);
@@ -135,7 +135,7 @@
 			read_unlock(&binfmt_lock);
 			error = fmt->load_shlib(file);
 			read_lock(&binfmt_lock);
-			put_binfmt(fmt);
+			_put_binfmt(fmt);
 			if (error != -ENOEXEC)
 				break;
 		}
@@ -810,7 +810,7 @@
 			read_unlock(&binfmt_lock);
 			retval = fn(bprm, regs);
 			if (retval >= 0) {
-				put_binfmt(fmt);
+				_put_binfmt(fmt);
 				allow_write_access(bprm->file);
 				if (bprm->file)
 					fput(bprm->file);
@@ -819,7 +819,7 @@
 				return retval;
 			}
 			read_lock(&binfmt_lock);
-			put_binfmt(fmt);
+			_put_binfmt(fmt);
 			if (retval != -ENOEXEC)
 				break;
 			if (!bprm->file) {
@@ -924,11 +924,11 @@
 void set_binfmt(struct linux_binfmt *new)
 {
 	struct linux_binfmt *old = current->binfmt;
-	if (new && new->module)
-		__MOD_INC_USE_COUNT(new->module);
+
+	get_binfmt(new);
 	current->binfmt = new;
-	if (old && old->module)
-		__MOD_DEC_USE_COUNT(old->module);
+	put_binfmt(old);
+
 }
 
 int do_coredump(long signr, struct pt_regs * regs)
diff -uNr -X dontdiff /usr/src/clean/linux/include/linux/binfmts.h linux/include/linux/binfmts.h
--- /usr/src/clean/linux/include/linux/binfmts.h	Tue Dec 12 11:42:22 2000
+++ linux/include/linux/binfmts.h	Wed Dec 20 00:10:59 2000
@@ -59,6 +59,12 @@
 extern int do_coredump(long signr, struct pt_regs * regs);
 extern void set_binfmt(struct linux_binfmt *new);
 
+#define get_binfmt(bf)	\
+	if (bf && bf->module) __MOD_INC_USE_COUNT(bf->module)
+
+#define put_binfmt(bf)	\
+	if (bf && bf->module) __MOD_DEC_USE_COUNT(bf->module)
+	
 
 #if 0
 /* this went away now */
diff -uNr -X dontdiff /usr/src/clean/linux/kernel/exit.c linux/kernel/exit.c
--- /usr/src/clean/linux/kernel/exit.c	Tue Dec 12 11:25:58 2000
+++ linux/kernel/exit.c	Wed Dec 20 00:11:40 2000
@@ -448,8 +448,7 @@
 	tsk->exit_code = code;
 	exit_notify();
 	put_exec_domain(tsk->exec_domain);
-	if (tsk->binfmt && tsk->binfmt->module)
-		__MOD_DEC_USE_COUNT(tsk->binfmt->module);
+	put_binfmt(tsk->binfmt);
 	schedule();
 /*
  * In order to get rid of the "volatile function does return" message
diff -uNr -X dontdiff /usr/src/clean/linux/kernel/fork.c linux/kernel/fork.c
--- /usr/src/clean/linux/kernel/fork.c	Tue Dec 12 11:25:58 2000
+++ linux/kernel/fork.c	Wed Dec 20 00:10:44 2000
@@ -578,8 +578,7 @@
 	
 	get_exec_domain(p->exec_domain);
 
-	if (p->binfmt && p->binfmt->module)
-		__MOD_INC_USE_COUNT(p->binfmt->module);
+	get_binfmt(p->binfmt);
 
 	p->did_exec = 0;
 	p->swappable = 0;
@@ -701,8 +700,8 @@
 	exit_files(p); /* blocking */
 bad_fork_cleanup:
 	put_exec_domain(p->exec_domain);
-	if (p->binfmt && p->binfmt->module)
-		__MOD_DEC_USE_COUNT(p->binfmt->module);
+	put_binfmt(p->binfmt);
+	
 bad_fork_cleanup_count:
 	atomic_dec(&p->user->processes);
 	free_uid(p->user);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-12-19 23:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-19 23:09 [patch] get_binfmt/put_binfmt macros Jani Monoses

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).