* grub-core/fs/zfs/zfs.c (dmu_read): Use void * for some pointers to
avoid aliasing. (fzap_lookup): Likewise. (dnode_get): Likewise. (make_mdn): Likewise. (zfs_mount): Likewise. (fzap_iterate): Use temporary pointer to avoid aliasing. (grub_zfs_read): Likewise. * grub-core/loader/i386/xnu.c (grub_xnu_boot): Likewise. * grub-core/loader/xnu.c (grub_cmd_xnu_kernel): Use void * for some pointers to avoid aliasing. (grub_cmd_xnu_kernel64): Likewise. (grub_xnu_load_driver): Likewise.
This commit is contained in:
parent
fc836af9a5
commit
e7121b6932
4 changed files with 63 additions and 33 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/zfs/zfs.c (dmu_read): Use void * for some pointers to
|
||||
avoid aliasing.
|
||||
(fzap_lookup): Likewise.
|
||||
(dnode_get): Likewise.
|
||||
(make_mdn): Likewise.
|
||||
(zfs_mount): Likewise.
|
||||
(fzap_iterate): Use temporary pointer to avoid aliasing.
|
||||
(grub_zfs_read): Likewise.
|
||||
* grub-core/loader/i386/xnu.c (grub_xnu_boot): Likewise.
|
||||
* grub-core/loader/xnu.c (grub_cmd_xnu_kernel): Use void * for some
|
||||
pointers to avoid aliasing.
|
||||
(grub_cmd_xnu_kernel64): Likewise.
|
||||
(grub_xnu_load_driver): Likewise.
|
||||
|
||||
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/commands/terminal.c (grub_cmd_terminal_input): Silence
|
||||
|
|
|
@ -603,7 +603,8 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
|
|||
int idx, level;
|
||||
blkptr_t *bp_array = dn->dn.dn_blkptr;
|
||||
int epbs = dn->dn.dn_indblkshift - SPA_BLKPTRSHIFT;
|
||||
blkptr_t *bp, *tmpbuf = 0;
|
||||
blkptr_t *bp;
|
||||
void *tmpbuf = 0;
|
||||
grub_zfs_endian_t endian;
|
||||
grub_err_t err = GRUB_ERR_NONE;
|
||||
|
||||
|
@ -646,7 +647,7 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
|
|||
break;
|
||||
}
|
||||
grub_dprintf ("zfs", "endian = %d\n", endian);
|
||||
err = zio_read (bp, endian, (void **) &tmpbuf, 0, data);
|
||||
err = zio_read (bp, endian, &tmpbuf, 0, data);
|
||||
endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1;
|
||||
if (err)
|
||||
break;
|
||||
|
@ -880,7 +881,7 @@ static grub_err_t
|
|||
fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap,
|
||||
char *name, grub_uint64_t * value, struct grub_zfs_data *data)
|
||||
{
|
||||
zap_leaf_phys_t *l;
|
||||
void *l;
|
||||
grub_uint64_t hash, idx, blkid;
|
||||
int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec,
|
||||
zap_dnode->endian) << DNODE_SHIFT);
|
||||
|
@ -903,7 +904,7 @@ fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap,
|
|||
/* Get the leaf block */
|
||||
if ((1U << blksft) < sizeof (zap_leaf_phys_t))
|
||||
return grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small");
|
||||
err = dmu_read (zap_dnode, blkid, (void **) &l, &leafendian, data);
|
||||
err = dmu_read (zap_dnode, blkid, &l, &leafendian, data);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -920,6 +921,7 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap,
|
|||
struct grub_zfs_data *data)
|
||||
{
|
||||
zap_leaf_phys_t *l;
|
||||
void *l_in;
|
||||
grub_uint64_t idx, blkid;
|
||||
grub_uint16_t chunk;
|
||||
int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec,
|
||||
|
@ -947,7 +949,8 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap,
|
|||
{
|
||||
blkid = ((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))];
|
||||
|
||||
err = dmu_read (zap_dnode, blkid, (void **) &l, &endian, data);
|
||||
err = dmu_read (zap_dnode, blkid, &l_in, &endian, data);
|
||||
l = l_in;
|
||||
if (err)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -1108,7 +1111,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type,
|
|||
grub_uint64_t blkid, blksz; /* the block id this object dnode is in */
|
||||
int epbs; /* shift of number of dnodes in a block */
|
||||
int idx; /* index within a block */
|
||||
dnode_phys_t *dnbuf;
|
||||
void *dnbuf;
|
||||
grub_err_t err;
|
||||
grub_zfs_endian_t endian;
|
||||
|
||||
|
@ -1131,7 +1134,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type,
|
|||
|
||||
grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian,
|
||||
(unsigned long long) blkid);
|
||||
err = dmu_read (mdn, blkid, (void **) &dnbuf, &endian, data);
|
||||
err = dmu_read (mdn, blkid, &dnbuf, &endian, data);
|
||||
if (err)
|
||||
return err;
|
||||
grub_dprintf ("zfs", "alive\n");
|
||||
|
@ -1153,7 +1156,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type,
|
|||
data->dnode_endian = endian;
|
||||
}
|
||||
|
||||
grub_memmove (&(buf->dn), &dnbuf[idx], DNODE_SIZE);
|
||||
grub_memmove (&(buf->dn), (dnode_phys_t *) dnbuf + idx, DNODE_SIZE);
|
||||
buf->endian = endian;
|
||||
if (type && buf->dn.dn_type != type)
|
||||
return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type");
|
||||
|
@ -1465,7 +1468,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname,
|
|||
static grub_err_t
|
||||
make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
|
||||
{
|
||||
objset_phys_t *osp;
|
||||
void *osp;
|
||||
blkptr_t *bp;
|
||||
grub_size_t ospsize;
|
||||
grub_err_t err;
|
||||
|
@ -1473,7 +1476,7 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
|
|||
grub_dprintf ("zfs", "endian = %d\n", mdn->endian);
|
||||
|
||||
bp = &(((dsl_dataset_phys_t *) DN_BONUS (&mdn->dn))->ds_bp);
|
||||
err = zio_read (bp, mdn->endian, (void **) &osp, &ospsize, data);
|
||||
err = zio_read (bp, mdn->endian, &osp, &ospsize, data);
|
||||
if (err)
|
||||
return err;
|
||||
if (ospsize < OBJSET_PHYS_SIZE_V14)
|
||||
|
@ -1483,7 +1486,8 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
|
|||
}
|
||||
|
||||
mdn->endian = (grub_zfs_to_cpu64 (bp->blk_prop, mdn->endian)>>63) & 1;
|
||||
grub_memmove ((char *) &(mdn->dn), (char *) &osp->os_meta_dnode, DNODE_SIZE);
|
||||
grub_memmove ((char *) &(mdn->dn),
|
||||
(char *) &((objset_phys_t *) osp)->os_meta_dnode, DNODE_SIZE);
|
||||
grub_free (osp);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -1960,7 +1964,7 @@ zfs_mount (grub_device_t dev)
|
|||
int label = 0;
|
||||
uberblock_phys_t *ub_array, *ubbest = NULL;
|
||||
vdev_boot_header_t *bh;
|
||||
objset_phys_t *osp = 0;
|
||||
void *osp = 0;
|
||||
grub_size_t ospsize;
|
||||
grub_err_t err;
|
||||
int vdevnum;
|
||||
|
@ -2038,7 +2042,7 @@ zfs_mount (grub_device_t dev)
|
|||
? LITTLE_ENDIAN : BIG_ENDIAN);
|
||||
err = zio_read (&ubbest->ubp_uberblock.ub_rootbp,
|
||||
ub_endian,
|
||||
(void **) &osp, &ospsize, data);
|
||||
&osp, &ospsize, data);
|
||||
if (err)
|
||||
{
|
||||
grub_dprintf ("zfs", "couldn't zio_read\n");
|
||||
|
@ -2067,7 +2071,8 @@ zfs_mount (grub_device_t dev)
|
|||
continue;
|
||||
#endif
|
||||
/* Got the MOS. Save it at the memory addr MOS. */
|
||||
grub_memmove (&(data->mos.dn), &osp->os_meta_dnode, DNODE_SIZE);
|
||||
grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode,
|
||||
DNODE_SIZE);
|
||||
data->mos.endian = (grub_zfs_to_cpu64 (ubbest->ubp_uberblock.ub_rootbp.blk_prop, ub_endian) >> 63) & 1;
|
||||
grub_memmove (&(data->current_uberblock),
|
||||
&ubbest->ubp_uberblock, sizeof (uberblock_t));
|
||||
|
@ -2201,7 +2206,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename)
|
|||
*/
|
||||
if (data->dnode.dn.dn_bonustype == DMU_OT_SA)
|
||||
{
|
||||
sa_hdr_phys_t *sahdrp;
|
||||
void *sahdrp;
|
||||
int hdrsize;
|
||||
|
||||
if (data->dnode.dn.dn_bonuslen != 0)
|
||||
|
@ -2212,7 +2217,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename)
|
|||
{
|
||||
blkptr_t *bp = &data->dnode.dn.dn_spill;
|
||||
|
||||
err = zio_read (bp, data->dnode.endian, (void **) &sahdrp, NULL, data);
|
||||
err = zio_read (bp, data->dnode.endian, &sahdrp, NULL, data);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
@ -2221,7 +2226,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename)
|
|||
return grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt");
|
||||
}
|
||||
|
||||
hdrsize = SA_HDR_SIZE (sahdrp);
|
||||
hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp));
|
||||
file->size = *(grub_uint64_t *) ((char *) sahdrp + hdrsize + SA_SIZE_OFFSET);
|
||||
}
|
||||
else
|
||||
|
@ -2280,6 +2285,7 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
|
|||
read = 0;
|
||||
while (length)
|
||||
{
|
||||
void *t;
|
||||
/*
|
||||
* Find requested blkid and the offset within that block.
|
||||
*/
|
||||
|
@ -2287,8 +2293,9 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
|
|||
grub_free (data->file_buf);
|
||||
data->file_buf = 0;
|
||||
|
||||
err = dmu_read (&(data->dnode), blkid, (void **) &(data->file_buf),
|
||||
err = dmu_read (&(data->dnode), blkid, &t,
|
||||
0, data);
|
||||
data->file_buf = t;
|
||||
if (err)
|
||||
return -1;
|
||||
|
||||
|
|
|
@ -951,10 +951,11 @@ grub_err_t
|
|||
grub_xnu_boot (void)
|
||||
{
|
||||
struct grub_xnu_boot_params *bootparams;
|
||||
void *bp_in;
|
||||
grub_addr_t bootparams_target;
|
||||
grub_err_t err;
|
||||
grub_efi_uintn_t memory_map_size = 0;
|
||||
grub_efi_memory_descriptor_t *memory_map;
|
||||
void *memory_map;
|
||||
grub_addr_t memory_map_target;
|
||||
grub_efi_uintn_t map_key = 0;
|
||||
grub_efi_uintn_t descriptor_size = 0;
|
||||
|
@ -1006,9 +1007,10 @@ grub_xnu_boot (void)
|
|||
|
||||
/* Relocate the boot parameters to heap. */
|
||||
err = grub_xnu_heap_malloc (sizeof (*bootparams),
|
||||
(void **) &bootparams, &bootparams_target);
|
||||
&bp_in, &bootparams_target);
|
||||
if (err)
|
||||
return err;
|
||||
bootparams = bp_in;
|
||||
|
||||
/* Set video. */
|
||||
err = grub_xnu_set_video (bootparams);
|
||||
|
@ -1035,7 +1037,7 @@ grub_xnu_boot (void)
|
|||
memory map growth. */
|
||||
memory_map_size += 20 * descriptor_size;
|
||||
err = grub_xnu_heap_malloc (memory_map_size,
|
||||
(void **) &memory_map, &memory_map_target);
|
||||
&memory_map, &memory_map_target);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -1109,7 +1111,7 @@ grub_xnu_boot (void)
|
|||
grub_xnu_arg1 = bootparams_target;
|
||||
|
||||
grub_autoefi_set_virtual_address_map (memory_map_size, descriptor_size,
|
||||
descriptor_version,memory_map);
|
||||
descriptor_version, memory_map);
|
||||
|
||||
state.eip = grub_xnu_entry_point;
|
||||
state.eax = grub_xnu_arg1;
|
||||
|
|
|
@ -342,7 +342,8 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_macho_t macho;
|
||||
grub_uint32_t startcode, endcode;
|
||||
int i;
|
||||
char *ptr, *loadaddr;
|
||||
char *ptr;
|
||||
void *loadaddr;
|
||||
grub_addr_t loadaddr_target;
|
||||
|
||||
if (argc < 1)
|
||||
|
@ -375,7 +376,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (!grub_xnu_relocator)
|
||||
return grub_errno;
|
||||
grub_xnu_heap_target_start = startcode;
|
||||
err = grub_xnu_heap_malloc (endcode - startcode, (void **) &loadaddr,
|
||||
err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr,
|
||||
&loadaddr_target);
|
||||
|
||||
if (err)
|
||||
|
@ -386,7 +387,8 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
/* Load kernel. */
|
||||
err = grub_macho_load32 (macho, loadaddr - startcode, GRUB_MACHO_NOBSS);
|
||||
err = grub_macho_load32 (macho, (char *) loadaddr - startcode,
|
||||
GRUB_MACHO_NOBSS);
|
||||
if (err)
|
||||
{
|
||||
grub_macho_close (macho);
|
||||
|
@ -450,7 +452,8 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_macho_t macho;
|
||||
grub_uint64_t startcode, endcode;
|
||||
int i;
|
||||
char *ptr, *loadaddr;
|
||||
char *ptr;
|
||||
void *loadaddr;
|
||||
grub_addr_t loadaddr_target;
|
||||
|
||||
if (argc < 1)
|
||||
|
@ -486,7 +489,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (!grub_xnu_relocator)
|
||||
return grub_errno;
|
||||
grub_xnu_heap_target_start = startcode;
|
||||
err = grub_xnu_heap_malloc (endcode - startcode, (void **) &loadaddr,
|
||||
err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr,
|
||||
&loadaddr_target);
|
||||
|
||||
if (err)
|
||||
|
@ -497,7 +500,8 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
/* Load kernel. */
|
||||
err = grub_macho_load64 (macho, loadaddr - startcode, GRUB_MACHO_NOBSS);
|
||||
err = grub_macho_load64 (macho, (char *) loadaddr - startcode,
|
||||
GRUB_MACHO_NOBSS);
|
||||
if (err)
|
||||
{
|
||||
grub_macho_close (macho);
|
||||
|
@ -636,7 +640,8 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
|
|||
grub_file_t infoplist;
|
||||
struct grub_xnu_extheader *exthead;
|
||||
int neededspace = sizeof (*exthead);
|
||||
grub_uint8_t *buf, *buf0;
|
||||
grub_uint8_t *buf;
|
||||
void *buf0;
|
||||
grub_addr_t buf_target;
|
||||
grub_size_t infoplistsize = 0, machosize = 0;
|
||||
char *name, *nameend;
|
||||
|
@ -692,7 +697,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
|
|||
err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
|
||||
if (err)
|
||||
return err;
|
||||
err = grub_xnu_heap_malloc (neededspace, (void **) &buf0, &buf_target);
|
||||
err = grub_xnu_heap_malloc (neededspace, &buf0, &buf_target);
|
||||
if (err)
|
||||
return err;
|
||||
buf = buf0;
|
||||
|
@ -704,7 +709,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
|
|||
/* Load the binary. */
|
||||
if (macho)
|
||||
{
|
||||
exthead->binaryaddr = buf_target + (buf - buf0);
|
||||
exthead->binaryaddr = buf_target + (buf - (grub_uint8_t *) buf0);
|
||||
exthead->binarysize = machosize;
|
||||
if (grub_xnu_is_64bit)
|
||||
err = grub_macho_readfile64 (macho, buf);
|
||||
|
@ -723,7 +728,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
|
|||
/* Load the plist. */
|
||||
if (infoplist)
|
||||
{
|
||||
exthead->infoplistaddr = buf_target + (buf - buf0);
|
||||
exthead->infoplistaddr = buf_target + (buf - (grub_uint8_t *) buf0);
|
||||
exthead->infoplistsize = infoplistsize + 1;
|
||||
if (grub_file_read (infoplist, buf, infoplistsize)
|
||||
!= (grub_ssize_t) (infoplistsize))
|
||||
|
@ -739,7 +744,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
|
|||
}
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
exthead->nameaddr = (buf - buf0) + buf_target;
|
||||
exthead->nameaddr = (buf - (grub_uint8_t *) buf0) + buf_target;
|
||||
exthead->namesize = namelen + 1;
|
||||
grub_memcpy (buf, name, namelen);
|
||||
buf[namelen] = 0;
|
||||
|
|
Loading…
Reference in a new issue