diff --git a/SMB_test.c b/SMB_test.c index 6d2fc7c3..a59992a6 100644 --- a/SMB_test.c +++ b/SMB_test.c @@ -73,6 +73,7 @@ size_t storeSMBCNF(char *cnf_buf) int i; for (CNF_size = 0, i = 0; i < smbServerListCount; i++) { // loop for each SMB server in the list + size_step = 0; sprintf(cnf_buf + CNF_size, "smbIndex = %d\r\n" "smbServer_IP = %s\r\n" @@ -104,7 +105,7 @@ size_t storeSMBCNF(char *cnf_buf) //--------------------------------------------------------------------------- // saveSMBCNF will save SMB specific settings to an SMB CNF file //------------------------------ -int saveSMBCNF(char *CNFpath) +int saveSMBCNF(const char *CNFpath) { int ret, fd; char tmp[SERVERLIST_MAX * 1500]; // Must have room for entire SMB CNF file @@ -129,7 +130,7 @@ int saveSMBCNF(char *CNFpath) //--------------------------------------------------------------------------- // scanSMBCNF will check for SMB specific variables of an SMB CNF in RAM //------------------------------ -int scanSMBCNF(unsigned char *name, unsigned char *value) +int scanSMBCNF(const unsigned char *name, const unsigned char *value) { if (!strcmp(name, "smbIndex")) { int test; @@ -169,7 +170,7 @@ int scanSMBCNF(unsigned char *name, unsigned char *value) //--------------------------------------------------------------------------- // loadSMBCNF will load SMB specific settings from an SMB CNF file //------------------------------ -int loadSMBCNF(char *path) +int loadSMBCNF(const char *path) { int var_cnt; unsigned char *RAM_p, *CNF_p, *name, *value; diff --git a/config.c b/config.c index 321cf8e4..8ea545c3 100644 --- a/config.c +++ b/config.c @@ -135,7 +135,7 @@ int CheckMC(void) return -11; } //--------------------------------------------------------------------------- -unsigned long hextoul(char *string) +unsigned long hextoul(const char *string) { unsigned long value; char c; @@ -152,6 +152,7 @@ static size_t storeSkinCNF(char *cnf_buf) { size_t CNF_size; + CNF_size = 0; sprintf(cnf_buf, "GUI_Col_1_ABGR = %08X\r\n" "GUI_Col_2_ABGR = %08X\r\n" @@ -197,7 +198,7 @@ static size_t storeSkinCNF(char *cnf_buf) //--------------------------------------------------------------------------- // saveSkinCNF will save most cosmetic settings to a skin CNF file //------------------------------ -static int saveSkinCNF(char *CNF) +static int saveSkinCNF(const char *CNF) { int ret, fd; char tmp[26 * MAX_PATH + 30 * MAX_PATH]; @@ -277,7 +278,7 @@ static void saveSkinBrowser(void) //--------------------------------------------------------------------------- // preloadCNF loads an entire CNF file into RAM it allocates //------------------------------ -char *preloadCNF(char *path) +char *preloadCNF(const char *path) { int fd, tst; s64 CNF_size; @@ -309,7 +310,7 @@ char *preloadCNF(char *path) //--------------------------------------------------------------------------- // scanSkinCNF will check for most cosmetic variables of a CNF //------------------------------ -int scanSkinCNF(char *name, char *value) +int scanSkinCNF(const char *name, const char *value) { if (!strcmp(name, "GUI_Col_1_ABGR")) setting->color[COLOR_BACKGR] = hextoul(value); @@ -357,7 +358,7 @@ int scanSkinCNF(char *name, char *value) //--------------------------------------------------------------------------- // loadSkinCNF will load most cosmetic settings from CNF file //------------------------------ -int loadSkinCNF(char *path) +int loadSkinCNF(const char *path) { int var_cnt; char *RAM_p, *CNF_p, *name, *value; @@ -369,7 +370,7 @@ int loadSkinCNF(char *path) scanSkinCNF(name, value); free(RAM_p); updateScreenMode(); - if (setting->skin) + if (setting->skin[0]) loadSkin(BACKGROUND_PIC, 0, 0); return 0; } @@ -401,17 +402,19 @@ void loadSkinBrowser(void) // polo: ADD save SKIN_FILE string // suloku: ADD save MAIN_SKIN string //dlanor: changed to GUI_SKIN_FILE //--------------------------------------------------------------------------- -void saveConfig(char *mainMsg, char *CNF) +void saveConfig(char *mainMsg, const char *CNF) { int i, ret, fd; char c[MAX_PATH], tmp[26 * MAX_PATH + 30 * MAX_PATH]; char cnf_path[MAX_PATH]; size_t CNF_size, CNF_step; + CNF_size = 0; sprintf(tmp, "CNF_version = 3\r\n%n", &CNF_size); // Start CNF with version header for (i = 0; i < SETTING_LK_COUNT; i++) { // Loop to save the ELF paths for launch keys if ((i <= SETTING_LK_SELECT) || (setting->LK_Flag[i] != 0)) { + CNF_step = 0; sprintf(tmp + CNF_size, "LK_%s_E1 = %s\r\n" "%n", // %n causes NO output, but only a measurement @@ -424,6 +427,7 @@ void saveConfig(char *mainMsg, char *CNF) } // ends for i = strlen(setting->Misc); + CNF_step = 0; sprintf(tmp + CNF_size, "Misc = %s\r\n" "Misc_PS2Disc = %s\r\n" @@ -468,6 +472,7 @@ void saveConfig(char *mainMsg, char *CNF) CNF_size += storeSkinCNF(tmp + CNF_size); + CNF_step = 0; sprintf(tmp + CNF_size, "LK_auto_Timer = %d\r\n" "Menu_Hide_Paths = %d\r\n" @@ -524,6 +529,7 @@ void saveConfig(char *mainMsg, char *CNF) for (i = 0; i < SETTING_LK_BTN_COUNT; i++) { // Loop to save user defined launch key titles if (setting->LK_Title[i][0]) { // Only save non-empty strings + CNF_step = 0; sprintf(tmp + CNF_size, "LK_%s_Title = %s\r\n" "%n", // %n causes NO output, but only a measurement @@ -535,6 +541,7 @@ void saveConfig(char *mainMsg, char *CNF) } // ends if } // ends for + CNF_step = 0; sprintf(tmp + CNF_size, "PathPad_Lock = %d\r\n" "%n", // %n causes NO output, but only a measurement @@ -545,6 +552,7 @@ void saveConfig(char *mainMsg, char *CNF) for (i = 0; i < MAX_PATH_PAD; i++) { // Loop to save non-empty PathPad entries if (PathPad[i][0]) { // Only save non-empty strings + CNF_step = 0; sprintf(tmp + CNF_size, "PathPad[%02d] = %s\r\n" "%n", // %n causes NO output, but only a measurement @@ -694,7 +702,7 @@ void initConfig(void) // suloku: ADD load MAIN_SKIN string //dlanor: changed to GUI_SKIN_FILE // dlanor: added error flag return value 0==OK, -1==failure //--------------------------------------------------------------------------- -int loadConfig(char *mainMsg, char *CNF) +int loadConfig(char *mainMsg, const char *CNF) { int i, fd, tst, len, mcport, var_cnt, CNF_version; char tsts[256]; @@ -1976,7 +1984,7 @@ static void saveNetworkSettings(char *Message) //--------------------------------------------------------------------------- // Convert IP string to numbers //--------------------------------------------------------------------------- -static void ipStringToOctet(char *ip, int ip_octet[4]) +static void ipStringToOctet(const char *ip, int ip_octet[4]) { // This takes a string (ip) representing an IP address and converts it @@ -1991,7 +1999,7 @@ static void ipStringToOctet(char *ip, int ip_octet[4]) oct_str[0] = 0; for (i = 0; ((i <= strlen(ip)) && (oct_cnt < 4)); i++) { - if ((ip[i] == '.') | (i == strlen(ip))) { + if ((ip[i] == '.') || (i == strlen(ip))) { ip_octet[oct_cnt] = atoi(oct_str); oct_cnt++; oct_str[0] = 0; @@ -2002,7 +2010,7 @@ static void ipStringToOctet(char *ip, int ip_octet[4]) } } //--------------------------------------------------------------------------- -static data_ip_struct BuildOctets(char *ip, char *nm, char *gw) +static data_ip_struct BuildOctets(const char *ip, const char *nm, const char *gw) { // Populate 3 arrays with the ip address (as ints) @@ -2266,11 +2274,11 @@ enum CONFIG_MAIN { CONFIG_MAIN_COUNT }; -void config(char *mainMsg, char *CNF) +void config(char *mainMsg, const char *CNF) { char c[MAX_PATH]; char title_tmp[MAX_ELF_TITLE]; - char *localMsg; + const char *localMsg; int i; int s; int x, y; diff --git a/draw.c b/draw.c index 35baef8b..57587de4 100644 --- a/draw.c +++ b/draw.c @@ -257,11 +257,11 @@ static int ShrinkData(u8 *pInBuff, u16 wWidth, u16 wHeight, u8 *pOutBuff, u16 wN static int EnlargeData(u8 *pInBuff, u16 wWidth, u16 wHeight, u8 *pOutBuff, u16 wNewWidth, u16 wNewHeight) { - u8 *pLine = pInBuff, - *pPix = pLine, - *pPixOld, - *pUpPix, - *pUpPixOld; + u8 *pLine = pInBuff; + u8 *pPix = pLine; + const u8 *pPixOld; + u8 *pUpPix; + const u8 *pUpPixOld; u8 *pOutLine = pOutBuff; u32 dwInLn = (3 * wWidth + 3) & ~3; u32 dwOutLn = (3 * wNewWidth + 3) & ~3; @@ -659,7 +659,7 @@ void updateScreenMode(void) gsKit_set_display_offset(gsGlobal, setting->screen_x, setting->screen_y); } //-------------------------------------------------------------- -void loadSkin(int Picture, char *Path, int ThumbNum) +void loadSkin(int Picture, const char *Path, int ThumbNum) { char tmpPath[MAX_PATH], skinpath[MAX_PATH]; @@ -848,7 +848,7 @@ void loadIcon(void) free(TexIcon[1].Mem); } //-------------------------------------------------------------- -int loadFont(char *path_arg) +int loadFont(const char *path_arg) { int fd; @@ -961,7 +961,7 @@ void drawFrame(int x1, int y1, int x2, int y2, u64 color) void drawChar(unsigned int c, int x, int y, u64 colour) { int i, j, pixMask; - u8 *cm; + const u8 *cm; updateScr_1 = 1; diff --git a/editor.c b/editor.c index f9668cb8..586cb042 100644 --- a/editor.c +++ b/editor.c @@ -103,7 +103,7 @@ static int Windows_Selector(void); static void Init(void); static int New(int Win); static int OpenFile(int Win); -static int Open(int Win, char *path); +static int Open(int Win, const char *path); static void Close(int Win); static void Save(int Win); static void Save_As(int Win); @@ -1047,7 +1047,7 @@ static int OpenFile(int Win) return Open(Win, Path[Win]); } -static int Open(int Win, char *path) +static int Open(int Win, const char *path) { int fd, i, ret = 0; char filePath[MAX_PATH]; @@ -1173,7 +1173,7 @@ static void Save_As(int Win) { int fd, ret = 0; char tmp[MAX_PATH], oldPath[MAX_PATH], filePath[MAX_PATH]; - char *p; + const char *p; tmp[0] = '\0', oldPath[0] = '\0', filePath[0] = '\0'; @@ -1234,7 +1234,7 @@ static void Save_As(int Win) ; // display operation result during 1.5 sec. } //-------------------------------------------------------------- -void TextEditor(char *path) +void TextEditor(const char *path) { char tmp[MAX_PATH], tmp1[MAX_PATH], tmp2[MAX_PATH]; int ch; diff --git a/elf.c b/elf.c index 19e08214..87d3c051 100644 --- a/elf.c +++ b/elf.c @@ -55,7 +55,7 @@ int checkELFheader(char *path) { elf_header_t elf_head; u8 *boot_elf = (u8 *)&elf_head; - elf_header_t *eh = (elf_header_t *)boot_elf; + const elf_header_t *eh = (const elf_header_t *)boot_elf; int fd, size = 0, ret; char fullpath[MAX_PATH], tmp[MAX_PATH], *p; @@ -85,7 +85,7 @@ int checkELFheader(char *path) goto error; fullpath[7] += ret; } else if (!strncmp(fullpath, "mass", 4)) { - char *pathSep; + const char *pathSep; pathSep = strchr(path, '/'); if (pathSep && (pathSep - path < 7) && pathSep[-1] == ':') @@ -127,11 +127,11 @@ void RunLoaderElf(char *filename, char *party) u8 *boot_elf; elf_header_t *eh; elf_pheader_t *eph; - void *pdata; + const void *pdata; int i; char *argv[2], bootpath[256]; - if ((!strncmp(party, "hdd0:", 5)) && (!strncmp(filename, "pfs0:", 5))) { + if ((!strncmp(party, "hdd0:", 5))) { if (0 > fileXioMount("pfs0:", party, FIO_MT_RDONLY)) { // Some error occurred, it could be due to something else having used pfs0 unmountParty(0); // So we try unmounting pfs0, to try again @@ -149,7 +149,7 @@ void RunLoaderElf(char *filename, char *party) argv[0] = filename; argv[1] = bootpath; - } else if ((!strncmp(party, "dvr_hdd0:", 9)) && (!strncmp(filename, "dvr_pfs0:", 9))) { + } else if ((!strncmp(party, "dvr_hdd0:", 9))) { if (0 > fileXioMount("dvr_pfs0:", party, FIO_MT_RDONLY)) { // Some error occurred, it could be due to something else having used pfs0 unmountDVRPParty(0); // So we try unmounting pfs0, to try again diff --git a/filer.c b/filer.c index 0d97608e..fab4ce30 100644 --- a/filer.c +++ b/filer.c @@ -496,7 +496,7 @@ int ynDialog(const char *message) //------------------------------ // endfunc ynDialog //-------------------------------------------------------------- -void nonDialog(char *message) +void nonDialog(const char *message) { char msg[80 * 30]; // More than this can't be shown on screen, even in PAL static int dh, dw, dx, dy; // These are static, to allow cleanup @@ -628,7 +628,7 @@ int cmpFile(FILEINFO *a, FILEINFO *b) // Used for directory sort //-------------------------------------------------------------- void sort(FILEINFO *a, int left, int right) { - FILEINFO tmp, pivot; + FILEINFO pivot; if (left < right) { int i, p; @@ -637,6 +637,8 @@ void sort(FILEINFO *a, int left, int right) p = left; for (i = left + 1; i <= right; i++) { if (cmpFile(&a[i], &pivot) < 0) { + FILEINFO tmp; + p = p + 1; tmp = a[p]; a[p] = a[i]; @@ -867,7 +869,7 @@ void genLimObjName(char *uLE_path, int reserve) int genFixPath(const char *inp_path, char *gen_path) { char uLE_path[MAX_PATH], loc_path[MAX_PATH], party[MAX_NAME], *p; - char *pathSep; + const char *pathSep; int part_ix; part_ix = 99; // Assume valid non-HDD path @@ -1300,7 +1302,7 @@ int readMASS(const char *path, FILEINFO *info, int max) //------------------------------ // endfunc readMASS //-------------------------------------------------------------- -char *makeHostPath(char *dp, char *sp) +char *makeHostPath(char *dp, const char *sp) { int i; @@ -1487,7 +1489,7 @@ static int getGameTitle(const char *path, const FILEINFO *file, unsigned char *o char party[MAX_NAME], dir[MAX_PATH], tmpdir[MAX_PATH]; int fd = -1, size, ret; psu_header PSU_head; - int i, tst, PSU_content, psu_pad_pos; + int i, tst, PSU_content_local, psu_pad_pos; out[0] = '\0'; // Start by making an empty result string, for failures @@ -1525,8 +1527,8 @@ static int getGameTitle(const char *path, const FILEINFO *file, unsigned char *o tst = genRead(fd, (void *)&PSU_head, sizeof(PSU_head)); if (tst != sizeof(PSU_head)) goto finish; // Abort if read fails - PSU_content = PSU_head.size; - for (i = 0; i < PSU_content; i++) { + PSU_content_local = PSU_head.size; + for (i = 0; i < PSU_content_local; i++) { tst = genRead(fd, (void *)&PSU_head, sizeof(PSU_head)); if (tst != sizeof(PSU_head)) goto finish; // Abort if read fails @@ -1585,7 +1587,7 @@ static int getGameTitle(const char *path, const FILEINFO *file, unsigned char *o return ret; } //-------------------------------------------------------------- -int menu(const char *path, FILEINFO *file) +int menu(const char *path, const FILEINFO *file) { u64 color; char enable[NUM_MENU], tmp[80]; @@ -2186,7 +2188,7 @@ int newdir(const char *path, const char *name) // be either a single file or a folder. In the latter case the // folder contents should also be copied, recursively. //-------------------------------------------------------------- -int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) +int copy(const char *outPath, const char *inPath, FILEINFO file, int recurses) { FILEINFO newfile, files[MAX_ENTRY]; iox_stat_t iox_stat; @@ -2204,10 +2206,13 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) u64 OldTime = 0LL; psu_header PSU_head; mcT_header *mcT_head_p = (mcT_header *)&file.stats; - mcT_header *mcT_files_p = (mcT_header *)&files[0].stats; + mcT_header *mcT_files_p; int psu_pad_size = 0, PSU_restart_f = 0; char *cp, *np; + memset(&files, 0, sizeof(files)); + mcT_files_p = (mcT_header *)&files[0].stats; + PM_flag[recurses + 1] = PM_NORMAL; // assume normal mode for next level PM_file[recurses + 1] = -1; // assume that no special file is needed @@ -2857,16 +2862,17 @@ int keyboard(char *out, int max) KEY_H = LINE_THICKNESS + 1 + FONT_HEIGHT + 1 + LINE_THICKNESS + 8 + (8 * FONT_HEIGHT) + 8 + LINE_THICKNESS, KEY_X = ((SCREEN_WIDTH - KEY_W) / 2) & -2, KEY_Y = ((SCREEN_HEIGHT - KEY_H) / 2) & -2; - char *KEY = "ABCDEFGHIJKLM" - "NOPQRSTUVWXYZ" - "abcdefghijklm" - "nopqrstuvwxyz" - "0123456789/|\\" - "<>(){}[].,:;\"" - "!@#$%&=+-^*_'"; + const char *KEY = "ABCDEFGHIJKLM" + "NOPQRSTUVWXYZ" + "abcdefghijklm" + "nopqrstuvwxyz" + "0123456789/|\\" + "<>(){}[].,:;\"" + "!@#$%&=+-^*_'"; int KEY_LEN; int cur = 0, sel = 0, i, x, y, t = 0; - char tmp[256], *p; + char tmp[256]; + const char *p; char KeyPress; p = strrchr(out, '.'); @@ -3255,7 +3261,7 @@ int keyboard2(char *out, int max) //-------------------------------------------------------------- int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) { - int nfiles, i, j, ret; + int nfiles, i; size_valid = 0; time_valid = 0; @@ -3366,6 +3372,8 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) files[0].stats.AttrFile = sceMcFileAttrSubdir; nfiles = getDir(path, &files[1]) + 1; if (strcmp(ext, "*")) { + int j; + for (i = j = 1; i < nfiles; i++) { if (files[i].stats.AttrFile & sceMcFileAttrSubdir) files[j++] = files[i]; @@ -3378,6 +3386,8 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) } if ((file_show == 2) || (file_sort == 2)) { for (i = 1; i < nfiles; i++) { + int ret; + ret = getGameTitle(path, &files[i], files[i].title); if (ret < 0) files[i].title[0] = 0; @@ -3593,10 +3603,10 @@ int BrowserModePopup(void) // dlanor: ADD return value 0=pure path, 1=pathname, negative=error/no_selection static int browser_cd, browser_up, browser_repos, browser_pushed; static int browser_sel, browser_nfiles; -static void submenu_func_GetSize(char *mess, char *path, FILEINFO *files); -static void submenu_func_Paste(char *mess, char *path); -static void submenu_func_mcPaste(char *mess, char *path); -static void submenu_func_psuPaste(char *mess, char *path); +static void submenu_func_GetSize(char *mess, const char *path, FILEINFO *files); +static void submenu_func_Paste(char *mess, const char *path); +static void submenu_func_mcPaste(char *mess, const char *path); +static void submenu_func_psuPaste(char *mess, const char *path); int getFilePath(char *out, int cnfmode) { char path[MAX_PATH + 1], cursorEntry[MAX_PATH], @@ -3711,7 +3721,7 @@ int getFilePath(char *out, int cnfmode) } } } else if (new_pad & PAD_R2) { - char *temp = PathPad_menu(path); + const char *temp = PathPad_menu(path); if (temp != NULL) { strcpy(path, temp); @@ -4122,7 +4132,7 @@ int getFilePath(char *out, int cnfmode) strcpy(tmp, "----- B"); else { int scale = 0; // 0==Bytes, 1==KBytes, 2==MBytes, 3==GB - char scale_s[6] = " KMGTP"; + const char scale_s[6] = " KMGTP"; while (size > 99999) { scale++; @@ -4270,7 +4280,7 @@ int getFilePath(char *out, int cnfmode) //------------------------------ // endfunc getFilePath //-------------------------------------------------------------- -void submenu_func_GetSize(char *mess, char *path, FILEINFO *files) +void submenu_func_GetSize(char *mess, const char *path, FILEINFO *files) { u64 size; int ret, text_pos, text_inc, sel = -1; @@ -4303,6 +4313,7 @@ void submenu_func_GetSize(char *mess, char *path, FILEINFO *files) text_pos = strlen(mess); } else { text_pos = 0; + text_inc = 0; if (size >= 1024 * 1024) sprintf(mess, "%s = %.1fMB%n", LNG(SIZE), (double)size / 1024 / 1024, &text_inc); else if (size >= 1024) @@ -4374,7 +4385,7 @@ void submenu_func_GetSize(char *mess, char *path, FILEINFO *files) //------------------------------ // endfunc submenu_func_GetSize //-------------------------------------------------------------- -void subfunc_Paste(char *mess, char *path) +void subfunc_Paste(char *mess, const char *path) { char tmp[MAX_PATH], tmp1[MAX_PATH]; int i, ret = -1; @@ -4417,7 +4428,7 @@ void subfunc_Paste(char *mess, char *path) //------------------------------ // endfunc subfunc_Paste //-------------------------------------------------------------- -void submenu_func_Paste(char *mess, char *path) +void submenu_func_Paste(char *mess, const char *path) { if (new_pad & PAD_SQUARE) PasteMode = PM_RENAME; @@ -4428,7 +4439,7 @@ void submenu_func_Paste(char *mess, char *path) //------------------------------ // endfunc submenu_func_Paste //-------------------------------------------------------------- -void submenu_func_mcPaste(char *mess, char *path) +void submenu_func_mcPaste(char *mess, const char *path) { if (!strncmp(path, "mc", 2) || !strncmp(path, "vmc", 3)) { PasteMode = PM_MC_RESTORE; @@ -4440,7 +4451,7 @@ void submenu_func_mcPaste(char *mess, char *path) //------------------------------ // endfunc submenu_func_mcPaste //-------------------------------------------------------------- -void submenu_func_psuPaste(char *mess, char *path) +void submenu_func_psuPaste(char *mess, const char *path) { if (!strncmp(path, "mc", 2) || !strncmp(path, "vmc", 3)) { PasteMode = PM_PSU_RESTORE; diff --git a/hdd.c b/hdd.c index 12cfd9ff..6f8a224f 100644 --- a/hdd.c +++ b/hdd.c @@ -52,7 +52,7 @@ float cosdgf(float f) { return cosf(f) * M_PI / 180.0f; } //-------------------------------------------------------------- ///* -void DebugDisp(char *Message) +void DebugDisp(const char *Message) { int done; diff --git a/hdl_info/apa.c b/hdl_info/apa.c index e9f8f2f4..9ddf0e6d 100644 --- a/hdl_info/apa.c +++ b/hdl_info/apa.c @@ -136,13 +136,6 @@ int apa_ptable_read_ex(hio_t *hio, apa_partition_table_t **table) u_long size_in_kb; int result = hio->stat(hio, &size_in_kb); if (result == 0) { - u_long total_sectors; - // limit HDD size to 128GB - 1KB; that is: exclude the last 128MB chunk - // if (size_in_kb > 128 * 1024 * 1024 - 1) - // size_in_kb = 128 * 1024 * 1024 - 1; - - total_sectors = size_in_kb * 2; /* 1KB = 2 sectors of 512 bytes, each */ - *table = apa_ptable_alloc(); if (*table != NULL) { u_long sector = 0; @@ -154,6 +147,13 @@ int apa_ptable_read_ex(hio_t *hio, apa_partition_table_t **table) if (bytes == sizeof(part) && get_u32(&part.checksum) == apa_partition_checksum(&part) && memcmp(part.magic, PS2_PARTITION_MAGIC, 4) == 0) { + u_long total_sectors; + // limit HDD size to 128GB - 1KB; that is: exclude the last 128MB chunk + // if (size_in_kb > 128 * 1024 * 1024 - 1) + // size_in_kb = 128 * 1024 * 1024 - 1; + + total_sectors = size_in_kb * 2; /* 1KB = 2 sectors of 512 bytes, each */ + if (get_u32(&part.start) < total_sectors && get_u32(&part.start) + get_u32(&part.length) < total_sectors) { if ((get_u16(&part.flags) == 0x0000) && (get_u16(&part.type) == 0x1337)) diff --git a/hdl_info/hdd.c b/hdl_info/hdd.c index 594936f4..af19ae00 100644 --- a/hdl_info/hdd.c +++ b/hdl_info/hdd.c @@ -15,12 +15,12 @@ #include "apa.h" static hdl_games_list_t *games = NULL; -static hio_t *hio = NULL; +static hio_t *g_hio = NULL; //-------------------------------------------------------------- static int iop_stat(hio_t *hio, u_long *size_in_kb) { - hio_iop_t *iop = (hio_iop_t *)hio; + const hio_iop_t *iop = (const hio_iop_t *)hio; *size_in_kb = iop->size_in_sectors / 2; return 0; } @@ -107,7 +107,7 @@ int hio_iop_probe(const char *path, hio_t **hio) path[4] == ':' && path[5] == '\0') { int unit = path[3] - '0'; - ata_devinfo_t *dev_info = ata_get_devinfo(unit); + const ata_devinfo_t *dev_info = ata_get_devinfo(unit); if (dev_info != NULL && dev_info->exists) { *hio = iop_alloc(unit, dev_info->total_sectors); if (*hio != NULL) @@ -121,18 +121,18 @@ int hio_iop_probe(const char *path, hio_t **hio) //------------------------------ // endfunc hio_iop_probe //-------------------------------------------------------------- -int HdlGetGameInfo(char *PartName, GameInfo *GameInf) +int HdlGetGameInfo(const char *PartName, GameInfo *GameInf) { hdl_glist_free(games); games = NULL; - if (hio != NULL) - hio->close(hio); - hio = NULL; + if (g_hio != NULL) + g_hio->close(g_hio); + g_hio = NULL; - if (hio_iop_probe("hdd0:", &hio) == 0) { + if (hio_iop_probe("hdd0:", &g_hio) == 0) { int err; - if ((err = hdl_glist_read(hio, &games)) == 0) { + if ((err = hdl_glist_read(g_hio, &games)) == 0) { int i; for (i = 0; i < games->count; ++i) { @@ -159,19 +159,19 @@ int HdlGetGameInfo(char *PartName, GameInfo *GameInf) int HdlRenameGame(void *Data) { - int *Pointer = Data; - Rpc_Packet_Send_Rename *Packet = (Rpc_Packet_Send_Rename *)Pointer; + const int *Pointer = Data; + const Rpc_Packet_Send_Rename *Packet = (const Rpc_Packet_Send_Rename *)Pointer; hdl_glist_free(games); games = NULL; - if (hio != NULL) - hio->close(hio); - hio = NULL; + if (g_hio != NULL) + g_hio->close(g_hio); + g_hio = NULL; - if (hio_iop_probe("hdd0:", &hio) == 0) { + if (hio_iop_probe("hdd0:", &g_hio) == 0) { int err; - if ((err = hdl_glist_read(hio, &games)) == 0) { + if ((err = hdl_glist_read(g_hio, &games)) == 0) { int i; for (i = 0; i < games->count; ++i) { @@ -180,7 +180,7 @@ int HdlRenameGame(void *Data) if (!strcmp(Packet->OldName, game->name)) { printf("Renaming Game %s To %s.\n", game->name, Packet->NewName); strcpy(game->name, Packet->NewName); - if ((err = hdl_glist_write(hio, game)) == 0) + if ((err = hdl_glist_write(g_hio, game)) == 0) return 0; // Return flag for no error else return err; // Return error flag for 'hdl_glist_write failed' diff --git a/hdl_info/hdd.h b/hdl_info/hdd.h index 9a3112e4..f293215b 100644 --- a/hdl_info/hdd.h +++ b/hdl_info/hdd.h @@ -76,7 +76,7 @@ typedef struct int Is_Dvd; } GameInfo; -int HdlGetGameInfo(char *PartName, GameInfo *GameInf); +int HdlGetGameInfo(const char *PartName, GameInfo *GameInf); int HdlRenameGame(void *Data); #endif diff --git a/hdl_info/hdl.c b/hdl_info/hdl.c index 66b35d96..ab0a6eca 100644 --- a/hdl_info/hdl.c +++ b/hdl_info/hdl.c @@ -106,7 +106,7 @@ int hdl_glist_read(hio_t *hio, hdl_games_list_t **glist) //------------------------------ // endfunc hdl_glist_read //-------------------------------------------------------------- -static int hdl_ginfo_write(hio_t *hio, const ps2_partition_header_t *part, hdl_game_info_t *ginfo) +static int hdl_ginfo_write(hio_t *hio, const ps2_partition_header_t *part, const hdl_game_info_t *ginfo) { const u_long offset = 0x101000; char buffer[1024]; @@ -125,7 +125,7 @@ static int hdl_ginfo_write(hio_t *hio, const ps2_partition_header_t *part, hdl_g //------------------------------ // endfunc hdl_ginfo_write //-------------------------------------------------------------- -int hdl_glist_write(hio_t *hio, hdl_game_info_t *ginfo) +int hdl_glist_write(hio_t *hio, const hdl_game_info_t *ginfo) { apa_partition_table_t *ptable; int result; diff --git a/hdl_info/hdl.h b/hdl_info/hdl.h index 94a0fa3a..97d4f3d0 100644 --- a/hdl_info/hdl.h +++ b/hdl_info/hdl.h @@ -25,6 +25,6 @@ typedef struct hdl_games_list_type void hdl_glist_free(hdl_games_list_t *glist); int hdl_glist_read(hio_t *hio, hdl_games_list_t **glist); -int hdl_glist_write(hio_t *hio, hdl_game_info_t *ginfo); +int hdl_glist_write(hio_t *hio, const hdl_game_info_t *ginfo); #endif /* _CDVDHDL_H_ */ diff --git a/hdl_rpc.c b/hdl_rpc.c index a5c68a8a..0f79d9e2 100644 --- a/hdl_rpc.c +++ b/hdl_rpc.c @@ -50,7 +50,7 @@ int Hdl_Info_BindRpc() return retryCount; } -int HdlGetGameInfo(char *PartName, GameInfo *Game) +int HdlGetGameInfo(const char *PartName, GameInfo *Game) { Rpc_Packet_Send_GetInfo *Packet = (Rpc_Packet_Send_GetInfo *)Rpc_Buffer; @@ -67,7 +67,7 @@ int HdlGetGameInfo(char *PartName, GameInfo *Game) return Rpc_Buffer[0]; } -int HdlRenameGame(char *OldName, char *NewName) +int HdlRenameGame(const char *OldName, const char *NewName) { Rpc_Packet_Send_Rename *Packet = (Rpc_Packet_Send_Rename *)Rpc_Buffer; diff --git a/hdl_rpc.h b/hdl_rpc.h index b02962ef..d6fde8d0 100644 --- a/hdl_rpc.h +++ b/hdl_rpc.h @@ -19,8 +19,8 @@ extern "C" { #endif /* __cplusplus */ int Hdl_Info_BindRpc(void); -int HdlGetGameInfo(char *PartName, GameInfo *Game); -int HdlRenameGame(char *OldName, char *NewName); +int HdlGetGameInfo(const char *PartName, GameInfo *Game); +int HdlRenameGame(const char *OldName, const char *NewName); #ifdef __cplusplus } diff --git a/jpgviewer.c b/jpgviewer.c index 96d8f0cb..ed5d5a18 100644 --- a/jpgviewer.c +++ b/jpgviewer.c @@ -483,7 +483,7 @@ static void loadPic(void) } /* end loadPic */ //-------------------------------------------------------------- -void JpgViewer(char *file) +void JpgViewer(const char *file) { char path[MAX_PATH], cursorEntry[MAX_PATH], ext[8], @@ -897,7 +897,7 @@ void JpgViewer(char *file) if (--SlideShowTime <= 1) SlideShowTime = 1; } else if (new_pad & PAD_R2) { - char *temp = PathPad_menu(path); + const char *temp = PathPad_menu(path); if (temp != NULL) { strcpy(path, temp); diff --git a/lang.c b/lang.c index f800db79..414398dc 100644 --- a/lang.c +++ b/lang.c @@ -31,7 +31,10 @@ Language *External_Lang_Buffer = NULL; //--------------------------------------------------------------------------- int get_LANG_string(char **LANG_p_p, char **id_p_p, char **value_p_p) { - char *cp, *ip, *vp, *tp = *LANG_p_p; + const char *cp; + char *ip; + char *vp; + char *tp = *LANG_p_p; int ret, length; ip = NULL; @@ -187,7 +190,7 @@ void Load_External_Language(void) External_Lang_Buffer = NULL; } - Language *Lang = Lang_Default; + const Language *Lang = Lang_Default; memcpy(Lang_String, Lang, sizeof(Lang_String)); if (strlen(setting->lang_file) != 0) { // if language file string set @@ -297,7 +300,7 @@ void Load_External_Language(void) for (i = 0; i < 16; i++) { // Loop to rename the ELF paths with new language for launch keys if ((i < 12) || (setting->LK_Flag[i] != 0)) { if (!strncmp(setting->LK_Path[i], setting->Misc, strlen(setting->Misc))) { - char *tmp; + const char *tmp; tmp = strrchr(setting->LK_Path[i], '/'); if (!strcmp(tmp + 1, setting->Misc_PS2Disc + strlen(setting->Misc))) diff --git a/launchelf.h b/launchelf.h index a8d709e6..ced32114 100644 --- a/launchelf.h +++ b/launchelf.h @@ -221,7 +221,7 @@ int uLE_cdStop(void); int IsSupportedFileType(char *path); /* elf.c */ -int checkELFheader(char *filename); +int checkELFheader(char *path); void RunLoaderElf(char *filename, char *); /* draw.c */ @@ -265,7 +265,7 @@ void setupGS(void); void updateScreenMode(void); void clrScr(u64 color); void setBrightness(int Brightness); -void loadSkin(int Picture, char *Path, int ThumbNum); +void loadSkin(int Picture, const char *Path, int ThumbNum); void drawScr(void); void drawFrame(int x1, int y1, int x2, int y2, u64 color); void drawChar(unsigned int c, int x, int y, u64 colour); @@ -273,7 +273,7 @@ int printXY(const char *s, int x, int y, u64 colour, int draw, int space); int printXY_sjis(const unsigned char *s, int x, int y, u64 colour, int); char *transcpy_sjis(char *d, const unsigned char *s); void loadIcon(void); -int loadFont(char *path_arg); +int loadFont(const char *path_arg); // Comment out WriteFont_C when not used (also requires patch in draw.c) // int WriteFont_C(char *pathname); @@ -310,12 +310,12 @@ enum TV_mode { extern char PathPad[30][MAX_PATH]; extern SETTING *setting; void initConfig(void); -int loadConfig(char *, char *); // 0==OK, -1==load failed -void config(char *, char *); +int loadConfig(char *, const char *); // 0==OK, -1==load failed +void config(char *, const char *); int get_CNF_string(char **CNF_p_p, char **name_p_p, char **value_p_p); // main CNF name,value parser -char *preloadCNF(char *path); // loads file into RAM it allocates +char *preloadCNF(const char *path); // loads file into RAM it allocates /* filer.c */ typedef struct @@ -336,9 +336,9 @@ extern unsigned char *elisaFnt; char *PathPad_menu(const char *path); int getFilePath(char *out, const int cnfmode); void initHOST(void); -char *makeHostPath(char *dp, char *sp); +char *makeHostPath(char *dp, const char *sp); int ynDialog(const char *message); -void nonDialog(char *message); +void nonDialog(const char *message); int keyboard(char *out, int max); void genLimObjName(char *uLE_path, int reserve); int genFixPath(const char *inp_path, char *gen_path); @@ -360,11 +360,11 @@ void unmountAll(void); int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode); /* hdd.c */ -void DebugDisp(char *Message); +void DebugDisp(const char *Message); void hddManager(void); /* editor.c */ -void TextEditor(char *path); +void TextEditor(const char *path); /* timer.c */ extern u64 WaitTime; @@ -373,7 +373,7 @@ extern u64 CurrTime; u64 Timer(void); /* jpgviewer.c */ -void JpgViewer(char *file); +void JpgViewer(const char *file); /* lang.c */ typedef struct Language @@ -425,8 +425,8 @@ enum { }; /* makeicon.c */ -int make_icon(char *icontext, char *filename); -int make_iconsys(char *title, char *iconname, char *filename); +int make_icon(const char *icontext, const char *filename); +int make_iconsys(char *title, const char *iconname, const char *filename); // vmcfs definitions diff --git a/main.c b/main.c index 810afe33..6aae52da 100644 --- a/main.c +++ b/main.c @@ -206,8 +206,8 @@ DiscType DiscTypes[] = { }; // ends DiscTypes array // Static function declarations -static int PrintRow(int row_f, char *text_p); -static int PrintPos(int row_f, int column, char *text_p); +static int PrintRow(int row_f, const char *text_p); +static int PrintPos(int row_f, int column, const char *text_p); static void Show_About_uLE(void); static void getIpConfig(void); static void setLaunchKeys(void); @@ -226,8 +226,8 @@ static void load_ps2ftpd(void); static void load_ps2netfs(void); static void loadBasicModules(void); static void loadCdModules(void); -static int loadExternalFile(char *argPath, void **fileBaseP, int *fileSizeP); -static int loadExternalModule(char *modPath, void *defBase, int defSize); +static int loadExternalFile(const char *argPath, void **fileBaseP, int *fileSizeP); +static int loadExternalModule(const char *modPath, void *defBase, int defSize); static void loadUsbDModule(void); static void loadUsbModules(void); static void loadKbdModules(void); @@ -236,7 +236,7 @@ static void poweroffHandler(int i); static void setupPowerOff(void); static void loadNetModules(void); static void startKbd(void); -static int scanSystemCnf(char *name, char *value); +static int scanSystemCnf(const char *name, const char *value); static int readSystemCnf(void); static void ShowFont(void); static void Validate_CNF_Path(void); @@ -246,7 +246,7 @@ static void decConfig(void); static void incConfig(void); static int exists(char *path); static void CleanUp(void); -static void Execute(char *pathin); +static void Execute(const char *pathin); static void Reset(void); static void InitializeBootExecPath(); //--------------------------------------------------------------------------- @@ -254,7 +254,7 @@ static void InitializeBootExecPath(); //--------------------------------------------------------------------------- // Function to print a text row to the 'gs' screen //------------------------------ -static int PrintRow(int row_f, char *text_p) +static int PrintRow(int row_f, const char *text_p) { static int row; int x = (Menu_start_x + 4); @@ -271,7 +271,7 @@ static int PrintRow(int row_f, char *text_p) //--------------------------------------------------------------------------- // Function to print a text row with text positioning //------------------------------ -static int PrintPos(int row_f, int column, char *text_p) +static int PrintPos(int row_f, int column, const char *text_p) { static int row; int x = (Menu_start_x + 4 + column * FONT_WIDTH); @@ -623,7 +623,7 @@ static int drawMainScreen2(int TV_mode) strcpy(f, setting->LK_Path[i]); } } // ends clause for No title - if (setting->LK_Path[i][0] && nElfs++ == selected && mode == DPAD) + if (nElfs++ == selected && mode == DPAD) color = setting->color[COLOR_SELECT]; else color = setting->color[COLOR_TEXT]; @@ -1056,7 +1056,7 @@ int uLE_cdStop(void) //--------------------------------------------------------------------------- static void getExternalFilePath(const char *argPath, char *filePath) { - char *pathSep; + const char *pathSep; pathSep = strchr(argPath, '/'); @@ -1112,7 +1112,7 @@ static void getExternalFilePath(const char *argPath, char *filePath) // needed anymore, is entirely the responsibility of the caller, // though, of course, none is allocated if the file is not found. //--------------------------------------------------------------------------- -static int loadExternalFile(char *argPath, void **fileBaseP, int *fileSizeP) +static int loadExternalFile(const char *argPath, void **fileBaseP, int *fileSizeP) { // The first three variables are local variants similar to the arguments char filePath[MAX_PATH]; void *fileBase; @@ -1156,7 +1156,7 @@ static int loadExternalFile(char *argPath, void **fileBaseP, int *fileSizeP) // normally the value returned will be 1 for an internal default // module, but 2 for an external module.. //--------------------------------------------------------------------------- -static int loadExternalModule(char *modPath, void *defBase, int defSize) +static int loadExternalModule(const char *modPath, void *defBase, int defSize) { char filePath[MAX_PATH]; int ext_OK, def_OK; // Flags success for external and default module @@ -1366,7 +1366,7 @@ static void startKbd(void) //--------------------------------------------------------------------------- // scanSystemCnf will check for a standard variable of a SYSTEM.CNF file //------------------------------ -static int scanSystemCnf(char *name, char *value) +static int scanSystemCnf(const char *name, const char *value) { if (!strcmp(name, "BOOT")) strncat(SystemCnf_BOOT, value, MAX_PATH - 1); @@ -1436,7 +1436,7 @@ static void ShowFont(void) int test_type = 0; int test_types = 2; // Patch test_types for number of test loops int i, j, event, post_event = 0; - char Hex[18] = "0123456789ABCDEF"; + const char Hex[18] = "0123456789ABCDEF"; int ch_x_stp = 1 + FONT_WIDTH + 1 + LINE_THICKNESS; int ch_y_stp = 2 + FONT_HEIGHT + 1 + LINE_THICKNESS; int mat_w = LINE_THICKNESS + 17 * ch_x_stp; @@ -1747,13 +1747,13 @@ int IsSupportedFileType(char *path) // Execute. Execute an action. May be called recursively. // For any path specified, its device must be accessible. //------------------------------ -static void Execute(char *pathin) +static void Execute(const char *pathin) { char tmp[MAX_PATH]; static char path[MAX_PATH]; static char fullpath[MAX_PATH]; static char party[1024]; - char *pathSep; + const char *pathSep; char *p; int x, t = 0; char dvdpl_path[] = "mc0:/BREXEC-DVDPLAYER/dvdplayer.elf"; @@ -2288,7 +2288,7 @@ int main(int argc, char *argv[]) strcpy(temp, boot_path + 5); // Skip "hdd0:" when copying. t = strchr(temp, ':'); // Check if the separator between the block device & the path exists. if (t != NULL) { - char *p; + const char *p; *(t) = 0; // If it does, get the block device name. p = strchr(t + 1, ':'); // Get the path to the file @@ -2313,7 +2313,7 @@ int main(int argc, char *argv[]) strcpy(temp, boot_path + 9); // Skip "dvr_hdd0:" when copying. t = strchr(temp, ':'); // Check if the separator between the block device & the path exists. if (t != NULL) { - char *p; + const char *p; *(t) = 0; // If it does, get the block device name. p = strchr(t + 1, ':'); // Get the path to the file diff --git a/makeicon.c b/makeicon.c index 1d30219f..d5e9c3c8 100644 --- a/makeicon.c +++ b/makeicon.c @@ -74,7 +74,7 @@ struct icon_framedata void tex_drawChar(unsigned int c, int x, int y, u16 colour) { int i, j, k, pixMask; - u8 *cm; + const u8 *cm; u16 temp_image[16][32]; // blank out the memory(was causing issues before) @@ -233,7 +233,7 @@ u32 tex_compresRLE() * The position of the text is hard coded in on line 260 */ //-------------------------------------------------------------- -int make_icon(char *icontext, char *filename) +int make_icon(const char *icontext, const char *filename) { int i; struct icon_header icn_head; @@ -329,7 +329,7 @@ int make_icon(char *icontext, char *filename) * filename is where to store the icon.sys file(eg: mc0:/FOLDER/icon.sys) */ //-------------------------------------------------------------- -int make_iconsys(char *title, char *iconname, char *filename) +int make_iconsys(char *title, const char *iconname, const char *filename) { // mcIcon is defined as part of libmc mcIcon icon_sys; diff --git a/oldlibs/ps2ftpd/src/FileSystem.c b/oldlibs/ps2ftpd/src/FileSystem.c index ba7f9ae4..04a3ebdb 100644 --- a/oldlibs/ps2ftpd/src/FileSystem.c +++ b/oldlibs/ps2ftpd/src/FileSystem.c @@ -69,8 +69,6 @@ void FileSystem_Destroy(FSContext *pContext) int FileSystem_OpenFile(FSContext *pContext, const char *pFile, FileMode eMode, int iContinue) { int flags; - int fileMode = 0; - int iOpened = 0; FileSystem_Close(pContext); FileSystem_BuildPath(buffer, pContext->m_Path, pFile); @@ -98,7 +96,11 @@ int FileSystem_OpenFile(FSContext *pContext, const char *pFile, FileMode eMode, switch (pContext->m_eType) { case FS_IODEVICE: { + int fileMode = 0; + if (iContinue) { + int iOpened = 0; + if (flags & O_WRONLY) { pContext->m_kFile.mode = O_WRONLY; if (pContext->m_kFile.device->ops->open(&(pContext->m_kFile), pFile, pContext->m_kFile.mode, 0) >= 0) @@ -247,8 +249,8 @@ int FileSystem_WriteFile(FSContext *pContext, const char *pBuffer, int iSize) int FileSystem_ReadDir(FSContext *pContext, FSFileInfo *pInfo) { #ifdef LINUX - struct dirent *ent; - struct tm *t; + const struct dirent *ent; + const struct tm *t; struct stat s; memset(pInfo, 0, sizeof(FSFileInfo)); @@ -494,7 +496,7 @@ int FileSystem_ReadDir(FSContext *pContext, FSFileInfo *pInfo) } else { // evaluating devices - ModuleInfo_t *pkModule; + const ModuleInfo_t *pkModule; iop_device_t **ppkDevices; int num_devices; int dev_offset; @@ -725,7 +727,7 @@ int FileSystem_ChangeDir(FSContext *pContext, const char *pPath) if ((pContext->m_Path[strlen(pContext->m_Path) - 1] != '/')) strcat(pContext->m_Path, "/"); } else { - char *entry = strtok(buffer, "/"); + const char *entry = strtok(buffer, "/"); while (entry && strlen(entry) > 0) { if (!strcmp(entry, "..")) { @@ -915,7 +917,7 @@ ModuleInfo_t *FileSystem_GetModule(const char *pDevice) iop_device_t *FileSystem_ScanDevice(const char *pDevice, int iNumDevices, const char *pPath) { - ModuleInfo_t *pkModule; + const ModuleInfo_t *pkModule; iop_device_t **ppkDevices; int i; int offset; diff --git a/oldlibs/ps2ftpd/src/FtpClient.c b/oldlibs/ps2ftpd/src/FtpClient.c index 6e8dc1d0..3afa2bcd 100644 --- a/oldlibs/ps2ftpd/src/FtpClient.c +++ b/oldlibs/ps2ftpd/src/FtpClient.c @@ -166,7 +166,7 @@ void FtpClient_OnConnect(FtpClient *pClient) void FtpClient_OnCommand(FtpClient *pClient, const char *pString) { - char *c; + const char *c; assert(pClient); @@ -187,7 +187,7 @@ void FtpClient_OnCommand(FtpClient *pClient, const char *pString) switch (result) { // USER case FTPCMD_USER: { - char *user = strtok(NULL, ""); + const char *user = strtok(NULL, ""); if (user) FtpClient_OnCmdUser(pClient, user); @@ -197,7 +197,7 @@ void FtpClient_OnCommand(FtpClient *pClient, const char *pString) // PASS case FTPCMD_PASS: { - char *pass = strtok(NULL, ""); + const char *pass = strtok(NULL, ""); if (pass) FtpClient_OnCmdPass(pClient, pass); @@ -235,7 +235,7 @@ void FtpClient_OnCommand(FtpClient *pClient, const char *pString) int port = 0; for (i = 0; i < 6; i++) { - char *val = strtok(NULL, ","); + const char *val = strtok(NULL, ","); if (!val) break; @@ -267,7 +267,7 @@ void FtpClient_OnCommand(FtpClient *pClient, const char *pString) // LIST case FTPCMD_LIST: { - char *path = strtok(NULL, ""); + const char *path = strtok(NULL, ""); if (path) FtpClient_OnCmdList(pClient, path, 0); @@ -277,7 +277,7 @@ void FtpClient_OnCommand(FtpClient *pClient, const char *pString) // NLST case FTPCMD_NLST: { - char *path = strtok(NULL, ""); + const char *path = strtok(NULL, ""); if (path) FtpClient_OnCmdList(pClient, path, 1); @@ -304,7 +304,7 @@ void FtpClient_OnCommand(FtpClient *pClient, const char *pString) case FTPCMD_MODE: case FTPCMD_STRU: case FTPCMD_SIZE: { - char *arg = strtok(NULL, ""); + const char *arg = strtok(NULL, ""); if (arg) { switch (result) { diff --git a/oldlibs/ps2ftpd/src/FtpCommands.c b/oldlibs/ps2ftpd/src/FtpCommands.c index be6cf5c7..b31ed95f 100644 --- a/oldlibs/ps2ftpd/src/FtpCommands.c +++ b/oldlibs/ps2ftpd/src/FtpCommands.c @@ -394,7 +394,7 @@ void FtpClient_OnCmdSize(FtpClient *pClient, const char *pFile) void FtpClient_OnCmdSite(FtpClient *pClient, const char *pCmd) { - char *c; + const char *c; // copy command to clean buffer strcpy(buffer, pCmd); @@ -412,8 +412,8 @@ void FtpClient_OnCmdSite(FtpClient *pClient, const char *pCmd) #ifndef LINUX // SITE MNT case SITECMD_MNT: { - char *mount_point; - char *mount_file; + const char *mount_point; + const char *mount_file; // get mount point mount_point = strtok(NULL, " "); @@ -434,7 +434,7 @@ void FtpClient_OnCmdSite(FtpClient *pClient, const char *pCmd) // SITE UMNT case SITECMD_UMNT: { - char *mount_point = strtok(NULL, ""); + const char *mount_point = strtok(NULL, ""); if (mount_point) FtpClient_OnSiteUmount(pClient, mount_point); @@ -444,7 +444,7 @@ void FtpClient_OnCmdSite(FtpClient *pClient, const char *pCmd) // SITE SYNC case SITECMD_SYNC: { - char *devname = strtok(NULL, ""); + const char *devname = strtok(NULL, ""); if (devname) FtpClient_OnSiteSync(pClient, devname); diff --git a/oldlibs/ps2ftpd/src/FtpServer.c b/oldlibs/ps2ftpd/src/FtpServer.c index 2b402ed2..88b0ffd5 100644 --- a/oldlibs/ps2ftpd/src/FtpServer.c +++ b/oldlibs/ps2ftpd/src/FtpServer.c @@ -141,19 +141,19 @@ void FtpServer_SetAnonymous(FtpServer *pServer, int iAnonymous) pServer->m_iAnonymous = iAnonymous; } -void FtpServer_SetUsername(FtpServer *pServer, char *pUsername) +void FtpServer_SetUsername(FtpServer *pServer, const char *pUsername) { strncpy(pServer->m_Username, pUsername, sizeof(pServer->m_Username)); pServer->m_Username[sizeof(pServer->m_Username) - 1] = '\0'; } -void FtpServer_SetPassword(FtpServer *pServer, char *pPassword) +void FtpServer_SetPassword(FtpServer *pServer, const char *pPassword) { strncpy(pServer->m_Password, pPassword, sizeof(pServer->m_Password)); pServer->m_Password[sizeof(pServer->m_Password) - 1] = '\0'; } -int FtpServer_IsRunning(FtpServer *pServer) +int FtpServer_IsRunning(const FtpServer *pServer) { return (-1 != pServer->m_iSocket); } @@ -231,7 +231,7 @@ int FtpServer_HandleEvents(FtpServer *pServer) sizeof(pClient->m_CommandBuffer) - pClient->m_iCommandOffset, 0); if (rv > 0) { - char *rofs; + const char *rofs; char *nofs; pClient->m_CommandBuffer[pClient->m_iCommandOffset + rv] = '\0'; diff --git a/oldlibs/ps2ftpd/src/FtpServer.h b/oldlibs/ps2ftpd/src/FtpServer.h index f75edbc7..1638207c 100644 --- a/oldlibs/ps2ftpd/src/FtpServer.h +++ b/oldlibs/ps2ftpd/src/FtpServer.h @@ -55,10 +55,10 @@ void FtpServer_Stop(struct FtpServer *pServer); void FtpServer_SetPort(FtpServer *pServer, int iPort); void FtpServer_SetAnonymous(FtpServer *pServer, int iAnonymous); -void FtpServer_SetUsername(FtpServer *pServer, char *pUsername); -void FtpServer_SetPassword(FtpServer *pServer, char *pPassword); +void FtpServer_SetUsername(FtpServer *pServer, const char *pUsername); +void FtpServer_SetPassword(FtpServer *pServer, const char *pPassword); -int FtpServer_IsRunning(struct FtpServer *pServer); +int FtpServer_IsRunning(const struct FtpServer *pServer); int FtpServer_HandleEvents(struct FtpServer *pServer); FtpClient *FtpServer_OnClientConnect(struct FtpServer *pServer, int iSocket); void FtpServer_OnClientDisconnect(const struct FtpServer *pServer, FtpClient *pClient); diff --git a/ps2host/net_fio.c b/ps2host/net_fio.c index 4814903e..d3ee53a5 100644 --- a/ps2host/net_fio.c +++ b/ps2host/net_fio.c @@ -83,7 +83,7 @@ pko_lwip_send(int sock, void *buf, int len, int flag) //---------------------------------------------------------------------- // Do repetetive recv() calles until 'bytes' bytes are received // or error returned -int pko_recv_bytes(int sock, char *buf, int bytes) +int pko_recv_bytes(int fd, char *buf, int bytes) { int left; @@ -92,7 +92,7 @@ int pko_recv_bytes(int sock, char *buf, int bytes) while (left > 0) { int len; - len = recv(sock, &buf[bytes - left], left, 0); + len = recv(fd, &buf[bytes - left], left, 0); if (len < 0) { dbgprintf("pko_file: pko_recv_bytes error!!\n"); return -1; @@ -105,7 +105,7 @@ int pko_recv_bytes(int sock, char *buf, int bytes) //---------------------------------------------------------------------- // Receive a 'packet' of the expected type 'pkt_type', and lenght 'len' -int pko_accept_pkt(int sock, char *buf, int len, int pkt_type) +int pko_accept_pkt(int fd, char *buf, int len, int pkt_type) { int length; pko_pkt_hdr *hdr; @@ -113,7 +113,7 @@ int pko_accept_pkt(int sock, char *buf, int len, int pkt_type) unsigned short hlen; - length = pko_recv_bytes(sock, buf, sizeof(pko_pkt_hdr)); + length = pko_recv_bytes(fd, buf, sizeof(pko_pkt_hdr)); if (length < 0) { dbgprintf("pko_file: accept_pkt recv error\n"); return -1; @@ -143,7 +143,7 @@ int pko_accept_pkt(int sock, char *buf, int len, int pkt_type) } // get the actual packet data - length = pko_recv_bytes(sock, buf + sizeof(pko_pkt_hdr), + length = pko_recv_bytes(fd, buf + sizeof(pko_pkt_hdr), hlen - sizeof(pko_pkt_hdr)); if (length < 0) { @@ -162,7 +162,7 @@ int pko_accept_pkt(int sock, char *buf, int len, int pkt_type) //---------------------------------------------------------------------- // -int pko_open_file(char *path, int flags) +int pko_open_file(const char *path, int flags) { pko_pkt_open_req *openreq; pko_pkt_file_rly *openrly; @@ -279,7 +279,7 @@ int pko_lseek_file(int fd, unsigned int offset, int whence) //---------------------------------------------------------------------- // -int pko_write_file(int fd, char *buf, int length) +int pko_write_file(int fd, const char *buf, int length) { pko_pkt_write_req *writecmd; pko_pkt_file_rly *writerly; @@ -416,7 +416,7 @@ int pko_read_file(int fd, char *buf, int length) //---------------------------------------------------------------------- // -int pko_ioctl(int fd, unsigned long request, void *data) +int pko_ioctl(int fd, unsigned long request, const void *data) { pko_pkt_ioctl_req *ioctlreq; pko_pkt_file_rly *ioctlrly; @@ -453,7 +453,7 @@ int pko_ioctl(int fd, unsigned long request, void *data) //---------------------------------------------------------------------- // -int pko_remove(char *name) +int pko_remove(const char *name) { pko_pkt_remove_req *removereq; pko_pkt_file_rly *removerly; @@ -489,7 +489,7 @@ int pko_remove(char *name) //---------------------------------------------------------------------- // -int pko_mkdir(char *name, int mode) +int pko_mkdir(const char *name, int mode) { pko_pkt_mkdir_req *mkdirreq; pko_pkt_file_rly *mkdirrly; @@ -526,7 +526,7 @@ int pko_mkdir(char *name, int mode) //---------------------------------------------------------------------- // -int pko_rmdir(char *name) +int pko_rmdir(const char *name) { pko_pkt_rmdir_req *rmdirreq; pko_pkt_file_rly *rmdirrly; @@ -562,7 +562,7 @@ int pko_rmdir(char *name) //---------------------------------------------------------------------- // -int pko_open_dir(char *path) +int pko_open_dir(const char *path) { pko_pkt_open_req *openreq; pko_pkt_file_rly *openrly; @@ -689,7 +689,7 @@ int pko_close_dir(int fd) //---------------------------------------------------------------------- // Thread that waits for a PC to connect/disconnect/reconnect blah.. -int pko_file_serv(void *argv) +int pko_file_serv(void *arg) { struct sockaddr_in server_addr; struct sockaddr_in client_addr; diff --git a/ps2host/net_fio.h b/ps2host/net_fio.h index 69522ceb..0db6f19c 100644 --- a/ps2host/net_fio.h +++ b/ps2host/net_fio.h @@ -12,21 +12,21 @@ int pko_file_serv(void *arg); int pko_recv_bytes(int fd, char *buf, int bytes); int pko_accept_pkt(int fd, char *buf, int len, int pkt_type); -int pko_open_file(char *path, int flags); +int pko_open_file(const char *path, int flags); int pko_close_file(int fd); int pko_read_file(int fd, char *buf, int length); -int pko_write_file(int fd, char *buf, int length); +int pko_write_file(int fd, const char *buf, int length); int pko_lseek_file(int fd, unsigned int offset, int whence); void pko_close_socket(void); void pko_close_fsys(void); -int pko_open_dir(char *path); +int pko_open_dir(const char *path); int pko_read_dir(int fd, void *buf); int pko_close_dir(int fd); int pko_make_dir(char *path); -int pko_ioctl(int fd, unsigned long request, void *data); -int pko_remove(char *name); -int pko_mkdir(char *name, int mode); -int pko_rmdir(char *name); +int pko_ioctl(int fd, unsigned long request, const void *data); +int pko_remove(const char *name); +int pko_mkdir(const char *name, int mode); +int pko_rmdir(const char *name); /* * Don't want printfs to broadcast in case more than 1 ps2 on the same network, so at * connect time, the remote PC's IP is stored here and used as destination for printfs. diff --git a/ps2host/net_fsys.c b/ps2host/net_fsys.c index 12f02930..f862e647 100644 --- a/ps2host/net_fsys.c +++ b/ps2host/net_fsys.c @@ -171,7 +171,7 @@ static int fsysClose(int fd) //---------------------------------------------------------------------------- static int fsysRead(int fd, char *buf, int size) { - struct filedesc_info *fd_info; + const struct filedesc_info *fd_info; int ret; fd_info = (struct filedesc_info *)fd; @@ -194,7 +194,7 @@ static int fsysRead(int fd, char *buf, int size) //---------------------------------------------------------------------------- static int fsysWrite(int fd, char *buf, int size) { - struct filedesc_info *fd_info; + const struct filedesc_info *fd_info; int ret; dbgprintf("fsysWrite..." @@ -212,7 +212,7 @@ static int fsysWrite(int fd, char *buf, int size) //---------------------------------------------------------------------------- static int fsysLseek(int fd, unsigned int offset, int whence) { - struct filedesc_info *fd_info; + const struct filedesc_info *fd_info; int ret; dbgprintf("fsysLseek..\n" @@ -232,7 +232,6 @@ static int fsysLseek(int fd, unsigned int offset, int whence) //---------------------------------------------------------------------------- static int fsysIoctl(iop_file_t *file, unsigned long request, void *data) { - int remote_fd = ((struct filedesc_info *)file)->own_fd; int ret; dbgprintf("fsysioctl..\n"); // dbgprintf(" fd: %x\n" @@ -242,6 +241,8 @@ static int fsysIoctl(iop_file_t *file, unsigned long request, void *data) remove_flag = 0; if (request == IOCTL_RENAME) { + int remote_fd = ((struct filedesc_info *)file)->own_fd; + if (lastopen_fd == remote_fd) { WaitSema(fsys_sema); ret = pko_ioctl(remote_fd, request, data); @@ -354,7 +355,7 @@ static int fsysDclose(int fd) //---------------------------------------------------------------------------- static int fsysDread(int fd, void *buf) { - struct filedesc_info *fd_info; + const struct filedesc_info *fd_info; int ret; fd_info = (struct filedesc_info *)fd; diff --git a/vmc_fs/vmc.h b/vmc_fs/vmc.h index 2d7671b0..d065a3c3 100644 --- a/vmc_fs/vmc.h +++ b/vmc_fs/vmc.h @@ -251,7 +251,7 @@ int Vmc_Mkdir(iop_file_t *f, const char *path1, int mode); int Vmc_Rmdir(iop_file_t *f, const char *path1); int Vmc_Dopen(iop_file_t *f, const char *path); int Vmc_Dclose(iop_file_t *f); -int Vmc_Dread(iop_file_t *f, iox_dirent_t *buf); +int Vmc_Dread(iop_file_t *f, iox_dirent_t *buffer); int Vmc_Getstat(iop_file_t *f, const char *path, iox_stat_t *stat); int Vmc_Chstat(iop_file_t *f, const char *path, iox_stat_t *stat, unsigned int statmask); int Vmc_Rename(iop_file_t *f, const char *path, const char *new_name); @@ -286,17 +286,17 @@ unsigned int setFatEntry(int fd, unsigned int cluster, unsigned int value, const // ps2.c int eraseBlock(int fd, unsigned int block); int writePage(int fd, u8 *page, unsigned int pagenum); -int writeCluster(int fd, u8 *cluster, unsigned int clusternum); -int writeClusterPart(int fd, u8 *cluster, unsigned int clusternum, int cluster_offset, int size); +int writeCluster(int fd, const u8 *cluster, unsigned int clusternum); +int writeClusterPart(int fd, const u8 *cluster, unsigned int clusternum, int cluster_offset, int size); int readPage(int fd, u8 *page, unsigned int pagenum); int readCluster(int fd, u8 *cluster, unsigned int clusternum); // misc.c unsigned int getDirentryFromPath(struct direntry *retval, const char *path, struct gen_privdata *gendata, int unit); -unsigned int addObject(struct gen_privdata *gendata, unsigned int parentcluster, struct direntry *parent, struct direntry *dirent, int unit); -void removeObject(struct gen_privdata *gendata, unsigned int dirent_cluster, struct direntry *dirent, int unit); -unsigned int getFreeCluster(struct gen_privdata *gendata, int unit); +unsigned int addObject(struct gen_privdata *gendata, unsigned int parent_cluster, struct direntry *parent, struct direntry *dirent, int unit); +void removeObject(const struct gen_privdata *gendata, unsigned int dirent_cluster, struct direntry *dirent, int unit); +unsigned int getFreeCluster(const struct gen_privdata *gendata, int unit); int getPs2Time(vmc_datetime *tm); int setDefaultSpec(int unit); void buildECC(int unit, const u8 *Page_Data, u8 *ECC_Data); diff --git a/vmc_fs/vmc_io.c b/vmc_fs/vmc_io.c index df3d388c..28cff48d 100644 --- a/vmc_fs/vmc_io.c +++ b/vmc_fs/vmc_io.c @@ -33,7 +33,7 @@ int Vmc_Format(iop_file_t *f, const char *dev, const char *blockdev, void *arg, for (i = 0; i < g_Vmc_Image[f->unit].total_pages / g_Vmc_Image[f->unit].header.pages_per_block; i++) { - DEBUGPRINT(7, "vmc_fs: format erasing block %d / %d\r", i, g_Vmc_Image[f->unit].total_pages / g_Vmc_Image[f->unit].header.pages_per_block); + DEBUGPRINT(7, "vmc_fs: format erasing block %u / %d\r", i, g_Vmc_Image[f->unit].total_pages / g_Vmc_Image[f->unit].header.pages_per_block); eraseBlock(g_Vmc_Image[f->unit].fd, i); } } @@ -148,13 +148,13 @@ int Vmc_Format(iop_file_t *f, const char *dev, const char *blockdev, void *arg, //---------------------------------------------------------------------------- // Open a file from vmc image. open("vmc... //---------------------------------------------------------------------------- -int Vmc_Open(iop_file_t *f, const char *path1, int flags, int mode) +int Vmc_Open(iop_file_t *f, const char *name, int flags, int mode) { if (!g_Vmc_Initialized) return VMCFS_ERR_INITIALIZED; - DEBUGPRINT(1, "vmc_fs: Open %i %s\n", f->unit, path1); + DEBUGPRINT(1, "vmc_fs: Open %i %s\n", f->unit, name); if (g_Vmc_Image[f->unit].fd < 0) return VMCFS_ERR_NOT_MOUNT; @@ -178,7 +178,7 @@ int Vmc_Open(iop_file_t *f, const char *path1, int flags, int mode) memcpy(fprivdata->gendata.indir_fat_clusters, g_Vmc_Image[f->unit].header.indir_fat_clusters, sizeof(unsigned int) * 32); - unsigned int dirent_cluster = getDirentryFromPath(&dirent, path1, &(fprivdata->gendata), f->unit); + unsigned int dirent_cluster = getDirentryFromPath(&dirent, name, &(fprivdata->gendata), f->unit); if (dirent_cluster == ROOT_CLUSTER) { @@ -197,8 +197,8 @@ int Vmc_Open(iop_file_t *f, const char *path1, int flags, int mode) struct direntry parent; unsigned int parent_cluster = 0; - char *path = malloc(strlen(path1) + 1); // + 1 for null terminator - memcpy(path, path1, strlen(path1) + 1); // create a local copy to work with + char *path = malloc(strlen(name) + 1); // + 1 for null terminator + memcpy(path, name, strlen(name) + 1); // create a local copy to work with char *filename = strrchr(path, '/'); // last occurance of / , which should split the file name from the folders @@ -246,7 +246,7 @@ int Vmc_Open(iop_file_t *f, const char *path1, int flags, int mode) if (dirent_cluster == ERROR_CLUSTER) { - DEBUGPRINT(2, "vmc_fs: open failed on %s\n", path1); + DEBUGPRINT(2, "vmc_fs: open failed on %s\n", name); free(path); free(fprivdata); // Release the allocated memory @@ -335,7 +335,7 @@ int Vmc_Open(iop_file_t *f, const char *path1, int flags, int mode) fprivdata->file_startcluster = dirent.cluster; fprivdata->file_length = dirent.length; // set the length to what it should be, and go from there - DEBUGPRINT(2, "vmc_fs: File %s opened with length %u\n", path1, fprivdata->file_length); + DEBUGPRINT(2, "vmc_fs: File %s opened with length %u\n", name, fprivdata->file_length); PROF_END(vmc_openProf) @@ -536,21 +536,21 @@ int Vmc_Write(iop_file_t *f, void *buffer, int size) if ((fprivdata->file_length % g_Vmc_Image[f->unit].cluster_size) > 0) num_clusters++; - DEBUGPRINT(5, "vmc_fs: File lenght in cluster before this write: %u\n", num_clusters); + DEBUGPRINT(5, "vmc_fs: File lenght in cluster before this write: %d\n", num_clusters); int num_clusters_required = (fprivdata->file_position + size) / g_Vmc_Image[f->unit].cluster_size; if (((fprivdata->file_position + size) % g_Vmc_Image[f->unit].cluster_size) > 0) num_clusters_required++; - DEBUGPRINT(5, "vmc_fs: File lenght in cluster after this write : %u\n", num_clusters_required); + DEBUGPRINT(5, "vmc_fs: File lenght in cluster after this write : %d\n", num_clusters_required); if (num_clusters_required > num_clusters) { fprivdata->file_length = fprivdata->file_position + size; DEBUGPRINT(3, "vmc_fs: File position: %u\n", fprivdata->file_position); - DEBUGPRINT(3, "vmc_fs: Size to write: %u\n", size); + DEBUGPRINT(3, "vmc_fs: Size to write: %d\n", size); DEBUGPRINT(3, "vmc_fs: File length : %u\n", fprivdata->file_length); // now determine how many clusters we need forthis write @@ -602,7 +602,7 @@ int Vmc_Write(iop_file_t *f, void *buffer, int size) if (current_cluster == FREE_CLUSTER) { - DEBUGPRINT(10, "vmc_fs: Testing cluster %d ... value is FREE_CLUSTER\n", last_cluster); + DEBUGPRINT(10, "vmc_fs: Testing cluster %u ... value is FREE_CLUSTER\n", last_cluster); } else if (current_cluster == EOF_CLUSTER) { @@ -611,7 +611,7 @@ int Vmc_Write(iop_file_t *f, void *buffer, int size) } else { - DEBUGPRINT(10, "vmc_fs: Testing cluster %d ... value is %d\n", last_cluster, current_cluster); + DEBUGPRINT(10, "vmc_fs: Testing cluster %u ... value is %u\n", last_cluster, current_cluster); } last_cluster = current_cluster; @@ -1740,8 +1740,8 @@ int Vmc_Mount(iop_file_t *f, const char *fsname, const char *devname, int flag, goto mountAbort; } - DEBUGPRINT(4, "vmc_fs: Image file Info: Number of pages : %d\n", g_Vmc_Image[f->unit].total_pages); - DEBUGPRINT(4, "vmc_fs: Image file Info: Size of a cluster : %d bytes\n", g_Vmc_Image[f->unit].cluster_size); + DEBUGPRINT(4, "vmc_fs: Image file Info: Number of pages : %u\n", g_Vmc_Image[f->unit].total_pages); + DEBUGPRINT(4, "vmc_fs: Image file Info: Size of a cluster : %u bytes\n", g_Vmc_Image[f->unit].cluster_size); DEBUGPRINT(4, "vmc_fs: Image file Info: ECC shunk found : %s\n", g_Vmc_Image[f->unit].ecc_flag ? "YES" : "NO"); } diff --git a/vmc_fs/vmc_misc.c b/vmc_fs/vmc_misc.c index fe694997..a0d5c687 100644 --- a/vmc_fs/vmc_misc.c +++ b/vmc_fs/vmc_misc.c @@ -134,7 +134,7 @@ unsigned int getDirentryFromPath(struct direntry *retval, const char *path, stru //---------------------------------------------------------------------------- // Add 2 pseudo entries for a new directory //---------------------------------------------------------------------------- -unsigned int addPseudoEntries(struct gen_privdata *gendata, struct direntry *parent, int unit) +unsigned int addPseudoEntries(const struct gen_privdata *gendata, const struct direntry *parent, int unit) { // Get a free cluster we can use to store the entries '.' and '..' @@ -290,7 +290,7 @@ unsigned int addObject(struct gen_privdata *gendata, unsigned int parent_cluster // Set as free the last cluster of the direntry. // Finaly, set deleted flag of the direntry. ( DF_EXISTS flag ) //---------------------------------------------------------------------------- -void removeObject(struct gen_privdata *gendata, unsigned int dirent_cluster, struct direntry *dirent, int unit) +void removeObject(const struct gen_privdata *gendata, unsigned int dirent_cluster, struct direntry *dirent, int unit) { unsigned int last_cluster = dirent->cluster; @@ -339,7 +339,7 @@ void removeObject(struct gen_privdata *gendata, unsigned int dirent_cluster, str //---------------------------------------------------------------------------- // Return a free cluster. //---------------------------------------------------------------------------- -unsigned int getFreeCluster(struct gen_privdata *gendata, int unit) +unsigned int getFreeCluster(const struct gen_privdata *gendata, int unit) { unsigned int i; @@ -352,26 +352,26 @@ unsigned int getFreeCluster(struct gen_privdata *gendata, int unit) if (value == FREE_CLUSTER) { - DEBUGPRINT(10, "vmc_fs: Testing fat table cluster %d ... value is FREE_CLUSTER\n", i - gendata->first_allocatable); + DEBUGPRINT(10, "vmc_fs: Testing fat table cluster %u ... value is FREE_CLUSTER\n", i - gendata->first_allocatable); - DEBUGPRINT(6, "vmc_fs: Free cluster found at %d in fat table\n", i - gendata->first_allocatable); + DEBUGPRINT(6, "vmc_fs: Free cluster found at %u in fat table\n", i - gendata->first_allocatable); g_Vmc_Image[unit].last_free_cluster = i; return (i - gendata->first_allocatable); } else if (value == EOF_CLUSTER) { - DEBUGPRINT(10, "vmc_fs: Testing fat table cluster %d ... value is EOF_CLUSTER\n", i - gendata->first_allocatable); + DEBUGPRINT(10, "vmc_fs: Testing fat table cluster %u ... value is EOF_CLUSTER\n", i - gendata->first_allocatable); } else { - DEBUGPRINT(10, "vmc_fs: Testing fat table cluster %d ... value is %d\n", i - gendata->first_allocatable, value); + DEBUGPRINT(10, "vmc_fs: Testing fat table cluster %u ... value is %u\n", i - gendata->first_allocatable, value); cluster_mask = getFatEntry(gendata->fd, i - gendata->first_allocatable, gendata->indir_fat_clusters, FAT_MASK); if (cluster_mask != MASK_CLUSTER) { - DEBUGPRINT(6, "vmc_fs: Free cluster found at %d in fat table\n", i - gendata->first_allocatable); + DEBUGPRINT(6, "vmc_fs: Free cluster found at %u in fat table\n", i - gendata->first_allocatable); g_Vmc_Image[unit].last_free_cluster = i; return (i - gendata->first_allocatable); @@ -428,8 +428,8 @@ int setDefaultSpec(int unit) g_Vmc_Image[unit].header.mc_type = 0x2; g_Vmc_Image[unit].header.mc_flag = 0x2B; - DEBUGPRINT(4, "vmc_fs: Image file Info: Number of pages : %d\n", g_Vmc_Image[unit].total_pages); - DEBUGPRINT(4, "vmc_fs: Image file Info: Size of a cluster : %d bytes\n", g_Vmc_Image[unit].cluster_size); + DEBUGPRINT(4, "vmc_fs: Image file Info: Number of pages : %u\n", g_Vmc_Image[unit].total_pages); + DEBUGPRINT(4, "vmc_fs: Image file Info: Size of a cluster : %u bytes\n", g_Vmc_Image[unit].cluster_size); DEBUGPRINT(4, "vmc_fs: Image file Info: ECC shunk found : %s\n", g_Vmc_Image[unit].ecc_flag ? "YES" : "NO"); DEBUGPRINT(3, "vmc_fs: Image file Info: Vmc card type : %s MemoryCard.\n", (g_Vmc_Image[unit].header.mc_type == PSX_MEMORYCARD ? "PSX" : (g_Vmc_Image[unit].header.mc_type == PS2_MEMORYCARD ? "PS2" : "PDA"))); DEBUGPRINT(4, "vmc_fs: SuperBlock Info: page_size : 0x%02x\n", g_Vmc_Image[unit].header.page_size); diff --git a/vmc_fs/vmc_ps2.c b/vmc_fs/vmc_ps2.c index 08f98a7c..3c31a249 100644 --- a/vmc_fs/vmc_ps2.c +++ b/vmc_fs/vmc_ps2.c @@ -88,7 +88,7 @@ int writePage(int fd, u8 *page, unsigned int pagenum) return 0; } -int writeCluster(int fd, u8 *cluster, unsigned int clusternum) +int writeCluster(int fd, const u8 *cluster, unsigned int clusternum) { int i, unit; @@ -114,7 +114,7 @@ int writeCluster(int fd, u8 *cluster, unsigned int clusternum) return 0; } -int writeClusterPart(int fd, u8 *cluster, unsigned int clusternum, int cluster_offset, int size) +int writeClusterPart(int fd, const u8 *cluster, unsigned int clusternum, int cluster_offset, int size) { int i, unit;