Skip to contentSkip to conversation

Fix warnings in mips_r4k.c

PATCH In review Dirk Behme 2 participants 4 messages Jul 31, 2006

lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

PATCH 1/1 Fix warnings in mips_r4k.c

Fix warnings

hw/mips_r4k.c: In function ‘mips_r4kc_init’:
hw/mips_r4k.c:230: warning: pointer targets in passing argument 3 of ‘load_elf’ differ in signedness hw/mips_r4k.c:256: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness

hw/mips_r4k.c renamed from hw/mips_r4k.c_orig +2 -2
@@ -195,7 +195,7 @@ void mips_r4kc_init (int ram_size, int v
                      const char *initrd_filename)
 {
     char buf[1024];
-    int64_t entry = 0;
+    uint64_t entry = 0;
     unsigned long bios_offset;
     int io_memory;
     int ret;
@@ -253,7 +253,7 @@ void mips_r4kc_init (int ram_size, int v
         }
 
 	/* Store command line.  */
-        strcpy (phys_ram_base + (16 << 20) - 256, kernel_cmdline);
+        strcpy ((char *)phys_ram_base + (16 << 20) - 256, kernel_cmdline);
         /* FIXME: little endian support */
         *(int *)(phys_ram_base + (16 << 20) - 260) = tswap32 (0x12345678);
         *(int *)(phys_ram_base + (16 << 20) - 264) = tswap32 (ram_size);
#1 lore raw
Quoted 7 lines · Dirk Behme

Fix warnings

hw/mips_r4k.c: In function ‘mips_r4kc_init’:
hw/mips_r4k.c:230: warning: pointer targets in passing argument 3 of ‘load_elf’ differ in signedness hw/mips_r4k.c:256: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness

Compile with -Wno-pointer-sign. gcc4 isn't really supported anyway.

Paul

author
#2 lore raw
Quoted 11 lines · Paul Brook
Quoted 7 lines · Dirk Behme

Fix warnings

hw/mips_r4k.c: In function ‘mips_r4kc_init’:
hw/mips_r4k.c:230: warning: pointer targets in passing argument 3 of ‘load_elf’ differ in signedness hw/mips_r4k.c:256: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness

Compile with -Wno-pointer-sign. gcc4 isn't really supported anyway.

Yes, I know ;) And yes, I know there are technical reasons for not supporting gcc4.

But do you wan't to say that at places, where because of typos or lazy programming and thus no technical reason for it (e.g. passing signed where calling function wants unsigned) it is better to disable warning with -Wno-pointer-sign instead of fixing it?

Note that I haven't fixed a lot of other similar warnings where there may be technical reasons for it. But in this file I thought its worth fixing and improving code quality.

Regards

Dirk

#3 lore raw
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

hw/mips_r4k.c:256: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness

Compile with -Wno-pointer-sign. gcc4 isn't really supported anyway.

Quoted 8 lines

Yes, I know ;) And yes, I know there are technical reasons for not supporting gcc4.

But do you wan't to say that at places, where because of typos or lazy programming and thus no technical reason for it (e.g. passing signed where calling function wants unsigned) it is better to disable warning with -Wno-pointer-sign instead of fixing it?

I'm saying that this warning occurs in sufficiently many places, many of which are questionable, that it's best to just turn it off.

The entry change is maybe acceptable. The strcpy change just uglifies the code.

Paul