port to 64bit. Some gcc 4.4 warning fixes
authornotaz <notasas@gmail.com>
Sun, 6 Dec 2009 17:03:58 +0000 (17:03 +0000)
committernotaz <notasas@gmail.com>
Sun, 6 Dec 2009 17:03:58 +0000 (17:03 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@835 be3aeb3a-fb24-0410-a615-afba39da0efa

common/emu.c
common/menu.c
gp2x/in_gp2x.c
linux/sndout_oss.c

index 370242d..e916b3f 100644 (file)
@@ -464,25 +464,25 @@ int emu_reload_rom(char *rom_fname)
                // check for both gmv and rom\r
                int dummy;\r
                FILE *movie_file = fopen(rom_fname, "rb");\r
-               if(!movie_file) {\r
+               if (!movie_file) {\r
                        me_update_msg("Failed to open movie.");\r
                        return 0;\r
                }\r
                fseek(movie_file, 0, SEEK_END);\r
                movie_size = ftell(movie_file);\r
                fseek(movie_file, 0, SEEK_SET);\r
-               if(movie_size < 64+3) {\r
+               if (movie_size < 64+3) {\r
                        me_update_msg("Invalid GMV file.");\r
                        fclose(movie_file);\r
                        return 0;\r
                }\r
                movie_data = malloc(movie_size);\r
-               if(movie_data == NULL) {\r
+               if (movie_data == NULL) {\r
                        me_update_msg("low memory.");\r
                        fclose(movie_file);\r
                        return 0;\r
                }\r
-               fread(movie_data, 1, movie_size, movie_file);\r
+               dummy = fread(movie_data, 1, movie_size, movie_file);\r
                fclose(movie_file);\r
                if (strncmp((char *)movie_data, "Gens Movie TEST", 15) != 0) {\r
                        me_update_msg("Invalid GMV file.");\r
@@ -1008,13 +1008,16 @@ int emu_save_load_game(int load, int sram)
                        sram_size = SRam.size;\r
                        sram_data = SRam.data;\r
                }\r
-               if (!sram_data) return 0; // SRam forcefully disabled for this game\r
+               if (sram_data == NULL)\r
+                       return 0; // SRam forcefully disabled for this game\r
 \r
                if (load)\r
                {\r
                        sramFile = fopen(saveFname, "rb");\r
-                       if(!sramFile) return -1;\r
-                       fread(sram_data, 1, sram_size, sramFile);\r
+                       if (!sramFile)\r
+                               return -1;\r
+                       ret = fread(sram_data, 1, sram_size, sramFile);\r
+                       ret = ret > 0 ? 0 : -1;\r
                        fclose(sramFile);\r
                        if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART))\r
                                memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4);\r
index 887e0cd..8e3b9dd 100644 (file)
@@ -276,7 +276,8 @@ void menu_init(void)
                lprintf("found skin.txt\n");\r
                while (!feof(f))\r
                {\r
-                       fgets(buff, sizeof(buff), f);\r
+                       if (fgets(buff, sizeof(buff), f) == NULL)\r
+                               break;\r
                        if (buff[0] == '#'  || buff[0] == '/')  continue; // comment\r
                        if (buff[0] == '\r' || buff[0] == '\n') continue; // empty line\r
                        if (strncmp(buff, "text_color=", 11) == 0)\r
@@ -744,10 +745,15 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)
 \r
 static int scandir_cmp(const void *p1, const void *p2)\r
 {\r
-       struct dirent **d1 = (struct dirent **)p1, **d2 = (struct dirent **)p2;\r
-       if ((*d1)->d_type == (*d2)->d_type) return alphasort(d1, d2);\r
-       if ((*d1)->d_type == DT_DIR) return -1; // put before\r
-       if ((*d2)->d_type == DT_DIR) return  1;\r
+       const struct dirent **d1 = (const struct dirent **)p1;\r
+       const struct dirent **d2 = (const struct dirent **)p2;\r
+       if ((*d1)->d_type == (*d2)->d_type)\r
+               return alphasort(d1, d2);\r
+       if ((*d1)->d_type == DT_DIR)\r
+               return -1; // put before\r
+       if ((*d2)->d_type == DT_DIR)\r
+               return  1;\r
+\r
        return alphasort(d1, d2);\r
 }\r
 \r
@@ -789,13 +795,13 @@ rescan:
                fname = p+1;\r
        }\r
 \r
-       n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp);\r
+       n = scandir(curr_path, &namelist, scandir_filter, (void *)scandir_cmp);\r
        if (n < 0) {\r
                lprintf("menu_loop_romsel failed, dir: %s\n", curr_path);\r
 \r
                // try root\r
-               getcwd(curr_path, len);\r
-               n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp);\r
+               plat_get_root_dir(curr_path, len);\r
+               n = scandir(curr_path, &namelist, scandir_filter, (void *)scandir_cmp);\r
                if (n < 0) {\r
                        // oops, we failed\r
                        lprintf("menu_loop_romsel failed, dir: %s\n", curr_path);\r
index 818aead..37abeaf 100644 (file)
@@ -55,8 +55,8 @@ static int in_gp2x_get_mmsp2_bits(void)
 
 static int in_gp2x_get_wiz_bits(void)
 {
-       int value = 0;
-       read(gpiodev, &value, 4);
+       int r, value = 0;
+       r = read(gpiodev, &value, 4);
        if (value & 0x02)
                value |= 0x05;
        if (value & 0x08)
index ccadbba..f74e706 100644 (file)
@@ -44,7 +44,11 @@ int sndout_oss_start(int rate, int frame_samples, int stereo)
        if (sounddev == -1)
        {
                perror("open(\"/dev/dsp\")");
-               return -1;
+               sounddev = open("/dev/dsp1", O_WRONLY|O_ASYNC);
+               if (sounddev == -1) {
+                       perror("open(\"/dev/dsp1\")");
+                       return -1;
+               }
        }
 
        // calculate buffer size. We one to fit 1 frame worth of sound data.