summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>1998-09-03 01:22:57 +0000
committerTheodore Ts'o <tytso@mit.edu>1998-09-03 01:22:57 +0000
commit2eb374c9401079aa56aa12f0047ca3866e69b754 (patch)
treee6d57fb1f217ab0aea0d83f14d494120db5b1711
parent1333fe93446a09ceb866a7f2a1ca0c196964b952 (diff)
downloade2fsprogs-2eb374c9401079aa56aa12f0047ca3866e69b754.tar.gz
Many files:
rw_bitmaps.c: Fixed signed/unsigned warnings. fileio.c (ext2fs_file_set_size): Remove unneeded extern from the function declaration. dblist.c (make_dblist): Add safety check in case the dblist pointer passed in is null (in which case, assign it to fs->dblist). Fixed some signed/unsigned warnings. bmap.c: Make addr_per_block be of type blk_t to avoid signed/unsigned warnings. namei.c (ext2fs_follow_link): Remove uneeded extern from the function declaration. get_pathname.c (get_pathname_proc): Use return value from ext2fs_get_mem, instead of checking if &gp->name is NULL. dir_iterate.c (ext2fs_process_dir_block): dblist_dir.c (ext2fs_dblist_dir_iterate): Remove uneeded extern from the function declaration. block.c (ext2fs_block_iterate2): If the read_inode call fails, return the error directly instead of jumping to the cleanup routine, since we don't need to do any cleanup. alloc_table.c (ext2fs_allocate_group_table): Make this function take a dgrp_t for its group argument. ext2fs.h: Make dgrp_t an __u32 type, and make fs->desc_group_count be of type dgrp_t.
-rw-r--r--lib/ext2fs/ChangeLog35
-rw-r--r--lib/ext2fs/alloc_tables.c4
-rw-r--r--lib/ext2fs/block.c2
-rw-r--r--lib/ext2fs/bmap.c12
-rw-r--r--lib/ext2fs/dblist.c9
-rw-r--r--lib/ext2fs/dblist_dir.c23
-rw-r--r--lib/ext2fs/dir_iterate.c12
-rw-r--r--lib/ext2fs/ext2fs.h6
-rw-r--r--lib/ext2fs/fileio.c2
-rw-r--r--lib/ext2fs/get_pathname.c4
-rw-r--r--lib/ext2fs/namei.c2
-rw-r--r--lib/ext2fs/rw_bitmaps.c6
12 files changed, 77 insertions, 40 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index ddce36d9..2684d86c 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,38 @@
+1998-09-02 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * rw_bitmaps.c: Fixed signed/unsigned warnings.
+
+ * fileio.c (ext2fs_file_set_size): Remove unneeded extern from the
+ function declaration.
+
+ * dblist.c (make_dblist): Add safety check in case the dblist
+ pointer passed in is null (in which case, assign it to
+ fs->dblist). Fixed some signed/unsigned warnings.
+
+ * bmap.c: Make addr_per_block be of type blk_t to avoid
+ signed/unsigned warnings.
+
+ * namei.c (ext2fs_follow_link): Remove uneeded extern from the
+ function declaration.
+
+ * get_pathname.c (get_pathname_proc): Use return value from
+ ext2fs_get_mem, instead of checking if &gp->name is
+ NULL.
+
+ * dir_iterate.c (ext2fs_process_dir_block):
+ * dblist_dir.c (ext2fs_dblist_dir_iterate): Remove uneeded extern
+ from the function declaration.
+
+ * block.c (ext2fs_block_iterate2): If the read_inode call fails,
+ return the error directly instead of jumping to the
+ cleanup routine, since we don't need to do any cleanup.
+
+ * alloc_table.c (ext2fs_allocate_group_table): Make this
+ function take a dgrp_t for its group argument.
+
+ * ext2fs.h: Make dgrp_t an __u32 type, and make
+ fs->desc_group_count be of type dgrp_t.
+
1998-07-27 Theodore Ts'o <tytso@rsts-11.mit.edu>
* badblocks.c (ext2fs_badblocks_list_add): Use a bigger increment
diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index 3660c5e0..81138542 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -32,7 +32,7 @@
#include "ext2fs.h"
-errcode_t ext2fs_allocate_group_table(ext2_filsys fs, int group,
+errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
ext2fs_block_bitmap bmap)
{
errcode_t retval;
@@ -113,7 +113,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, int group,
errcode_t ext2fs_allocate_tables(ext2_filsys fs)
{
errcode_t retval;
- int i;
+ dgrp_t i;
for (i = 0; i < fs->group_desc_count; i++) {
retval = ext2fs_allocate_group_table(fs, i, fs->block_map);
diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c
index 72cbb4a8..91b5c4c0 100644
--- a/lib/ext2fs/block.c
+++ b/lib/ext2fs/block.c
@@ -330,7 +330,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
if (flags & BLOCK_FLAG_NO_LARGE) {
ctx.errcode = ext2fs_read_inode(fs, ino, &inode);
if (ctx.errcode)
- goto abort;
+ return ctx.errcode;
got_inode = 1;
if (!LINUX_S_ISDIR(inode.i_mode) &&
(inode.i_size_high != 0))
diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c
index e4cf92a0..ba3a114b 100644
--- a/lib/ext2fs/bmap.c
+++ b/lib/ext2fs/bmap.c
@@ -91,9 +91,9 @@ static errcode_t _BMAP_INLINE_ block_dind_bmap(ext2_filsys fs, int flags,
{
blk_t b;
errcode_t retval;
- int addr_per_block;
+ blk_t addr_per_block;
- addr_per_block = fs->blocksize >> 2;
+ addr_per_block = (blk_t) fs->blocksize >> 2;
retval = block_ind_bmap(fs, flags, dind, block_buf, blocks_alloc,
nr / addr_per_block, &b);
@@ -111,9 +111,9 @@ static errcode_t _BMAP_INLINE_ block_tind_bmap(ext2_filsys fs, int flags,
{
blk_t b;
errcode_t retval;
- int addr_per_block;
+ blk_t addr_per_block;
- addr_per_block = fs->blocksize >> 2;
+ addr_per_block = (blk_t) fs->blocksize >> 2;
retval = block_dind_bmap(fs, flags, tind, block_buf, blocks_alloc,
nr / addr_per_block, &b);
@@ -129,7 +129,7 @@ errcode_t ext2fs_bmap(ext2_filsys fs, ino_t ino, struct ext2_inode *inode,
blk_t *phys_blk)
{
struct ext2_inode inode_buf;
- int addr_per_block;
+ blk_t addr_per_block;
blk_t b;
char *buf = 0;
errcode_t retval = 0;
@@ -144,7 +144,7 @@ errcode_t ext2fs_bmap(ext2_filsys fs, ino_t ino, struct ext2_inode *inode,
return retval;
inode = &inode_buf;
}
- addr_per_block = fs->blocksize >> 2;
+ addr_per_block = (blk_t) fs->blocksize >> 2;
if (!block_buf) {
retval = ext2fs_get_mem(fs->blocksize * 2, (void **) &buf);
diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c
index b6365848..5a2a9641 100644
--- a/lib/ext2fs/dblist.c
+++ b/lib/ext2fs/dblist.c
@@ -34,7 +34,7 @@ static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b);
*/
errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ino_t *ret_num_dirs)
{
- int i;
+ dgrp_t i;
ino_t num_dirs, max_dirs;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -99,7 +99,10 @@ static errcode_t make_dblist(ext2_filsys fs, ino_t size, ino_t count,
memcpy(dblist->list, list, len);
else
memset(dblist->list, 0, len);
- *ret_dblist = dblist;
+ if (ret_dblist)
+ *ret_dblist = dblist;
+ else
+ fs->dblist = dblist;
return 0;
cleanup:
if (dblist)
@@ -191,7 +194,7 @@ errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ino_t ino, blk_t blk,
errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ino_t ino, blk_t blk,
int blockcnt)
{
- int i;
+ dgrp_t i;
EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
diff --git a/lib/ext2fs/dblist_dir.c b/lib/ext2fs/dblist_dir.c
index 7fd14e0a..d97ca95d 100644
--- a/lib/ext2fs/dblist_dir.c
+++ b/lib/ext2fs/dblist_dir.c
@@ -28,18 +28,17 @@
static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info,
void *priv_data);
-extern errcode_t
- ext2fs_dblist_dir_iterate(ext2_dblist dblist,
- int flags,
- char *block_buf,
- int (*func)(ino_t dir,
- int entry,
- struct ext2_dir_entry *dirent,
- int offset,
- int blocksize,
- char *buf,
- void *priv_data),
- void *priv_data)
+errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist,
+ int flags,
+ char *block_buf,
+ int (*func)(ino_t dir,
+ int entry,
+ struct ext2_dir_entry *dirent,
+ int offset,
+ int blocksize,
+ char *buf,
+ void *priv_data),
+ void *priv_data)
{
errcode_t retval;
struct dir_context ctx;
diff --git a/lib/ext2fs/dir_iterate.c b/lib/ext2fs/dir_iterate.c
index 9aff315d..10a136a7 100644
--- a/lib/ext2fs/dir_iterate.c
+++ b/lib/ext2fs/dir_iterate.c
@@ -72,12 +72,12 @@ errcode_t ext2fs_dir_iterate(ext2_filsys fs,
* Helper function which is private to this module. Used by
* ext2fs_dir_iterate() and ext2fs_dblist_dir_iterate()
*/
-extern int ext2fs_process_dir_block(ext2_filsys fs,
- blk_t *blocknr,
- e2_blkcnt_t blockcnt,
- blk_t ref_block,
- int ref_offset,
- void *priv_data)
+int ext2fs_process_dir_block(ext2_filsys fs,
+ blk_t *blocknr,
+ e2_blkcnt_t blockcnt,
+ blk_t ref_block,
+ int ref_offset,
+ void *priv_data)
{
struct dir_context *ctx = (struct dir_context *) priv_data;
int offset = 0;
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 29c439a7..dc270295 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -52,7 +52,7 @@ typedef unsigned long long __u64;
#endif
typedef __u32 blk_t;
-typedef unsigned int dgrp_t;
+typedef __u32 dgrp_t;
typedef __u32 ext2_off_t;
typedef __s64 e2_blkcnt_t;
@@ -177,7 +177,7 @@ struct struct_ext2_filsys {
struct ext2_super_block * super;
int blocksize;
int fragsize;
- unsigned long group_desc_count;
+ dgrp_t group_desc_count;
unsigned long desc_blocks;
struct ext2_group_desc * group_desc;
int inode_blocks_per_group;
@@ -480,7 +480,7 @@ extern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal,
/* alloc_tables.c */
extern errcode_t ext2fs_allocate_tables(ext2_filsys fs);
-extern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, int group,
+extern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
ext2fs_block_bitmap bmap);
/* badblocks.c */
diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
index 51375b78..98191f8a 100644
--- a/lib/ext2fs/fileio.c
+++ b/lib/ext2fs/fileio.c
@@ -310,7 +310,7 @@ ext2_off_t ext2fs_file_get_size(ext2_file_t file)
*
* XXX still need to call truncate
*/
-extern errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size)
+errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size)
{
errcode_t retval;
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
diff --git a/lib/ext2fs/get_pathname.c b/lib/ext2fs/get_pathname.c
index ddbc58aa..9a793a4c 100644
--- a/lib/ext2fs/get_pathname.c
+++ b/lib/ext2fs/get_pathname.c
@@ -59,8 +59,8 @@ static int get_pathname_proc(struct ext2_dir_entry *dirent,
if (dirent->inode == gp->search_ino) {
retval = ext2fs_get_mem((dirent->name_len & 0xFF) + 1,
(void **) &gp->name);
- if (!gp->name) {
- gp->errcode = EXT2_ET_NO_MEMORY;
+ if (retval) {
+ gp->errcode = retval;
return DIRENT_ABORT;
}
strncpy(gp->name, dirent->name, (dirent->name_len & 0xFF));
diff --git a/lib/ext2fs/namei.c b/lib/ext2fs/namei.c
index c9bf6ce7..ae19387a 100644
--- a/lib/ext2fs/namei.c
+++ b/lib/ext2fs/namei.c
@@ -189,7 +189,7 @@ errcode_t ext2fs_namei_follow(ext2_filsys fs, ino_t root, ino_t cwd,
return retval;
}
-extern errcode_t ext2fs_follow_link(ext2_filsys fs, ino_t root, ino_t cwd,
+errcode_t ext2fs_follow_link(ext2_filsys fs, ino_t root, ino_t cwd,
ino_t inode, ino_t *res_inode)
{
char *buf;
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 8ad93de0..73979fdb 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -57,7 +57,7 @@ void ext2fs_swap_bitmap(ext2_filsys fs, char *bitmap, int nbytes)
errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs)
{
- int i;
+ dgrp_t i;
size_t nbytes;
errcode_t retval;
char * inode_bitmap = fs->inode_map->bitmap;
@@ -100,7 +100,7 @@ errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs)
errcode_t ext2fs_write_block_bitmap (ext2_filsys fs)
{
- int i;
+ dgrp_t i;
int j;
int nbytes;
int nbits;
@@ -153,7 +153,7 @@ errcode_t ext2fs_write_block_bitmap (ext2_filsys fs)
static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
{
- int i;
+ dgrp_t i;
char *block_bitmap = 0, *inode_bitmap = 0;
char *buf;
errcode_t retval;