[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/5] [ioemu]: char* casts
Not all signedness pointer issues can be fixed by declaration, sometimes casts are necessary (mostly char* vs. uint8_t*). -- Andre Przywara AMD-Operating System Research Center (OSRC), Dresden, Germany Tel: +49 351 277-84917 ----to satisfy European Law for business letters: AMD Saxony Limited Liability Company & Co. KG, Wilschdorfer Landstr. 101, 01109 Dresden, Germany Register Court Dresden: HRA 4896, General Partner authorized to represent: AMD Saxony LLC (Wilmington, Delaware, US) General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy diff -r 0f0d67f29ccb tools/ioemu/block-vpc.c --- a/tools/ioemu/block-vpc.c Fri Dec 21 23:58:29 2007 +0100 +++ b/tools/ioemu/block-vpc.c Tue Jan 08 14:48:38 2008 +0100 @@ -81,7 +81,7 @@ typedef struct BDRVVPCState { static int vpc_probe(const uint8_t *buf, int buf_size, const char *filename) { - if (buf_size >= 8 && !strncmp(buf, "conectix", 8)) + if (buf_size >= 8 && !strncmp((char *)buf, "conectix", 8)) return 100; return 0; } diff -r 0f0d67f29ccb tools/ioemu/block-vvfat.c --- a/tools/ioemu/block-vvfat.c Fri Dec 21 23:58:29 2007 +0100 +++ b/tools/ioemu/block-vvfat.c Tue Jan 08 14:48:38 2008 +0100 @@ -530,7 +530,7 @@ static inline uint32_t fat_get(BDRVVVFAT uint16_t* entry=array_get(&(s->fat),cluster); return le16_to_cpu(*entry); } else { - const uint8_t* x=s->fat.pointer+cluster*3/2; + const uint8_t* x=(uint8_t*)(s->fat.pointer)+cluster*3/2; return ((x[0]|(x[1]<<8))>>(cluster&1?4:0))&0x0fff; } } @@ -591,7 +591,7 @@ static inline direntry_t* create_short_a entry=array_get_next(&(s->directory)); memset(entry->name,0x20,11); - strncpy(entry->name,filename,i); + strncpy((char*)entry->name,filename,i); if(j > 0) for (i = 0; i < 3 && filename[j+1+i]; i++) @@ -833,7 +833,7 @@ static int init_directories(BDRVVVFATSta { direntry_t* entry=array_get_next(&(s->directory)); entry->attributes=0x28; /* archive | volume label */ - snprintf(entry->name,11,"QEMU VVFAT"); + snprintf((char*)entry->name,11,"QEMU VVFAT"); } /* Now build FAT, and write back information into directory */ @@ -1150,7 +1150,7 @@ static inline int read_cluster(BDRVVVFAT s->current_mapping = mapping; read_cluster_directory: offset = s->cluster_size*(cluster_num-s->current_mapping->begin); - s->cluster = s->directory.pointer+offset + s->cluster = (unsigned char*)s->directory.pointer+offset + 0x20*s->current_mapping->info.dir.first_dir_index; assert(((s->cluster-(unsigned char*)s->directory.pointer)%s->cluster_size)==0); assert((char*)s->cluster+s->cluster_size <= s->directory.pointer+s->directory.next*s->directory.item_size); @@ -1420,7 +1420,7 @@ static int parse_long_name(long_file_nam } if (pointer[0] & 0x40) - lfn->len = offset + strlen(lfn->name + offset); + lfn->len = offset + strlen((char*)lfn->name + offset); return 0; } @@ -1459,7 +1459,7 @@ static int parse_short_name(BDRVVVFATSta } else lfn->name[i + j + 1] = '\0'; - lfn->len = strlen(lfn->name); + lfn->len = strlen((char*)lfn->name); return 0; } @@ -1755,8 +1755,8 @@ DLOG(fprintf(stderr, "check direntry %d: fprintf(stderr, "Error in short name (%d)\n", subret); goto fail; } - if (subret > 0 || !strcmp(lfn.name, ".") - || !strcmp(lfn.name, "..")) + if (subret > 0 || !strcmp((char*)lfn.name, ".") + || !strcmp((char*)lfn.name, "..")) continue; } lfn.checksum = 0x100; /* cannot use long name twice */ @@ -1765,7 +1765,7 @@ DLOG(fprintf(stderr, "check direntry %d: fprintf(stderr, "Name too long: %s/%s\n", path, lfn.name); goto fail; } - strcpy(path2 + path_len + 1, lfn.name); + strcpy(path2 + path_len + 1, (char*)lfn.name); if (is_directory(direntries + i)) { if (begin_of_direntry(direntries + i) == 0) { @@ -2197,7 +2197,7 @@ static int commit_one_file(BDRVVVFATStat assert(size >= 0); ret = vvfat_read(s->bs, cluster2sector(s, c), - cluster, (rest_size + 0x1ff) / 0x200); + (uint8_t*)cluster, (rest_size + 0x1ff) / 0x200); if (ret < 0) return ret; diff -r 0f0d67f29ccb tools/ioemu/gdbstub.c --- a/tools/ioemu/gdbstub.c Fri Dec 21 23:58:29 2007 +0100 +++ b/tools/ioemu/gdbstub.c Tue Jan 08 14:48:38 2008 +0100 @@ -206,7 +206,7 @@ static int put_packet(GDBState *s, char *(p++) = tohex((csum) & 0xf); s->last_packet_len = p - s->last_packet; - put_buffer(s, s->last_packet, s->last_packet_len); + put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); #ifdef CONFIG_USER_ONLY i = get_char(s); @@ -992,7 +992,7 @@ static void gdb_read_byte(GDBState *s, i #ifdef DEBUG_GDB printf("Got NACK, retransmitting\n"); #endif - put_buffer(s, s->last_packet, s->last_packet_len); + put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); } #ifdef DEBUG_GDB else if (ch == '+') diff -r 0f0d67f29ccb tools/ioemu/hw/ide.c --- a/tools/ioemu/hw/ide.c Fri Dec 21 23:58:29 2007 +0100 +++ b/tools/ioemu/hw/ide.c Tue Jan 08 14:48:38 2008 +0100 @@ -614,12 +614,12 @@ static void ide_identify(IDEState *s) put_le16(p + 5, 512); /* XXX: retired, remove ? */ put_le16(p + 6, s->sectors); snprintf(buf, sizeof(buf), "QM%05d", s->drive_serial); - padstr((uint8_t *)(p + 10), buf, 20); /* serial number */ + padstr((char *)(p + 10), buf, 20); /* serial number */ put_le16(p + 20, 3); /* XXX: retired, remove ? */ put_le16(p + 21, 512); /* cache size in sectors */ put_le16(p + 22, 4); /* ecc bytes */ - padstr((uint8_t *)(p + 23), QEMU_VERSION, 8); /* firmware version */ - padstr((uint8_t *)(p + 27), "QEMU HARDDISK", 40); /* model */ + padstr((char *)(p + 23), QEMU_VERSION, 8); /* firmware version */ + padstr((char *)(p + 27), "QEMU HARDDISK", 40); /* model */ #if MAX_MULT_SECTORS > 1 put_le16(p + 47, 0x8000 | MAX_MULT_SECTORS); #endif @@ -680,12 +680,12 @@ static void ide_atapi_identify(IDEState /* Removable CDROM, 50us response, 12 byte packets */ put_le16(p + 0, (2 << 14) | (5 << 8) | (1 << 7) | (2 << 5) | (0 << 0)); snprintf(buf, sizeof(buf), "QM%05d", s->drive_serial); - padstr((uint8_t *)(p + 10), buf, 20); /* serial number */ + padstr((char *)(p + 10), buf, 20); /* serial number */ put_le16(p + 20, 3); /* buffer type */ put_le16(p + 21, 512); /* cache size in sectors */ put_le16(p + 22, 4); /* ecc bytes */ - padstr((uint8_t *)(p + 23), QEMU_VERSION, 8); /* firmware version */ - padstr((uint8_t *)(p + 27), "QEMU CD-ROM", 40); /* model */ + padstr((char *)(p + 23), QEMU_VERSION, 8); /* firmware version */ + padstr((char *)(p + 27), "QEMU CD-ROM", 40); /* model */ put_le16(p + 48, 1); /* dword I/O (XXX: should not be set on CDROM) */ #ifdef USE_DMA_CDROM put_le16(p + 49, 1 << 9 | 1 << 8); /* DMA and LBA supported */ diff -r 0f0d67f29ccb tools/ioemu/vl.c --- a/tools/ioemu/vl.c Fri Dec 21 23:58:29 2007 +0100 +++ b/tools/ioemu/vl.c Tue Jan 08 14:48:38 2008 +0100 @@ -1236,7 +1236,7 @@ void qemu_chr_printf(CharDriverState *s, va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); - qemu_chr_write(s, buf, strlen(buf)); + qemu_chr_write(s, (uint8_t *)buf, strlen(buf)); va_end(ap); } @@ -1650,7 +1650,7 @@ static int stdio_write(CharDriverState * (secs / 60) % 60, secs % 60, (int)((ti / 1000000) % 1000)); - unix_write(s->fd_out, buf1, strlen(buf1)); + unix_write(s->fd_out, (uint8_t *)buf1, strlen(buf1)); } } return len; @@ -4845,7 +4846,7 @@ int qemu_savevm_state(QEMUFile *f) /* ID string */ len = strlen(se->idstr); qemu_put_byte(f, len); - qemu_put_buffer(f, se->idstr, len); + qemu_put_buffer(f, (uint8_t *)se->idstr, len); qemu_put_be32(f, se->instance_id); qemu_put_be32(f, se->version_id); @@ -4907,7 +4908,7 @@ int qemu_loadvm_state(QEMUFile *f) if (qemu_ftell(f) >= end_pos) break; len = qemu_get_byte(f); - qemu_get_buffer(f, idstr, len); + qemu_get_buffer(f, (uint8_t *)idstr, len); idstr[len] = '\0'; instance_id = qemu_get_be32(f); version_id = qemu_get_be32(f); diff -r 0f0d67f29ccb tools/ioemu/vnc.c --- a/tools/ioemu/vnc.c Fri Dec 21 23:58:29 2007 +0100 +++ b/tools/ioemu/vnc.c Tue Jan 08 14:48:38 2008 +0100 @@ -1458,7 +1458,7 @@ static int protocol_client_msg(VncState return 8 + v; } - client_cut_text(vs, read_u32(data, 4), (char *)(data + 8)); + client_cut_text(vs, read_u32(data, 4), data + 8); break; default: printf("Msg: %d\n", data[0]); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |