All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] [Patch 3/4] BUG_ON() Conversion in ipc/shm.c
@ 2006-01-27 12:49 Eric Sesterhenn / snakebyte
  2006-01-27 12:49 ` [KJ] [Patch 3/4] BUG_ON() Conversion in ipc/util.c Eric Sesterhenn / snakebyte
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sesterhenn / snakebyte @ 2006-01-27 12:49 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1444 bytes --]

hi, 

this changes if() BUG(); constructs to BUG_ON() which is
cleaner, contains unlikely() and can better optimized away.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc1-git4/ipc/shm.c.orig	2006-01-27 11:11:02.000000000 +0100
+++ linux-2.6.16-rc1-git4/ipc/shm.c	2006-01-27 11:13:11.000000000 +0100
@@ -90,8 +90,8 @@ static inline int shm_addid(struct shmid
 static inline void shm_inc (int id) {
 	struct shmid_kernel *shp;
 
-	if(!(shp = shm_lock(id)))
-		BUG();
+	shp = shm_lock(id);
+	BUG_ON(!shp);
 	shp->shm_atim = get_seconds();
 	shp->shm_lprid = current->tgid;
 	shp->shm_nattch++;
@@ -141,8 +141,8 @@ static void shm_close (struct vm_area_st
 
 	down (&shm_ids.sem);
 	/* remove from the list of attaches of the shm segment */
-	if(!(shp = shm_lock(id)))
-		BUG();
+	shp = shm_lock(id);
+	BUG_ON(!shp);
 	shp->shm_lprid = current->tgid;
 	shp->shm_dtim = get_seconds();
 	shp->shm_nattch--;
@@ -282,8 +282,7 @@ asmlinkage long sys_shmget (key_t key, s
 		err = -EEXIST;
 	} else {
 		shp = shm_lock(id);
-		if(shp==NULL)
-			BUG();
+		BUG_ON(shp==NULL);
 		if (shp->shm_segsz < size)
 			err = -EINVAL;
 		else if (ipcperms(&shp->shm_perm, shmflg))
@@ -772,8 +771,8 @@ invalid:
 	up_write(&current->mm->mmap_sem);
 
 	down (&shm_ids.sem);
-	if(!(shp = shm_lock(shmid)))
-		BUG();
+	shp = shm_lock(shmid);
+	BUG_ON(!shp);
 	shp->shm_nattch--;
 	if(shp->shm_nattch == 0 &&
 	   shp->shm_perm.mode & SHM_DEST)



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] [Patch 3/4] BUG_ON() Conversion in ipc/util.c
  2006-01-27 12:49 [KJ] [Patch 3/4] BUG_ON() Conversion in ipc/shm.c Eric Sesterhenn / snakebyte
@ 2006-01-27 12:49 ` Eric Sesterhenn / snakebyte
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Sesterhenn / snakebyte @ 2006-01-27 12:49 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 818 bytes --]

hi, 

this changes if() BUG(); constructs to BUG_ON() which is
cleaner, contains unlikely() and can better optimized away.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc1-git4/ipc/util.c.orig	2006-01-27 11:13:20.000000000 +0100
+++ linux-2.6.16-rc1-git4/ipc/util.c	2006-01-27 11:13:39.000000000 +0100
@@ -265,8 +265,7 @@ struct kern_ipc_perm* ipc_rmid(struct ip
 {
 	struct kern_ipc_perm* p;
 	int lid = id % SEQ_MULTIPLIER;
-	if(lid >= ids->entries->size)
-		BUG();
+	BUG_ON(lid >= ids->entries->size);
 
 	/* 
 	 * do not need a rcu_dereference()() here to force ordering
@@ -274,8 +273,7 @@ struct kern_ipc_perm* ipc_rmid(struct ip
 	 */	
 	p = ids->entries->p[lid];
 	ids->entries->p[lid] = NULL;
-	if(p==NULL)
-		BUG();
+	BUG_ON(p==NULL);
 	ids->in_use--;
 
 	if (lid == ids->max_id) {



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

end of thread, other threads:[~2006-01-27 12:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-27 12:49 [KJ] [Patch 3/4] BUG_ON() Conversion in ipc/shm.c Eric Sesterhenn / snakebyte
2006-01-27 12:49 ` [KJ] [Patch 3/4] BUG_ON() Conversion in ipc/util.c Eric Sesterhenn / snakebyte

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.