Discussion:
[PATCH 8/9] isofs: remove redundant kfree checks from rock
(too old to reply)
Pekka Enberg
2005-03-28 18:01:24 UTC
Permalink
This patch removes redundant kfree() NULL checks from fs/isofs/rock.c.

Signed-off-by: Pekka Enberg <***@cs.helsinki.fi>
---

rock.c | 36 ++++++++++++------------------------
1 files changed, 12 insertions(+), 24 deletions(-)

Index: 2.6/fs/isofs/rock.c
===================================================================
--- 2.6.orig/fs/isofs/rock.c 2005-03-28 18:24:50.000000000 +0300
+++ 2.6/fs/isofs/rock.c 2005-03-28 18:24:53.000000000 +0300
@@ -130,18 +130,15 @@
retnamlen += rr->len - 5;
break;
case SIG('R', 'E'):
- if (buffer)
- kfree(buffer);
+ kfree(buffer);
return -1;
default:
break;
}
}
}
- if (buffer) {
- kfree(buffer);
- buffer = NULL;
- }
+ kfree(buffer);
+ buffer = NULL;
if (cont_extent) {
int block, offset, offset1;
struct buffer_head * pbh;
@@ -168,12 +165,10 @@
}
printk("Unable to read rock-ridge attributes\n");
}
- if (buffer)
- kfree(buffer);
+ kfree(buffer);
return retnamlen; /* If 0, this file did not have a NM field */
out:
- if (buffer)
- kfree(buffer);
+ kfree(buffer);
return 0;
}

@@ -426,10 +421,8 @@
}
}
}
- if (buffer) {
- kfree(buffer);
- buffer = NULL;
- }
+ kfree(buffer);
+ buffer = NULL;
if (cont_extent) {
int block, offset, offset1;
struct buffer_head * pbh;
@@ -457,8 +450,7 @@
printk("Unable to read rock-ridge attributes\n");
}
out:
- if (buffer)
- kfree(buffer);
+ kfree(buffer);
return 0;
}

@@ -625,10 +617,8 @@
break;
}
}
- if (buffer) {
- kfree(buffer);
- buffer = NULL;
- }
+ kfree(buffer);
+ buffer = NULL;
if (cont_extent) {
int block, offset, offset1;
struct buffer_head * pbh;
@@ -655,8 +645,7 @@
}
printk("Unable to read rock-ridge attributes\n");
}
- if (buffer)
- kfree(buffer);
+ kfree(buffer);

if (rpnt == link)
goto fail;
@@ -670,8 +659,7 @@

/* error exit from macro */
out:
- if (buffer)
- kfree(buffer);
+ kfree(buffer);
goto fail;
out_noread:
printk("unable to read i-node block");
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



-------------------------------------------------------------------------------
Achtung: diese Newsgruppe ist eine unidirektional gegatete Mailingliste.
Antworten nur per Mail an die im Reply-To-Header angegebene Adresse.
Fragen zum Gateway -> ***@inka.de.
-------------------------------------------------------------------------------
Pekka Enberg
2005-03-28 17:56:33 UTC
Permalink
This patch removes some redundant variables from fs/isofs/rock.c.

Signed-off-by: Pekka Enberg <***@cs.helsinki.fi>
---

rock.c | 41 +++++++++++++----------------------------
1 files changed, 13 insertions(+), 28 deletions(-)

Index: 2.6/fs/isofs/rock.c
===================================================================
--- 2.6.orig/fs/isofs/rock.c 2005-03-28 18:26:34.000000000 +0300
+++ 2.6/fs/isofs/rock.c 2005-03-28 18:27:35.000000000 +0300
@@ -140,21 +140,17 @@
kfree(buffer);
buffer = NULL;
if (cont_extent) {
- int block, offset, offset1;
struct buffer_head * pbh;
buffer = kmalloc(cont_size,GFP_KERNEL);
if (!buffer)
goto out;
- block = cont_extent;
- offset = cont_offset;
- offset1 = 0;
- pbh = sb_bread(inode->i_sb, block);
+ pbh = sb_bread(inode->i_sb, cont_extent);
if(pbh) {
- if (offset > pbh->b_size || offset + cont_size > pbh->b_size) {
+ if (cont_offset > pbh->b_size || cont_offset + cont_size > pbh->b_size) {
brelse(pbh);
goto out;
}
- memcpy(buffer + offset1, pbh->b_data + offset, cont_size - offset1);
+ memcpy(buffer, pbh->b_data + cont_offset, cont_size);
brelse(pbh);
chr = (unsigned char *) buffer;
len = cont_size;
@@ -424,21 +420,17 @@
kfree(buffer);
buffer = NULL;
if (cont_extent) {
- int block, offset, offset1;
struct buffer_head * pbh;
buffer = kmalloc(cont_size,GFP_KERNEL);
if (!buffer)
goto out;
- block = cont_extent;
- offset = cont_offset;
- offset1 = 0;
- pbh = sb_bread(inode->i_sb, block);
+ pbh = sb_bread(inode->i_sb, cont_extent);
if(pbh) {
- if (offset > pbh->b_size || offset + cont_size > pbh->b_size) {
+ if (cont_offset > pbh->b_size || cont_offset + cont_size > pbh->b_size) {
brelse(pbh);
goto out;
}
- memcpy(buffer + offset1, pbh->b_data + offset, cont_size - offset1);
+ memcpy(buffer, pbh->b_data + cont_offset, cont_size);
brelse(pbh);
chr = (unsigned char *) buffer;
len = cont_size;
@@ -549,8 +541,6 @@
struct iso_directory_record *raw_inode;
int cont_extent = 0, cont_offset = 0, cont_size = 0;
void *buffer = NULL;
- unsigned long block, offset;
- int sig;
int len;
unsigned char *chr;
struct rock_ridge *rr;
@@ -558,21 +548,19 @@
if (!ISOFS_SB(inode->i_sb)->s_rock)
goto error;

- block = ei->i_iget5_block;
lock_kernel();
- bh = sb_bread(inode->i_sb, block);
+ bh = sb_bread(inode->i_sb, ei->i_iget5_block);
if (!bh)
goto out_noread;

- offset = ei->i_iget5_offset;
- pnt = (unsigned char *)bh->b_data + offset;
+ pnt = (unsigned char *)bh->b_data + ei->i_iget5_offset;

raw_inode = (struct iso_directory_record *)pnt;

/*
* If we go past the end of the buffer, there is some sort of error.
*/
- if (offset + *pnt > bufsize)
+ if (ei->i_iget5_offset + *pnt > bufsize)
goto out_bad_span;

/* Now test for possible Rock Ridge extensions which will override
@@ -582,6 +570,7 @@

repeat:
while (len > 2) { /* There may be one byte for padding somewhere */
+ int sig;
rr = (struct rock_ridge *)chr;
if (rr->len < 3)
goto out; /* Something got screwed up here */
@@ -620,21 +609,17 @@
kfree(buffer);
buffer = NULL;
if (cont_extent) {
- int block, offset, offset1;
struct buffer_head * pbh;
buffer = kmalloc(cont_size,GFP_KERNEL);
if (!buffer)
goto out;
- block = cont_extent;
- offset = cont_offset;
- offset1 = 0;
- pbh = sb_bread(inode->i_sb, block);
+ pbh = sb_bread(inode->i_sb, cont_extent);
if(pbh) {
- if (offset > pbh->b_size || offset + cont_size > pbh->b_size) {
+ if (cont_offset > pbh->b_size || cont_offset + cont_size > pbh->b_size) {
brelse(pbh);
goto out;
}
- memcpy(buffer + offset1, pbh->b_data + offset, cont_size - offset1);
+ memcpy(buffer, pbh->b_data + cont_offset, cont_size);
brelse(pbh);
chr = (unsigned char *) buffer;
len = cont_size;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



-------------------------------------------------------------------------------
Achtung: diese Newsgruppe ist eine unidirektional gegatete Mailingliste.
Antworten nur per Mail an die im Reply-To-Header angegebene Adresse.
Fragen zum Gateway -> ***@inka.de.
-------------------------------------------------------------------------------
Loading...