port to 64bit. Some gcc 4.4 warning fixes
[picodrive.git] / platform / common / menu.c
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