Commit be6cdf41 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: NULL noise in jffs

parent 7140ae4b
...@@ -315,7 +315,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr) ...@@ -315,7 +315,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
} }
/* Write this node to the flash. */ /* Write this node to the flash. */
if ((res = jffs_write_node(c, new_node, &raw_inode, f->name, 0, recoverable, f)) < 0) { if ((res = jffs_write_node(c, new_node, &raw_inode, f->name, NULL, recoverable, f)) < 0) {
D(printk("jffs_notify_change(): The write failed!\n")); D(printk("jffs_notify_change(): The write failed!\n"));
jffs_free_node(new_node); jffs_free_node(new_node);
D3(printk (KERN_NOTICE "n_c(): up biglock\n")); D3(printk (KERN_NOTICE "n_c(): up biglock\n"));
...@@ -323,7 +323,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr) ...@@ -323,7 +323,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
goto out; goto out;
} }
jffs_insert_node(c, f, &raw_inode, 0, new_node); jffs_insert_node(c, f, &raw_inode, NULL, new_node);
mark_inode_dirty(inode); mark_inode_dirty(inode);
D3(printk (KERN_NOTICE "n_c(): up biglock\n")); D3(printk (KERN_NOTICE "n_c(): up biglock\n"));
...@@ -879,14 +879,14 @@ jffs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -879,14 +879,14 @@ jffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
/* Write the new node to the flash. */ /* Write the new node to the flash. */
if ((result = jffs_write_node(c, node, &raw_inode, if ((result = jffs_write_node(c, node, &raw_inode,
dentry->d_name.name, 0, 0, NULL)) < 0) { dentry->d_name.name, NULL, 0, NULL)) < 0) {
D(printk("jffs_mkdir(): jffs_write_node() failed.\n")); D(printk("jffs_mkdir(): jffs_write_node() failed.\n"));
jffs_free_node(node); jffs_free_node(node);
goto jffs_mkdir_end; goto jffs_mkdir_end;
} }
/* Insert the new node into the file system. */ /* Insert the new node into the file system. */
if ((result = jffs_insert_node(c, 0, &raw_inode, dentry->d_name.name, if ((result = jffs_insert_node(c, NULL, &raw_inode, dentry->d_name.name,
node)) < 0) { node)) < 0) {
goto jffs_mkdir_end; goto jffs_mkdir_end;
} }
...@@ -959,7 +959,7 @@ jffs_remove(struct inode *dir, struct dentry *dentry, int type) ...@@ -959,7 +959,7 @@ jffs_remove(struct inode *dir, struct dentry *dentry, int type)
struct jffs_file *dir_f; /* The file-to-remove's parent. */ struct jffs_file *dir_f; /* The file-to-remove's parent. */
struct jffs_file *del_f; /* The file to remove. */ struct jffs_file *del_f; /* The file to remove. */
struct jffs_node *del_node; struct jffs_node *del_node;
struct inode *inode = 0; struct inode *inode = NULL;
int result = 0; int result = 0;
D1({ D1({
...@@ -1041,7 +1041,7 @@ jffs_remove(struct inode *dir, struct dentry *dentry, int type) ...@@ -1041,7 +1041,7 @@ jffs_remove(struct inode *dir, struct dentry *dentry, int type)
raw_inode.deleted = 1; raw_inode.deleted = 1;
/* Write the new node to the flash memory. */ /* Write the new node to the flash memory. */
if (jffs_write_node(c, del_node, &raw_inode, 0, 0, 1, del_f) < 0) { if (jffs_write_node(c, del_node, &raw_inode, NULL, NULL, 1, del_f) < 0) {
jffs_free_node(del_node); jffs_free_node(del_node);
result = -EIO; result = -EIO;
goto jffs_remove_end; goto jffs_remove_end;
...@@ -1049,7 +1049,7 @@ jffs_remove(struct inode *dir, struct dentry *dentry, int type) ...@@ -1049,7 +1049,7 @@ jffs_remove(struct inode *dir, struct dentry *dentry, int type)
/* Update the file. This operation will make the file disappear /* Update the file. This operation will make the file disappear
from the in-memory file system structures. */ from the in-memory file system structures. */
jffs_insert_node(c, del_f, &raw_inode, 0, del_node); jffs_insert_node(c, del_f, &raw_inode, NULL, del_node);
dir->i_ctime = dir->i_mtime = CURRENT_TIME; dir->i_ctime = dir->i_mtime = CURRENT_TIME;
mark_inode_dirty(dir); mark_inode_dirty(dir);
...@@ -1070,7 +1070,7 @@ jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) ...@@ -1070,7 +1070,7 @@ jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
{ {
struct jffs_raw_inode raw_inode; struct jffs_raw_inode raw_inode;
struct jffs_file *dir_f; struct jffs_file *dir_f;
struct jffs_node *node = 0; struct jffs_node *node = NULL;
struct jffs_control *c; struct jffs_control *c;
struct inode *inode; struct inode *inode;
int result = 0; int result = 0;
...@@ -1127,7 +1127,7 @@ jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) ...@@ -1127,7 +1127,7 @@ jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
} }
/* Insert the new node into the file system. */ /* Insert the new node into the file system. */
if ((err = jffs_insert_node(c, 0, &raw_inode, dentry->d_name.name, if ((err = jffs_insert_node(c, NULL, &raw_inode, dentry->d_name.name,
node)) < 0) { node)) < 0) {
result = err; result = err;
goto jffs_mknod_end; goto jffs_mknod_end;
...@@ -1237,7 +1237,7 @@ jffs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) ...@@ -1237,7 +1237,7 @@ jffs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
} }
/* Insert the new node into the file system. */ /* Insert the new node into the file system. */
if ((err = jffs_insert_node(c, 0, &raw_inode, dentry->d_name.name, if ((err = jffs_insert_node(c, NULL, &raw_inode, dentry->d_name.name,
node)) < 0) { node)) < 0) {
goto jffs_symlink_end; goto jffs_symlink_end;
} }
...@@ -1333,14 +1333,14 @@ jffs_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -1333,14 +1333,14 @@ jffs_create(struct inode *dir, struct dentry *dentry, int mode,
/* Write the new node to the flash. */ /* Write the new node to the flash. */
if ((err = jffs_write_node(c, node, &raw_inode, if ((err = jffs_write_node(c, node, &raw_inode,
dentry->d_name.name, 0, 0, NULL)) < 0) { dentry->d_name.name, NULL, 0, NULL)) < 0) {
D(printk("jffs_create(): jffs_write_node() failed.\n")); D(printk("jffs_create(): jffs_write_node() failed.\n"));
jffs_free_node(node); jffs_free_node(node);
goto jffs_create_end; goto jffs_create_end;
} }
/* Insert the new node into the file system. */ /* Insert the new node into the file system. */
if ((err = jffs_insert_node(c, 0, &raw_inode, dentry->d_name.name, if ((err = jffs_insert_node(c, NULL, &raw_inode, dentry->d_name.name,
node)) < 0) { node)) < 0) {
goto jffs_create_end; goto jffs_create_end;
} }
...@@ -1501,7 +1501,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count, ...@@ -1501,7 +1501,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
pos += err; pos += err;
/* Insert the new node into the file system. */ /* Insert the new node into the file system. */
if ((err = jffs_insert_node(c, f, &raw_inode, 0, node)) < 0) { if ((err = jffs_insert_node(c, f, &raw_inode, NULL, node)) < 0) {
goto out; goto out;
} }
...@@ -1750,7 +1750,7 @@ jffs_delete_inode(struct inode *inode) ...@@ -1750,7 +1750,7 @@ jffs_delete_inode(struct inode *inode)
lock_kernel(); lock_kernel();
inode->i_size = 0; inode->i_size = 0;
inode->i_blocks = 0; inode->i_blocks = 0;
inode->u.generic_ip = 0; inode->u.generic_ip = NULL;
clear_inode(inode); clear_inode(inode);
if (inode->i_nlink == 0) { if (inode->i_nlink == 0) {
c = (struct jffs_control *) inode->i_sb->s_fs_info; c = (struct jffs_control *) inode->i_sb->s_fs_info;
......
...@@ -409,7 +409,7 @@ jffs_create_file(struct jffs_control *c, ...@@ -409,7 +409,7 @@ jffs_create_file(struct jffs_control *c,
if (!(f = (struct jffs_file *)kmalloc(sizeof(struct jffs_file), if (!(f = (struct jffs_file *)kmalloc(sizeof(struct jffs_file),
GFP_KERNEL))) { GFP_KERNEL))) {
D(printk("jffs_create_file(): Failed!\n")); D(printk("jffs_create_file(): Failed!\n"));
return 0; return NULL;
} }
no_jffs_file++; no_jffs_file++;
memset(f, 0, sizeof(struct jffs_file)); memset(f, 0, sizeof(struct jffs_file));
...@@ -438,8 +438,8 @@ jffs_create_control(struct super_block *sb) ...@@ -438,8 +438,8 @@ jffs_create_control(struct super_block *sb)
goto fail_control; goto fail_control;
} }
DJM(no_jffs_control++); DJM(no_jffs_control++);
c->root = 0; c->root = NULL;
c->gc_task = 0; c->gc_task = NULL;
c->hash_len = JFFS_HASH_SIZE; c->hash_len = JFFS_HASH_SIZE;
s = sizeof(struct list_head) * c->hash_len; s = sizeof(struct list_head) * c->hash_len;
if (!(c->hash = (struct list_head *)kmalloc(s, GFP_KERNEL))) { if (!(c->hash = (struct list_head *)kmalloc(s, GFP_KERNEL))) {
...@@ -752,7 +752,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -752,7 +752,7 @@ jffs_scan_flash(struct jffs_control *c)
{ {
char name[JFFS_MAX_NAME_LEN + 2]; char name[JFFS_MAX_NAME_LEN + 2];
struct jffs_raw_inode raw_inode; struct jffs_raw_inode raw_inode;
struct jffs_node *node = 0; struct jffs_node *node = NULL;
struct jffs_fmcontrol *fmc = c->fmc; struct jffs_fmcontrol *fmc = c->fmc;
__u32 checksum; __u32 checksum;
__u8 tmp_accurate; __u8 tmp_accurate;
...@@ -904,7 +904,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -904,7 +904,7 @@ jffs_scan_flash(struct jffs_control *c)
D1(printk("Dirty space: Starting 0x%x for 0x%x bytes\n", D1(printk("Dirty space: Starting 0x%x for 0x%x bytes\n",
(unsigned int) start, (unsigned int) (pos - start))); (unsigned int) start, (unsigned int) (pos - start)));
jffs_fmalloced(fmc, (__u32) start, jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), 0); (__u32) (pos - start), NULL);
}else{ }else{
/* "Flipping bits" detected. This means that our scan for them /* "Flipping bits" detected. This means that our scan for them
did not catch this offset. See check_partly_erased_sectors() for did not catch this offset. See check_partly_erased_sectors() for
...@@ -964,7 +964,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -964,7 +964,7 @@ jffs_scan_flash(struct jffs_control *c)
D1(printk("Dirty space: Starting 0x%x for 0x%x bytes\n", D1(printk("Dirty space: Starting 0x%x for 0x%x bytes\n",
(unsigned int) start, (unsigned int) (pos - start))); (unsigned int) start, (unsigned int) (pos - start)));
jffs_fmalloced(fmc, (__u32) start, jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), 0); (__u32) (pos - start), NULL);
} }
} }
...@@ -986,7 +986,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -986,7 +986,7 @@ jffs_scan_flash(struct jffs_control *c)
D1(printk("jffs_scan_flash(): 0x00 ended at " D1(printk("jffs_scan_flash(): 0x00 ended at "
"pos 0x%lx.\n", (long)pos)); "pos 0x%lx.\n", (long)pos));
jffs_fmalloced(fmc, (__u32) start, jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), 0); (__u32) (pos - start), NULL);
continue; continue;
case JFFS_MAGIC_BITMASK: case JFFS_MAGIC_BITMASK:
...@@ -1020,7 +1020,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -1020,7 +1020,7 @@ jffs_scan_flash(struct jffs_control *c)
which really does contain crap. */ which really does contain crap. */
jffs_fmalloced(fmc, (__u32) start, jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), (__u32) (pos - start),
0); NULL);
continue; continue;
}/* switch */ }/* switch */
...@@ -1067,7 +1067,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -1067,7 +1067,7 @@ jffs_scan_flash(struct jffs_control *c)
checksum, raw_inode.chksum)); checksum, raw_inode.chksum));
pos += sizeof(struct jffs_raw_inode); pos += sizeof(struct jffs_raw_inode);
jffs_fmalloced(fmc, (__u32) start, jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), 0); (__u32) (pos - start), NULL);
/* Reuse this unused struct jffs_node. */ /* Reuse this unused struct jffs_node. */
continue; continue;
} }
...@@ -1121,7 +1121,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -1121,7 +1121,7 @@ jffs_scan_flash(struct jffs_control *c)
"raw_inode.nchksum = %u\n", "raw_inode.nchksum = %u\n",
checksum, raw_inode.nchksum)); checksum, raw_inode.nchksum));
jffs_fmalloced(fmc, (__u32) start, jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), 0); (__u32) (pos - start), NULL);
/* Reuse this unused struct jffs_node. */ /* Reuse this unused struct jffs_node. */
continue; continue;
} }
...@@ -1139,7 +1139,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -1139,7 +1139,7 @@ jffs_scan_flash(struct jffs_control *c)
if (jffs_checksum_flash(fmc->mtd, pos, raw_inode.dsize, &checksum)) { if (jffs_checksum_flash(fmc->mtd, pos, raw_inode.dsize, &checksum)) {
printk("jffs_checksum_flash() failed to calculate a checksum\n"); printk("jffs_checksum_flash() failed to calculate a checksum\n");
jffs_fmalloced(fmc, (__u32) start, jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), 0); (__u32) (pos - start), NULL);
/* Reuse this unused struct jffs_node. */ /* Reuse this unused struct jffs_node. */
continue; continue;
} }
...@@ -1152,7 +1152,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -1152,7 +1152,7 @@ jffs_scan_flash(struct jffs_control *c)
"raw_inode.dchksum = %u\n", "raw_inode.dchksum = %u\n",
checksum, raw_inode.dchksum)); checksum, raw_inode.dchksum));
jffs_fmalloced(fmc, (__u32) start, jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), 0); (__u32) (pos - start), NULL);
/* Reuse this unused struct jffs_node. */ /* Reuse this unused struct jffs_node. */
continue; continue;
} }
...@@ -1194,7 +1194,7 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -1194,7 +1194,7 @@ jffs_scan_flash(struct jffs_control *c)
return -ENOMEM; return -ENOMEM;
} }
if ((err = jffs_insert_node(c, 0, &raw_inode, if ((err = jffs_insert_node(c, NULL, &raw_inode,
name, node)) < 0) { name, node)) < 0) {
printk("JFFS: Failed to handle raw inode. " printk("JFFS: Failed to handle raw inode. "
"(err = %d)\n", err); "(err = %d)\n", err);
...@@ -1224,11 +1224,11 @@ jffs_scan_flash(struct jffs_control *c) ...@@ -1224,11 +1224,11 @@ jffs_scan_flash(struct jffs_control *c)
node->data_size = 0; node->data_size = 0;
} }
D3(jffs_print_node(node)); D3(jffs_print_node(node));
node = 0; /* Don't free the node! */ node = NULL; /* Don't free the node! */
} }
else { else {
jffs_fmalloced(fmc, (__u32) start, jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), 0); (__u32) (pos - start), NULL);
D3(printk("jffs_scan_flash(): Just found an obsolete " D3(printk("jffs_scan_flash(): Just found an obsolete "
"raw_inode. Continuing the scan...\n")); "raw_inode. Continuing the scan...\n"));
/* Reuse this unused struct jffs_node. */ /* Reuse this unused struct jffs_node. */
...@@ -1312,8 +1312,8 @@ jffs_insert_node(struct jffs_control *c, struct jffs_file *f, ...@@ -1312,8 +1312,8 @@ jffs_insert_node(struct jffs_control *c, struct jffs_file *f,
/* This is the first node. */ /* This is the first node. */
f->version_head = node; f->version_head = node;
f->version_tail = node; f->version_tail = node;
node->version_prev = 0; node->version_prev = NULL;
node->version_next = 0; node->version_next = NULL;
f->highest_version = node->version; f->highest_version = node->version;
update_name = 1; update_name = 1;
f->mode = raw_inode->mode; f->mode = raw_inode->mode;
...@@ -1328,7 +1328,7 @@ jffs_insert_node(struct jffs_control *c, struct jffs_file *f, ...@@ -1328,7 +1328,7 @@ jffs_insert_node(struct jffs_control *c, struct jffs_file *f,
/* Insert at the end of the list. I.e. this node is the /* Insert at the end of the list. I.e. this node is the
newest one so far. */ newest one so far. */
node->version_prev = f->version_tail; node->version_prev = f->version_tail;
node->version_next = 0; node->version_next = NULL;
f->version_tail->version_next = node; f->version_tail->version_next = node;
f->version_tail = node; f->version_tail = node;
f->highest_version = node->version; f->highest_version = node->version;
...@@ -1343,7 +1343,7 @@ jffs_insert_node(struct jffs_control *c, struct jffs_file *f, ...@@ -1343,7 +1343,7 @@ jffs_insert_node(struct jffs_control *c, struct jffs_file *f,
} }
else if (f->version_head->version > node->version) { else if (f->version_head->version > node->version) {
/* Insert at the bottom of the list. */ /* Insert at the bottom of the list. */
node->version_prev = 0; node->version_prev = NULL;
node->version_next = f->version_head; node->version_next = f->version_head;
f->version_head->version_prev = node; f->version_head->version_prev = node;
f->version_head = node; f->version_head = node;
...@@ -1556,9 +1556,9 @@ jffs_insert_file_into_tree(struct jffs_file *f) ...@@ -1556,9 +1556,9 @@ jffs_insert_file_into_tree(struct jffs_file *f)
if (!(parent = jffs_find_file(f->c, f->pino))) { if (!(parent = jffs_find_file(f->c, f->pino))) {
if (f->pino == 0) { if (f->pino == 0) {
f->c->root = f; f->c->root = f;
f->parent = 0; f->parent = NULL;
f->sibling_prev = 0; f->sibling_prev = NULL;
f->sibling_next = 0; f->sibling_next = NULL;
return 0; return 0;
} }
else { else {
...@@ -1573,7 +1573,7 @@ jffs_insert_file_into_tree(struct jffs_file *f) ...@@ -1573,7 +1573,7 @@ jffs_insert_file_into_tree(struct jffs_file *f)
if (f->sibling_next) { if (f->sibling_next) {
f->sibling_next->sibling_prev = f; f->sibling_next->sibling_prev = f;
} }
f->sibling_prev = 0; f->sibling_prev = NULL;
parent->children = f; parent->children = f;
return 0; return 0;
} }
...@@ -2311,7 +2311,7 @@ jffs_insert_data(struct jffs_file *f, struct jffs_node *node) ...@@ -2311,7 +2311,7 @@ jffs_insert_data(struct jffs_file *f, struct jffs_node *node)
retry: retry:
if (node->data_offset == f->size) { if (node->data_offset == f->size) {
/* A simple append. This is the most common operation. */ /* A simple append. This is the most common operation. */
node->range_next = 0; node->range_next = NULL;
node->range_prev = f->range_tail; node->range_prev = f->range_tail;
if (node->range_prev) { if (node->range_prev) {
node->range_prev->range_next = node; node->range_prev->range_next = node;
...@@ -2389,10 +2389,10 @@ jffs_insert_data(struct jffs_file *f, struct jffs_node *node) ...@@ -2389,10 +2389,10 @@ jffs_insert_data(struct jffs_file *f, struct jffs_node *node)
virtual_node->removed_size = 0; virtual_node->removed_size = 0;
virtual_node->fm_offset = 0; virtual_node->fm_offset = 0;
virtual_node->name_size = 0; virtual_node->name_size = 0;
virtual_node->fm = 0; /* This is a virtual data holder. */ virtual_node->fm = NULL; /* This is a virtual data holder. */
virtual_node->version_prev = 0; virtual_node->version_prev = NULL;
virtual_node->version_next = 0; virtual_node->version_next = NULL;
virtual_node->range_next = 0; virtual_node->range_next = NULL;
/* Are there any data at all in the file yet? */ /* Are there any data at all in the file yet? */
if (f->range_head) { if (f->range_head) {
...@@ -2407,7 +2407,7 @@ jffs_insert_data(struct jffs_file *f, struct jffs_node *node) ...@@ -2407,7 +2407,7 @@ jffs_insert_data(struct jffs_file *f, struct jffs_node *node)
else { else {
virtual_node->data_offset = 0; virtual_node->data_offset = 0;
virtual_node->data_size = node->data_offset; virtual_node->data_size = node->data_offset;
virtual_node->range_prev = 0; virtual_node->range_prev = NULL;
f->range_head = virtual_node; f->range_head = virtual_node;
} }
......
...@@ -77,10 +77,10 @@ jffs_build_begin(struct jffs_control *c, int unit) ...@@ -77,10 +77,10 @@ jffs_build_begin(struct jffs_control *c, int unit)
fmc->min_free_size = fmc->sector_size << 2; fmc->min_free_size = fmc->sector_size << 2;
fmc->mtd = mtd; fmc->mtd = mtd;
fmc->c = c; fmc->c = c;
fmc->head = 0; fmc->head = NULL;
fmc->tail = 0; fmc->tail = NULL;
fmc->head_extra = 0; fmc->head_extra = NULL;
fmc->tail_extra = 0; fmc->tail_extra = NULL;
init_MUTEX(&fmc->biglock); init_MUTEX(&fmc->biglock);
return fmc; return fmc;
} }
...@@ -102,8 +102,8 @@ jffs_build_end(struct jffs_fmcontrol *fmc) ...@@ -102,8 +102,8 @@ jffs_build_end(struct jffs_fmcontrol *fmc)
fmc->head->prev = fmc->tail_extra; fmc->head->prev = fmc->tail_extra;
fmc->head = fmc->head_extra; fmc->head = fmc->head_extra;
} }
fmc->head_extra = 0; /* These two instructions should be omitted. */ fmc->head_extra = NULL; /* These two instructions should be omitted. */
fmc->tail_extra = 0; fmc->tail_extra = NULL;
D3(jffs_print_fmcontrol(fmc)); D3(jffs_print_fmcontrol(fmc));
} }
...@@ -205,7 +205,7 @@ jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node, ...@@ -205,7 +205,7 @@ jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node,
D2(printk("jffs_fmalloc(): fmc = 0x%p, size = %d, " D2(printk("jffs_fmalloc(): fmc = 0x%p, size = %d, "
"node = 0x%p\n", fmc, size, node)); "node = 0x%p\n", fmc, size, node));
*result = 0; *result = NULL;
if (!(fm = jffs_alloc_fm())) { if (!(fm = jffs_alloc_fm())) {
D(printk("jffs_fmalloc(): kmalloc() failed! (fm)\n")); D(printk("jffs_fmalloc(): kmalloc() failed! (fm)\n"));
...@@ -234,7 +234,7 @@ jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node, ...@@ -234,7 +234,7 @@ jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node,
} }
DJM(no_jffs_node_ref++); DJM(no_jffs_node_ref++);
fm->nodes->node = node; fm->nodes->node = node;
fm->nodes->next = 0; fm->nodes->next = NULL;
if (fmc->tail) { if (fmc->tail) {
fm->offset = fmc->tail->offset + fmc->tail->size; fm->offset = fmc->tail->offset + fmc->tail->size;
if (fm->offset == fmc->flash_size) { if (fm->offset == fmc->flash_size) {
...@@ -264,7 +264,7 @@ jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node, ...@@ -264,7 +264,7 @@ jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node,
else { else {
fm->offset = fmc->tail->offset + fmc->tail->size; fm->offset = fmc->tail->offset + fmc->tail->size;
fm->size = free_chunk_size1; fm->size = free_chunk_size1;
fm->nodes = 0; fm->nodes = NULL;
fmc->free_size -= fm->size; fmc->free_size -= fm->size;
fmc->dirty_size += fm->size; /* Changed by simonk. This seemingly fixes a fmc->dirty_size += fm->size; /* Changed by simonk. This seemingly fixes a
bug that caused infinite garbage collection. bug that caused infinite garbage collection.
...@@ -273,9 +273,9 @@ jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node, ...@@ -273,9 +273,9 @@ jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node,
*/ */
} }
fm->next = 0; fm->next = NULL;
if (!fmc->head) { if (!fmc->head) {
fm->prev = 0; fm->prev = NULL;
fmc->head = fm; fmc->head = fm;
fmc->tail = fm; fmc->tail = fm;
} }
...@@ -309,13 +309,13 @@ jffs_fmfree(struct jffs_fmcontrol *fmc, struct jffs_fm *fm, struct jffs_node *no ...@@ -309,13 +309,13 @@ jffs_fmfree(struct jffs_fmcontrol *fmc, struct jffs_fm *fm, struct jffs_node *no
ASSERT(if (!fmc || !fm || !fm->nodes) { ASSERT(if (!fmc || !fm || !fm->nodes) {
printk(KERN_ERR "jffs_fmfree(): fmc: 0x%p, fm: 0x%p, " printk(KERN_ERR "jffs_fmfree(): fmc: 0x%p, fm: 0x%p, "
"fm->nodes: 0x%p\n", "fm->nodes: 0x%p\n",
fmc, fm, (fm ? fm->nodes : 0)); fmc, fm, (fm ? fm->nodes : NULL));
return -1; return -1;
}); });
/* Find the reference to the node that is going to be removed /* Find the reference to the node that is going to be removed
and remove it. */ and remove it. */
for (ref = fm->nodes, prev = 0; ref; ref = ref->next) { for (ref = fm->nodes, prev = NULL; ref; ref = ref->next) {
if (ref->node == node) { if (ref->node == node) {
if (prev) { if (prev) {
prev->next = ref->next; prev->next = ref->next;
...@@ -368,13 +368,13 @@ jffs_fmalloced(struct jffs_fmcontrol *fmc, __u32 offset, __u32 size, ...@@ -368,13 +368,13 @@ jffs_fmalloced(struct jffs_fmcontrol *fmc, __u32 offset, __u32 size,
if (!(fm = jffs_alloc_fm())) { if (!(fm = jffs_alloc_fm())) {
D(printk("jffs_fmalloced(0x%p, %u, %u, 0x%p): failed!\n", D(printk("jffs_fmalloced(0x%p, %u, %u, 0x%p): failed!\n",
fmc, offset, size, node)); fmc, offset, size, node));
return 0; return NULL;
} }
fm->offset = offset; fm->offset = offset;
fm->size = size; fm->size = size;
fm->prev = 0; fm->prev = NULL;
fm->next = 0; fm->next = NULL;
fm->nodes = 0; fm->nodes = NULL;
if (node) { if (node) {
/* `node' exists and it should be associated with the /* `node' exists and it should be associated with the
jffs_fm structure `fm'. */ jffs_fm structure `fm'. */
...@@ -383,11 +383,11 @@ jffs_fmalloced(struct jffs_fmcontrol *fmc, __u32 offset, __u32 size, ...@@ -383,11 +383,11 @@ jffs_fmalloced(struct jffs_fmcontrol *fmc, __u32 offset, __u32 size,
GFP_KERNEL))) { GFP_KERNEL))) {
D(printk("jffs_fmalloced(): !fm->nodes\n")); D(printk("jffs_fmalloced(): !fm->nodes\n"));
jffs_free_fm(fm); jffs_free_fm(fm);
return 0; return NULL;
} }
DJM(no_jffs_node_ref++); DJM(no_jffs_node_ref++);
fm->nodes->node = node; fm->nodes->node = node;
fm->nodes->next = 0; fm->nodes->next = NULL;
fmc->used_size += size; fmc->used_size += size;
fmc->free_size -= size; fmc->free_size -= size;
} }
...@@ -454,7 +454,7 @@ jffs_fmfree_partly(struct jffs_fmcontrol *fmc, struct jffs_fm *fm, __u32 size) ...@@ -454,7 +454,7 @@ jffs_fmfree_partly(struct jffs_fmcontrol *fmc, struct jffs_fm *fm, __u32 size)
if (fm->nodes) { if (fm->nodes) {
kfree(fm->nodes); kfree(fm->nodes);
DJM(no_jffs_node_ref--); DJM(no_jffs_node_ref--);
fm->nodes = 0; fm->nodes = NULL;
} }
fmc->used_size -= fm->size; fmc->used_size -= fm->size;
if (fm == fmc->tail) { if (fm == fmc->tail) {
...@@ -476,12 +476,12 @@ jffs_cut_node(struct jffs_fmcontrol *fmc, __u32 size) ...@@ -476,12 +476,12 @@ jffs_cut_node(struct jffs_fmcontrol *fmc, __u32 size)
__u32 pos = 0; __u32 pos = 0;
if (size == 0) { if (size == 0) {
return 0; return NULL;
} }
ASSERT(if (!fmc) { ASSERT(if (!fmc) {
printk(KERN_ERR "jffs_cut_node(): fmc == NULL\n"); printk(KERN_ERR "jffs_cut_node(): fmc == NULL\n");
return 0; return NULL;
}); });
fm = fmc->head; fm = fmc->head;
...@@ -495,7 +495,7 @@ jffs_cut_node(struct jffs_fmcontrol *fmc, __u32 size) ...@@ -495,7 +495,7 @@ jffs_cut_node(struct jffs_fmcontrol *fmc, __u32 size)
break; break;
} }
else { else {
fm = 0; fm = NULL;
break; break;
} }
} }
...@@ -524,7 +524,7 @@ jffs_sync_erase(struct jffs_fmcontrol *fmc, int erased_size) ...@@ -524,7 +524,7 @@ jffs_sync_erase(struct jffs_fmcontrol *fmc, int erased_size)
erased_size -= fm->size; erased_size -= fm->size;
del = fm; del = fm;
fm = fm->next; fm = fm->next;
fm->prev = 0; fm->prev = NULL;
fmc->head = fm; fmc->head = fm;
jffs_free_fm(del); jffs_free_fm(del);
} }
...@@ -543,17 +543,17 @@ jffs_get_oldest_node(struct jffs_fmcontrol *fmc) ...@@ -543,17 +543,17 @@ jffs_get_oldest_node(struct jffs_fmcontrol *fmc)
{ {
struct jffs_fm *fm; struct jffs_fm *fm;
struct jffs_node_ref *nref; struct jffs_node_ref *nref;
struct jffs_node *node = 0; struct jffs_node *node = NULL;
ASSERT(if (!fmc) { ASSERT(if (!fmc) {
printk(KERN_ERR "jffs_get_oldest_node(): fmc == NULL\n"); printk(KERN_ERR "jffs_get_oldest_node(): fmc == NULL\n");
return 0; return NULL;
}); });
for (fm = fmc->head; fm && !fm->nodes; fm = fm->next); for (fm = fmc->head; fm && !fm->nodes; fm = fm->next);
if (!fm) { if (!fm) {
return 0; return NULL;
} }
/* The oldest node is the last one in the reference list. This list /* The oldest node is the last one in the reference list. This list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment