More gcc -Wflags
These patches enable gcc warning flags -Wendif-labels, -Wshadow and -Wpointer-arith. The other patches fix some of these warnings.
For -Wendif-labels there is nothing to fix, all code is clean. I'd enable this flag.
Enabling -Wshadow produces a lot of useless warnings about variables named 'index' etc, so I'm not proposing to add that. I might still fix the warnings for local variables shadowing each other, but maybe it's not worth the trouble and risk for new bugs.
Fixes for -Wpointer-arith are not too many, except for ARM devices. Maybe there the use of void * arithmetics is intentional? If Paul agrees that these should be fixed, I could make a patch that removes these warnings too. After that, the flag could be enabled.
Makefile.target +1 -1
@@ -73,7 +73,7 @@ PROGS=$(QEMU_PROG) # We require -O2 to avoid the stack setup prologue in EXIT_TB -OP_CFLAGS := -Wall -O2 -g -fno-strict-aliasing +OP_CFLAGS := -Wall -Wpointer-arith -O2 -g -fno-strict-aliasing # cc-option # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
configure +1 -1
@@ -346,7 +346,7 @@ done # default flags for all hosts -CFLAGS="$CFLAGS -Wall -O2 -g -fno-strict-aliasing" +CFLAGS="$CFLAGS -Wall -Wpointer-arith -O2 -g -fno-strict-aliasing" LDFLAGS="$LDFLAGS -g" if test "$werror" = "yes" ; then CFLAGS="$CFLAGS -Werror"
block-vvfat.c +1 -1
@@ -1523,7 +1523,7 @@uint16_t * entry=((uint16_t *)s->fat2)+cluster;return le16_to_cpu (*entry); }else { -const uint8_t * x=s->fat2+cluster*3 /2 ; +const uint8_t * x=((uint8_t *)s->fat2)+cluster*3 /2 ;return ((x[0 ]|(x[1 ]<<8 ))>>(cluster&1 ?4 :0 ))&0x0fff ; } }
hw/rtl8139.c +4 -1
@@ -752,6 +752,8 @@/* write packet data */ if (wrapped && !(s->RxBufferSize <65536 &&rtl8139_RxWrap (s))) { +const uint8_t *buffer; +DEBUG_PRINT ((">>> RTL8139: rx packet wrapped in buffer at %d\n" , size-wrapped));if (size > wrapped)
@@ -763,8 +765,9 @@/* reset buffer pointer */ s->RxBufAddr =0 ; + buffer = buf;cpu_physical_memory_write ( s->RxBuf + s->RxBufAddr, - buf + (size-wrapped), wrapped ); + &buffer[size-wrapped], wrapped ); s->RxBufAddr = wrapped;
linux-user/elfload.c +9 -9
@@ -993,10 +993,10 @@struct elf_shdr sechdr, symtab, strtab;char *strings;struct syminfo *s; +struct elf_sym *syms;#if (ELF_CLASS ==ELFCLASS64 )// Disas uses 32 bit symbols struct elf32_sym *syms32 =NULL ; -struct elf_sym *sym;#endif lseek (fd, hdr->e_shoff,SEEK_SET );
@@ -1037,18 +1037,18 @@if (read (fd, s->disas_symtab, symtab.sh_size) != symtab.sh_size)return ; + syms = s->disas_symtab;for (i =0 ; i < symtab.sh_size /sizeof (struct elf_sym ); i++) {#ifdef BSWAP_NEEDED -bswap_sym (s->disas_symtab +sizeof (struct elf_sym )*i); +bswap_sym (&syms[i]);#endif #if (ELF_CLASS ==ELFCLASS64 ) - sym = s->disas_symtab +sizeof (struct elf_sym )*i; - syms32[i].st_name = sym->st_name; - syms32[i].st_info = sym->st_info; - syms32[i].st_other = sym->st_other; - syms32[i].st_shndx = sym->st_shndx; - syms32[i].st_value = sym->st_value &0xffffffff ; - syms32[i].st_size = sym->st_size &0xffffffff ; + syms32[i].st_name = syms[i].st_name; + syms32[i].st_info = syms[i].st_info; + syms32[i].st_other = syms[i].st_other; + syms32[i].st_shndx = syms[i].st_shndx; + syms32[i].st_value = syms[i].st_value &0xffffffff ; + syms32[i].st_size = syms[i].st_size &0xffffffff ;#endif }
nbd.c +3 -2
@@ -75,11 +75,12 @@while (offset < size) {ssize_t len; +char *buf = buffer;if (do_read) { - len =read (fd, buffer + offset, size - offset); + len =read (fd, &buf[offset], size - offset); }else { - len =write (fd, buffer + offset, size - offset); + len =write (fd, &buf[offset], size - offset); }/* recoverable error */
hw/pflash_cfi01.c +4 -1
@@ -185,12 +185,15 @@ int size) {int offset_end; +uint8_t *buf; +if (pfl->bs) { offset_end = offset + size;/* round to sectors */ offset = offset >>9 ; offset_end = (offset_end +511 ) >>9 ; -bdrv_write (pfl->bs, offset, pfl->storage + (offset <<9 ), + buf = pfl->storage; +bdrv_write (pfl->bs, offset, &buf[offset <<9 ], offset_end - offset); } }
hw/pflash_cfi02.c +4 -1
@@ -214,12 +214,15 @@ int size) {int offset_end; +uint8_t *buf; +if (pfl->bs) { offset_end = offset + size;/* round to sectors */ offset = offset >>9 ; offset_end = (offset_end +511 ) >>9 ; -bdrv_write (pfl->bs, offset, pfl->storage + (offset <<9 ), + buf = pfl->storage; +bdrv_write (pfl->bs, offset, &buf[offset <<9 ], offset_end - offset); } }
Makefile.target +1 -1
@@ -73,7 +73,7 @@ PROGS=$(QEMU_PROG) # We require -O2 to avoid the stack setup prologue in EXIT_TB -OP_CFLAGS := -Wall -O2 -g -fno-strict-aliasing +OP_CFLAGS := -Wall -Wendif-labels -Wshadow -O2 -g -fno-strict-aliasing # cc-option # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
configure +1 -1
@@ -346,7 +346,7 @@ done # default flags for all hosts -CFLAGS="$CFLAGS -Wall -O2 -g -fno-strict-aliasing" +CFLAGS="$CFLAGS -Wall -Wendif-labels -Wshadow -O2 -g -fno-strict-aliasing" LDFLAGS="$LDFLAGS -g" if test "$werror" = "yes" ; then CFLAGS="$CFLAGS -Werror"
audio/audio.c +0 -1
@@ -1850,7 +1850,6 @@ }else {HWVoiceOut *hw; -CaptureVoiceOut *cap; cap =audio_calloc (AUDIO_FUNC ,1 ,sizeof (*cap));if (!cap) {
audio/ossaudio.c +0 -1
@@ -492,7 +492,6 @@oss_logerr (errno,"Failed to map %d bytes of DAC\n" , hw->samples << hw->info.shift); }else { -int err;int trig =0 ;if (ioctl (fd,SNDCTL_DSP_SETTRIGGER , &trig) <0 ) {oss_logerr (errno,"SNDCTL_DSP_SETTRIGGER 0 failed\n" );
block-vvfat.c +17 -20
@@ -644,7 +644,6 @@/* mangle duplicates */ while (1 ) {direntry_t * entry1=array_get (&(s->directory),directory_start); -int j;for (;entry1<entry;entry1++)if (!is_long_name (entry1) && !memcmp (entry1->name,entry->name,11 ))
@@ -654,7 +653,6 @@/* use all 8 characters of name */ if (entry->name[7 ]==' ' ) { -int j;for (j=6 ;j>0 && entry->name[j]==' ' ;j--) entry->name[j]='~' ; }
@@ -691,7 +689,6 @@static int read_directory (BDRVVVFATState * s,int mapping_index) {mapping_t * mapping =array_get (&(s->mapping), mapping_index); -direntry_t * direntry;const char * dirname = mapping->path;int first_cluster = mapping->begin;int parent_index = mapping->info.dir.parent_mapping_index;
@@ -702,6 +699,7 @@DIR * dir=opendir (dirname);struct dirent * entry;int i; +direntry_t * direntry;assert (mapping->mode &MODE_DIRECTORY );
@@ -717,7 +715,6 @@while ((entry=readdir (dir))) {unsigned int length=strlen (dirname)+2 +strlen (entry->d_name);char * buffer; -direntry_t * direntry;struct stat st;int is_dot=!strcmp (entry->d_name,"." );int is_dotdot=!strcmp (entry->d_name,".." );
@@ -786,7 +783,7 @@/* fill with zeroes up to the end of the cluster */ while (s->directory.next%(0x10 *s->sectors_per_cluster)) { -direntry_t * direntry=array_get_next (&(s->directory)); + direntry=array_get_next (&(s->directory));memset (direntry,0 ,sizeof (direntry_t)); }
@@ -1683,17 +1680,17 @@* This is horribly inefficient, but that is okay, since * it is rarely executed, if at all. */ -int64_t offset =cluster2sector (s, cluster_num); +int64_t offset2 =cluster2sector (s, cluster_num);vvfat_close_current_file (s);for (i =0 ; i < s->sectors_per_cluster; i++)if (!s->qcow->drv->bdrv_is_allocated (s->qcow, - offset + i,1 , &dummy)) { + offset2 + i,1 , &dummy)) {if (vvfat_read (s->bs, - offset, s->cluster_buffer,1 )) + offset2, s->cluster_buffer,1 ))return -1 ;if (s->qcow->drv->bdrv_write (s->qcow, - offset, s->cluster_buffer,1 )) + offset2, s->cluster_buffer,1 ))return -2 ; } }
@@ -2168,8 +2165,8 @@ factor * (old_cluster_count - new_cluster_count));for (c = first_cluster; !fat_eof (s, c); c =modified_fat_get (s, c)) { -void * direntry =array_get (&(s->directory), current_dir_index); -int ret =vvfat_read (s->bs,cluster2sector (s, c), direntry, + direntry =array_get (&(s->directory), current_dir_index); + ret =vvfat_read (s->bs,cluster2sector (s, c), direntry, s->sectors_per_cluster);if (ret)return ret;
@@ -2358,12 +2355,12 @@direntry_t * direntry =array_get (&(s->directory), mapping->info.dir.first_dir_index);uint32_t c = mapping->begin; -int i =0 ; +int diroffset =0 ;/* recurse */ while (!fat_eof (s, c)) { do { - direntry_t* d = direntry + i; + direntry_t* d = direntry + diroffset; if (is_file(d) || (is_directory(d) && !is_dot(d))) { mapping_t* m = find_mapping_for_cluster(s,
@@ -2379,8 +2376,8 @@schedule_rename (s, m->begin, new_path); } - i++; - }while ((i % (0x10 * s->sectors_per_cluster)) !=0 ); + diroffset++; + }while ((diroffset % (0x10 * s->sectors_per_cluster)) !=0 ); c =fat_get (s, c); } }
@@ -2471,16 +2468,16 @@int begin = commit->param.new_file.first_cluster;mapping_t * mapping =find_mapping_for_cluster (s, begin);direntry_t * entry; -int i; +int j;/* find direntry */ -for (i =0 ; i < s->directory.next; i++) { - entry =array_get (&(s->directory), i); +for (j =0 ; j < s->directory.next; j++) { + entry =array_get (&(s->directory), j);if (is_file (entry) &&begin_of_direntry (entry) == begin)break ; } -if (i >= s->directory.next) { +if (j >= s->directory.next) { fail =-6 ;continue ; }
@@ -2500,7 +2497,7 @@ mapping->mode =MODE_NORMAL ; mapping->info.file.offset =0 ; -if (commit_one_file (s, i,0 )) +if (commit_one_file (s, j,0 )) fail =-7 ;break ;
vnc.c +0 -1
@@ -745,7 +745,6 @@while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {size_t len = vs->read_handler_expect; -int ret; ret = vs->read_handler (vs, vs->input.buffer, len);if (vs->csock ==-1 )
tcg/tcg.c +0 -2
@@ -760,8 +760,6 @@ nb_iargs = def->nb_iargs; nb_cargs = def->nb_cargs; }else if (c == INDEX_op_call) { -TCGArg arg; -/* variable number of arguments */ arg = *args++; nb_oargs = arg >>16 ;
vl.c +3 -3
@@ -8687,9 +8687,9 @@break ;case QEMU_OPTION_echr: { -char *r; - term_escape_char =strtol (optarg, &r,0 ); -if (r == optarg) +char *optptr; + term_escape_char =strtol (optarg, &optptr,0 ); +if (optptr == optarg)printf ("Bad argument to echr\n" );break ; }
cpu-exec.c +0 -1
@@ -334,7 +334,6 @@ }#ifdef USE_KQEMU if (kqemu_is_ok (env) && env->interrupt_request ==0 ) { -int ret; env->eflags = env->eflags | cc_table[CC_OP ].compute_all () | (DF &DF_MASK ); ret =kqemu_cpu_exec (env);/* put eflags in CPU temporary format */
exec-all.h +12 -12
@@ -345,16 +345,16 @@/* Deterministic execution requires that IO only be performed on the last instruction of a TB so that interrupts take effect immediately. */ -static inline int can_do_io (CPUState *env) +static inline int can_do_io (CPUState *env1) {if (!use_icount)return 1 ;/* If not executing code then assume we are ok. */ -if (!env->current_tb) +if (!env1->current_tb)return 1 ; -return env->can_do_io !=0 ; +return env1->can_do_io !=0 ; }#endif
@@ -376,16 +376,16 @@extern uint32_t kqemu_comm_base; -static inline int kqemu_is_ok (CPUState *env) +static inline int kqemu_is_ok (CPUState *env1) { -return (env->kqemu_enabled && - (env->cr[0 ] &CR0_PE_MASK ) && - !(env->hflags &HF_INHIBIT_IRQ_MASK ) && - (env->eflags &IF_MASK ) && - !(env->eflags &VM_MASK ) && - (env->kqemu_enabled ==2 || - ((env->hflags &HF_CPL_MASK ) ==3 && - (env->eflags &IOPL_MASK ) !=IOPL_MASK ))); +return (env1->kqemu_enabled && + (env1->cr[0 ] &CR0_PE_MASK ) && + !(env1->hflags &HF_INHIBIT_IRQ_MASK ) && + (env1->eflags &IF_MASK ) && + !(env1->eflags &VM_MASK ) && + (env1->kqemu_enabled ==2 || + ((env1->hflags &HF_CPL_MASK ) ==3 && + (env1->eflags &IOPL_MASK ) !=IOPL_MASK ))); }#endif
target-sparc/op_helper.c +50 -50
166 lines not on this page · raw message
target-sparc/cpu.h +3 -3
@@ -475,11 +475,11 @@ }#if defined(CONFIG_USER_ONLY ) -static inline void cpu_clone_regs (CPUState *env,target_ulong newsp) +static inline void cpu_clone_regs (CPUState *env1,target_ulong newsp) {if (newsp) - env->regwptr[22 ] = newsp; - env->regwptr[0 ] =0 ; + env1->regwptr[22 ] = newsp; + env1->regwptr[0 ] =0 ;/* FIXME: Do we also need to clear CF? */ /* XXXXX */ printf ("HELPME: %s:%d\n" , __FILE__, __LINE__);