public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xip cleanups
@ 2005-06-28 12:01 Christoph Hellwig
  2005-06-28 12:40 ` Jörn Engel
       [not found] ` <200506281421.09893.arnd@arndb.de>
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2005-06-28 12:01 UTC (permalink / raw)
  To: cotte, akpm; +Cc: linux-kernel

adjust to kernel style and remove some unneeded NULL checks


Index: linux-2.6/fs/ext2/xip.c
===================================================================
--- linux-2.6.orig/fs/ext2/xip.c	2005-06-26 13:26:24.000000000 +0200
+++ linux-2.6/fs/ext2/xip.c	2005-06-26 13:30:39.000000000 +0200
@@ -15,42 +15,39 @@
 #include "xip.h"
 
 static inline int
-__inode_direct_access(struct inode *inode, sector_t sector, unsigned long *data) {
+__inode_direct_access(struct inode *inode, sector_t sector, unsigned long *data)
+{
 	BUG_ON(!inode->i_sb->s_bdev->bd_disk->fops->direct_access);
 	return inode->i_sb->s_bdev->bd_disk->fops
 		->direct_access(inode->i_sb->s_bdev,sector,data);
 }
 
 int
-ext2_clear_xip_target(struct inode *inode, int block) {
-	sector_t sector = block*(PAGE_SIZE/512);
+ext2_clear_xip_target(struct inode *inode, int block)
+{
+	sector_t sector = block * (PAGE_SIZE/512);
 	unsigned long data;
 	int rc;
 
 	rc = __inode_direct_access(inode, sector, &data);
-	if (rc)
-		return rc;
-	clear_page((void*)data);
-	return 0;
+	if (!rc)
+		clear_page(data);
+	return rc;
 }
 
 void ext2_xip_verify_sb(struct super_block *sb)
 {
 	struct ext2_sb_info *sbi = EXT2_SB(sb);
 
-	if ((sbi->s_mount_opt & EXT2_MOUNT_XIP)) {
-		if ((sb->s_bdev == NULL) ||
-			sb->s_bdev->bd_disk == NULL ||
-			sb->s_bdev->bd_disk->fops == NULL ||
-			sb->s_bdev->bd_disk->fops->direct_access == NULL) {
-			sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
-			ext2_warning(sb, __FUNCTION__,
-				"ignoring xip option - not supported by bdev");
-		}
+	if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) &&
+	    !sb->s_bdev->bd_disk->fops->direct_access) {
+		sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
+		ext2_warning(sb, __FUNCTION__,
+			"ignoring xip option - not supported by bdev");
 	}
 }
 
-struct page*
+struct page *
 ext2_get_xip_page(struct address_space *mapping, sector_t blockno,
 		   int create)
 {
@@ -60,7 +57,7 @@
 
 	tmp.b_state = 0;
 	tmp.b_blocknr = 0;
-	rc = ext2_get_block(mapping->host, blockno/(PAGE_SIZE/512) , &tmp,
+	rc = ext2_get_block(mapping->host, blockno/(PAGE_SIZE/512), &tmp,
 				create);
 	if (rc)
 		return ERR_PTR(rc);
@@ -71,7 +68,7 @@
 	}
 
 	rc = __inode_direct_access
-		(mapping->host,tmp.b_blocknr*(PAGE_SIZE/512) ,&data);
+		(mapping->host,tmp.b_blocknr * (PAGE_SIZE/512), &data);
 	if (rc)
 		return ERR_PTR(rc);
 

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

* Re: [PATCH] xip cleanups
  2005-06-28 12:01 [PATCH] xip cleanups Christoph Hellwig
@ 2005-06-28 12:40 ` Jörn Engel
  2005-06-30 13:46   ` Christoph Hellwig
       [not found] ` <200506281421.09893.arnd@arndb.de>
  1 sibling, 1 reply; 4+ messages in thread
From: Jörn Engel @ 2005-06-28 12:40 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: cotte, akpm, linux-kernel

On Tue, 28 June 2005 14:01:59 +0200, Christoph Hellwig wrote:
> 
> adjust to kernel style and remove some unneeded NULL checks

Cool!

>  	rc = __inode_direct_access(inode, sector, &data);
> -	if (rc)
> -		return rc;
> -	clear_page((void*)data);
> -	return 0;
> +	if (!rc)
> +		clear_page(data);
> +	return rc;

I personally prefer the original code.  As a general rule, error
handling code is indented further than regular good-case code.  That
makes reading a *lot* faster and the compiler should be smart enough
to generate identical code.

What are your arguments for the change?

> -		(mapping->host,tmp.b_blocknr*(PAGE_SIZE/512) ,&data);
> +		(mapping->host,tmp.b_blocknr * (PAGE_SIZE/512), &data);
                               ^
You missed one.

Jörn

-- 
Fancy algorithms are slow when n is small, and n is usually small.
Fancy algorithms have big constants. Until you know that n is
frequently going to be big, don't get fancy.
-- Rob Pike

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

* Re: [PATCH] xip cleanups
       [not found] ` <200506281421.09893.arnd@arndb.de>
@ 2005-06-30 13:44   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2005-06-30 13:44 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Christoph Hellwig, cotte, akpm, linux-kernel

On Tue, Jun 28, 2005 at 02:21:09PM +0200, Arnd Bergmann wrote:
> On Dinsdag 28 Juni 2005 14:01, Christoph Hellwig wrote:> ?int> -ext2_clear_xip_target(struct inode *inode, int block) {> -???????sector_t sector = block*(PAGE_SIZE/512);> +ext2_clear_xip_target(struct inode *inode, int block)> +{> +???????sector_t sector = block * (PAGE_SIZE/512);> ????????unsigned long data;> ????????int rc;> ?> ????????rc = __inode_direct_access(inode, sector, &data);> -???????if (rc)> -???????????????return rc;> -???????clear_page((void*)data);> -???????return 0;> +???????if (!rc)> +???????????????clear_page(data);> +???????return rc;> ?}
> Did you try building it? While most of your changes areobviously correct, passing an unsigned long value to clear_pagewithout a cast isn't.

On what hardware? ;-)  Ok, that one is indeed bogus.

Btw, you mailer totally messed up the quoted part.


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

* Re: [PATCH] xip cleanups
  2005-06-28 12:40 ` Jörn Engel
@ 2005-06-30 13:46   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2005-06-30 13:46 UTC (permalink / raw)
  To: J?rn Engel; +Cc: Christoph Hellwig, cotte, akpm, linux-kernel

On Tue, Jun 28, 2005 at 02:40:29PM +0200, J?rn Engel wrote:
> I personally prefer the original code.  As a general rule, error
> handling code is indented further than regular good-case code.  That
> makes reading a *lot* faster and the compiler should be smart enough
> to generate identical code.

ok..  the cast removal is also wrong as Arnd pointed out, btw.

> > -		(mapping->host,tmp.b_blocknr*(PAGE_SIZE/512) ,&data);
> > +		(mapping->host,tmp.b_blocknr * (PAGE_SIZE/512), &data);
>                                ^
> You missed one.

feel free to add it :)


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

end of thread, other threads:[~2005-06-30 13:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-28 12:01 [PATCH] xip cleanups Christoph Hellwig
2005-06-28 12:40 ` Jörn Engel
2005-06-30 13:46   ` Christoph Hellwig
     [not found] ` <200506281421.09893.arnd@arndb.de>
2005-06-30 13:44   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox