block: Drop some superfluous casts from void *

They clutter the code.  Unfortunately, I can't figure out how to make
Coccinelle drop all of them, so I have to settle for common special
cases:

    @@
    type T;
    T *pt;
    void *pv;
    @@
    - pt = (T *)pv;
    + pt = pv;
    @@
    type T;
    @@
    - (T *)
      (\(g_malloc\|g_malloc0\|g_realloc\|g_new\|g_new0\|g_renew\|
	 g_try_malloc\|g_try_malloc0\|g_try_realloc\|
	 g_try_new\|g_try_new0\|g_try_renew\)(...))

Topped off with minor manual style cleanups.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Markus Armbruster 2014-08-19 10:31:11 +02:00 committed by Kevin Wolf
parent 08193dd52b
commit d4df3dbc02
3 changed files with 6 additions and 6 deletions

View File

@ -923,7 +923,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s,
buffer = qemu_blockalign(bs, total_length); buffer = qemu_blockalign(bs, total_length);
memcpy(buffer, &new_hdr, sizeof(new_hdr)); memcpy(buffer, &new_hdr, sizeof(new_hdr));
new_desc = (VHDXLogDescriptor *) (buffer + sizeof(new_hdr)); new_desc = buffer + sizeof(new_hdr);
data_sector = buffer + (desc_sectors * VHDX_LOG_SECTOR_SIZE); data_sector = buffer + (desc_sectors * VHDX_LOG_SECTOR_SIZE);
data_tmp = data; data_tmp = data;

View File

@ -732,7 +732,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
if(first_cluster == 0 && (is_dotdot || is_dot)) if(first_cluster == 0 && (is_dotdot || is_dot))
continue; continue;
buffer=(char*)g_malloc(length); buffer = g_malloc(length);
snprintf(buffer,length,"%s/%s",dirname,entry->d_name); snprintf(buffer,length,"%s/%s",dirname,entry->d_name);
if(stat(buffer,&st)<0) { if(stat(buffer,&st)<0) {
@ -767,7 +767,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
/* create mapping for this file */ /* create mapping for this file */
if(!is_dot && !is_dotdot && (S_ISDIR(st.st_mode) || st.st_size)) { if(!is_dot && !is_dotdot && (S_ISDIR(st.st_mode) || st.st_size)) {
s->current_mapping=(mapping_t*)array_get_next(&(s->mapping)); s->current_mapping = array_get_next(&(s->mapping));
s->current_mapping->begin=0; s->current_mapping->begin=0;
s->current_mapping->end=st.st_size; s->current_mapping->end=st.st_size;
/* /*
@ -811,12 +811,12 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
} }
/* reget the mapping, since s->mapping was possibly realloc()ed */ /* reget the mapping, since s->mapping was possibly realloc()ed */
mapping = (mapping_t*)array_get(&(s->mapping), mapping_index); mapping = array_get(&(s->mapping), mapping_index);
first_cluster += (s->directory.next - mapping->info.dir.first_dir_index) first_cluster += (s->directory.next - mapping->info.dir.first_dir_index)
* 0x20 / s->cluster_size; * 0x20 / s->cluster_size;
mapping->end = first_cluster; mapping->end = first_cluster;
direntry = (direntry_t*)array_get(&(s->directory), mapping->dir_index); direntry = array_get(&(s->directory), mapping->dir_index);
set_begin_of_direntry(direntry, mapping->begin); set_begin_of_direntry(direntry, mapping->begin);
return 0; return 0;

View File

@ -567,7 +567,7 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *dinfo)
} }
md->bus.ifs[0].drive_kind = IDE_CFATA; md->bus.ifs[0].drive_kind = IDE_CFATA;
md->bus.ifs[0].mdata_size = METADATA_SIZE; md->bus.ifs[0].mdata_size = METADATA_SIZE;
md->bus.ifs[0].mdata_storage = (uint8_t *) g_malloc0(METADATA_SIZE); md->bus.ifs[0].mdata_storage = g_malloc0(METADATA_SIZE);
return PCMCIA_CARD(md); return PCMCIA_CARD(md);
} }