From a8ca8cea9d884ed57b3bb803108a4e16fedf66a6 Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Sat, 18 May 2024 10:21:36 -0500 Subject: [PATCH] fix: Fix instances of variableScope --- filer.c | 10 ++++++++-- hdl_info/apa.c | 14 +++++++------- ps2host/net_fsys.c | 3 ++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/filer.c b/filer.c index 68a2faec..fab4ce30 100644 --- a/filer.c +++ b/filer.c @@ -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]; @@ -3259,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; @@ -3370,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]; @@ -3382,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; 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/ps2host/net_fsys.c b/ps2host/net_fsys.c index c1d439fb..f862e647 100644 --- a/ps2host/net_fsys.c +++ b/ps2host/net_fsys.c @@ -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);