Fix few obvious type discrepancies.

* grub-core/fs/affs.c (grub_affs_read_file): Use grub_off_t for offset.
	* grub-core/fs/afs.c (grub_afs_read_file): Likewise.
	* grub-core/fs/fshelp.c (grub_fshelp_find_file): Remove leftover
	variable.
	* grub-core/fs/hfs.c (grub_hfs_read_file): Use grub_off_t for offset
	and connected types.
	* grub-core/fs/nilfs2.c (grub_nilfs2_read_file): Use grub_off_t for
	offset.
	(grub_nilfs2_iterate_dir): Use grub_off_t for fpos.
	* grub-core/fs/sfs.c (grub_sfs_read_file): Use grub_off_t for offset.
	* grub-core/fs/ufs.c (grub_ufs_read_file): Use grub_off_t for offset
	and connected types.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-10-16 11:57:48 +02:00
parent 177b960ea4
commit 366e34fa5a
8 changed files with 48 additions and 27 deletions

View file

@ -1,3 +1,20 @@
2011-10-16 Vladimir Serbinenko <phcoder@gmail.com>
Fix few obvious type discrepancies.
* grub-core/fs/affs.c (grub_affs_read_file): Use grub_off_t for offset.
* grub-core/fs/afs.c (grub_afs_read_file): Likewise.
* grub-core/fs/fshelp.c (grub_fshelp_find_file): Remove leftover
variable.
* grub-core/fs/hfs.c (grub_hfs_read_file): Use grub_off_t for offset
and connected types.
* grub-core/fs/nilfs2.c (grub_nilfs2_read_file): Use grub_off_t for
offset.
(grub_nilfs2_iterate_dir): Use grub_off_t for fpos.
* grub-core/fs/sfs.c (grub_sfs_read_file): Use grub_off_t for offset.
* grub-core/fs/ufs.c (grub_ufs_read_file): Use grub_off_t for offset
and connected types.
2011-10-16 Vladimir Serbinenko <phcoder@gmail.com> 2011-10-16 Vladimir Serbinenko <phcoder@gmail.com>
Fix python 3.x incompatibilities. Fix python 3.x incompatibilities.

View file

@ -160,7 +160,7 @@ static grub_ssize_t
grub_affs_read_file (grub_fshelp_node_t node, grub_affs_read_file (grub_fshelp_node_t node,
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector, void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
unsigned offset, unsigned length), unsigned offset, unsigned length),
int pos, grub_size_t len, char *buf) grub_off_t pos, grub_size_t len, char *buf)
{ {
return grub_fshelp_read_file (node->data->disk, node, read_hook, return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_affs_read_block, pos, len, buf, grub_affs_read_block,

View file

@ -336,7 +336,7 @@ static grub_ssize_t
grub_afs_read_file (grub_fshelp_node_t node, grub_afs_read_file (grub_fshelp_node_t node,
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector, void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
unsigned offset, unsigned length), unsigned offset, unsigned length),
int pos, grub_size_t len, char *buf) grub_off_t pos, grub_size_t len, char *buf)
{ {
return grub_fshelp_read_file (node->data->disk, node, read_hook, return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_afs_read_block, pos, len, buf, grub_afs_read_block,

View file

@ -61,7 +61,6 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
char fpath[grub_strlen (currpath) + 1]; char fpath[grub_strlen (currpath) + 1];
char *name = fpath; char *name = fpath;
char *next; char *next;
// unsigned int pos = 0;
enum grub_fshelp_filetype type = GRUB_FSHELP_DIR; enum grub_fshelp_filetype type = GRUB_FSHELP_DIR;
grub_fshelp_node_t currnode = currroot; grub_fshelp_node_t currnode = currroot;
grub_fshelp_node_t oldnode = currroot; grub_fshelp_node_t oldnode = currroot;

View file

@ -244,22 +244,24 @@ static grub_ssize_t
grub_hfs_read_file (struct grub_hfs_data *data, grub_hfs_read_file (struct grub_hfs_data *data,
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector, void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
unsigned offset, unsigned length), unsigned offset, unsigned length),
int pos, grub_size_t len, char *buf) grub_off_t pos, grub_size_t len, char *buf)
{ {
int i; grub_off_t i;
int blockcnt; grub_off_t blockcnt;
blockcnt = ((len + pos) blockcnt = grub_divmod64 (((len + pos)
+ data->blksz - 1) / data->blksz; + data->blksz - 1), data->blksz, 0);
for (i = pos / data->blksz; i < blockcnt; i++) for (i = grub_divmod64 (pos, data->blksz, 0); i < blockcnt; i++)
{ {
int blknr; grub_disk_addr_t blknr;
int blockoff = pos % data->blksz; grub_off_t blockoff;
int blockend = data->blksz; grub_off_t blockend = data->blksz;
int skipfirst = 0; int skipfirst = 0;
grub_divmod64 (pos, data->blksz, &blockoff);
blknr = grub_hfs_block (data, data->extents, data->fileid, i, 1); blknr = grub_hfs_block (data, data->extents, data->fileid, i, 1);
if (grub_errno) if (grub_errno)
return -1; return -1;
@ -267,7 +269,7 @@ grub_hfs_read_file (struct grub_hfs_data *data,
/* Last block. */ /* Last block. */
if (i == blockcnt - 1) if (i == blockcnt - 1)
{ {
blockend = (len + pos) % data->blksz; grub_divmod64 ((len + pos), data->blksz, &blockend);
/* The last portion is exactly EXT2_BLOCK_SIZE (data). */ /* The last portion is exactly EXT2_BLOCK_SIZE (data). */
if (! blockend) if (! blockend)
@ -275,7 +277,7 @@ grub_hfs_read_file (struct grub_hfs_data *data,
} }
/* First block. */ /* First block. */
if (i == pos / data->blksz) if (i == grub_divmod64 (pos, data->blksz, 0))
{ {
skipfirst = blockoff; skipfirst = blockoff;
blockend -= skipfirst; blockend -= skipfirst;

View file

@ -628,7 +628,7 @@ grub_nilfs2_read_file (grub_fshelp_node_t node,
sector, sector,
unsigned offset, unsigned offset,
unsigned length), unsigned length),
int pos, grub_size_t len, char *buf) grub_off_t pos, grub_size_t len, char *buf)
{ {
return grub_fshelp_read_file (node->data->disk, node, read_hook, return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_nilfs2_read_block, pos, len, buf, grub_nilfs2_read_block,
@ -866,7 +866,7 @@ grub_nilfs2_iterate_dir (grub_fshelp_node_t dir,
enum grub_fshelp_filetype filetype, enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node)) grub_fshelp_node_t node))
{ {
unsigned int fpos = 0; grub_off_t fpos = 0;
struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir; struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
if (!diro->inode_read) if (!diro->inode_read)

View file

@ -250,7 +250,7 @@ static grub_ssize_t
grub_sfs_read_file (grub_fshelp_node_t node, grub_sfs_read_file (grub_fshelp_node_t node,
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector, void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
unsigned offset, unsigned length), unsigned offset, unsigned length),
int pos, grub_size_t len, char *buf) grub_off_t pos, grub_size_t len, char *buf)
{ {
return grub_fshelp_read_file (node->data->disk, node, read_hook, return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_sfs_read_block, pos, len, buf, grub_sfs_read_block,

View file

@ -285,26 +285,29 @@ static grub_ssize_t
grub_ufs_read_file (struct grub_ufs_data *data, grub_ufs_read_file (struct grub_ufs_data *data,
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector, void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
unsigned offset, unsigned length), unsigned offset, unsigned length),
int pos, grub_size_t len, char *buf) grub_off_t pos, grub_size_t len, char *buf)
{ {
struct grub_ufs_sblock *sblock = &data->sblock; struct grub_ufs_sblock *sblock = &data->sblock;
int i; grub_off_t i;
int blockcnt; grub_off_t blockcnt;
/* Adjust len so it we can't read past the end of the file. */ /* Adjust len so it we can't read past the end of the file. */
if (len + pos > INODE_SIZE (data)) if (len + pos > INODE_SIZE (data))
len = INODE_SIZE (data) - pos; len = INODE_SIZE (data) - pos;
blockcnt = (len + pos + UFS_BLKSZ (sblock) - 1) / UFS_BLKSZ (sblock); blockcnt = grub_divmod64 ((len + pos + UFS_BLKSZ (sblock) - 1),
UFS_BLKSZ (sblock), 0);
for (i = pos / UFS_BLKSZ (sblock); i < blockcnt; i++) for (i = grub_divmod64 (pos, UFS_BLKSZ (sblock), 0); i < blockcnt; i++)
{ {
int blknr; grub_disk_addr_t blknr;
int blockoff = pos % UFS_BLKSZ (sblock); grub_off_t blockoff;
int blockend = UFS_BLKSZ (sblock); grub_off_t blockend = UFS_BLKSZ (sblock);
int skipfirst = 0; int skipfirst = 0;
grub_divmod64 (pos, UFS_BLKSZ (sblock), &blockoff);
blknr = grub_ufs_get_file_block (data, i); blknr = grub_ufs_get_file_block (data, i);
if (grub_errno) if (grub_errno)
return -1; return -1;
@ -312,14 +315,14 @@ grub_ufs_read_file (struct grub_ufs_data *data,
/* Last block. */ /* Last block. */
if (i == blockcnt - 1) if (i == blockcnt - 1)
{ {
blockend = (len + pos) % UFS_BLKSZ (sblock); grub_divmod64 (len + pos, UFS_BLKSZ (sblock), &blockend);
if (!blockend) if (!blockend)
blockend = UFS_BLKSZ (sblock); blockend = UFS_BLKSZ (sblock);
} }
/* First block. */ /* First block. */
if (i == (pos / (int) UFS_BLKSZ (sblock))) if (i == grub_divmod64 (pos, UFS_BLKSZ (sblock), 0))
{ {
skipfirst = blockoff; skipfirst = blockoff;
blockend -= skipfirst; blockend -= skipfirst;