From 626d87a7b537f4c8102a219c60d74655790d4cc3 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:10:30 -0500 Subject: [PATCH 01/22] Ignore -Warray-bounds and -Wstringop-overflow for memset of address --- src/system.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/system.c b/src/system.c index 97dee80d1..9eafdaa26 100644 --- a/src/system.c +++ b/src/system.c @@ -746,7 +746,11 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv // Wipe the low user memory region, since this region might not be wiped after OPL's EE core is installed. // Start wiping from 0x00084000 instead (as the HDD Browser does), as the alarm patch is installed at 0x00082000. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow" memset((void *)0x00084000, 0, 0x00100000 - 0x00084000); +#pragma GCC diagnostic pop modules = 0; ModuleStorage = GetModStorageLocation(filename, compatflags); From 0b49b1f46963562302684d65ca2ae99f9320578e Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:16:32 -0500 Subject: [PATCH 02/22] ethsupport: fix strict aliasing --- src/ethsupport.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/ethsupport.c b/src/ethsupport.c index 1522c2cb3..4fa728162 100644 --- a/src/ethsupport.c +++ b/src/ethsupport.c @@ -787,9 +787,9 @@ static int ethReadNetConfig(void) int result; if ((result = ps2ip_getconfig("sm0", &ip_info)) >= 0) { - lastIP = *(struct ip4_addr *)&ip_info.ipaddr; - lastNM = *(struct ip4_addr *)&ip_info.netmask; - lastGW = *(struct ip4_addr *)&ip_info.gw; + memcpy(&lastIP, &ip_info.ipaddr, sizeof(lastIP)); + memcpy(&lastNM, &ip_info.netmask, sizeof(lastNM)); + memcpy(&lastGW, &ip_info.gw, sizeof(lastGW)); } else { ip4_addr_set_zero(&lastIP); ip4_addr_set_zero(&lastNM); @@ -863,10 +863,15 @@ static int ethApplyIPConfig(void) { t_ip_info ip_info; struct ip4_addr ipaddr, netmask, gw, dns; + struct ip4_addr ipaddr_ip_info, netmask_ip_info, gw_ip_info; const struct ip4_addr *dns_curr; int result; if ((result = ps2ip_getconfig("sm0", &ip_info)) >= 0) { + memcpy(&ipaddr_ip_info, (struct ip4_addr *)&ip_info.ipaddr, sizeof(ipaddr_ip_info)); + memcpy(&netmask_ip_info, (struct ip4_addr *)&ip_info.netmask, sizeof(netmask_ip_info)); + memcpy(&gw_ip_info, (struct ip4_addr *)&ip_info.gw, sizeof(gw_ip_info)); + IP4_ADDR(&ipaddr, ps2_ip[0], ps2_ip[1], ps2_ip[2], ps2_ip[3]); IP4_ADDR(&netmask, ps2_netmask[0], ps2_netmask[1], ps2_netmask[2], ps2_netmask[3]); IP4_ADDR(&gw, ps2_gateway[0], ps2_gateway[1], ps2_gateway[2], ps2_gateway[3]); @@ -875,21 +880,24 @@ static int ethApplyIPConfig(void) // Check if it's the same. Otherwise, apply the new configuration. if ((ps2_ip_use_dhcp != ip_info.dhcp_enabled) || (!ps2_ip_use_dhcp && - (!ip_addr_cmp(&ipaddr, (struct ip4_addr *)&ip_info.ipaddr) || - !ip_addr_cmp(&netmask, (struct ip4_addr *)&ip_info.netmask) || - !ip_addr_cmp(&gw, (struct ip4_addr *)&ip_info.gw) || + (!ip_addr_cmp(&ipaddr, &ipaddr_ip_info) || + !ip_addr_cmp(&netmask, &netmask_ip_info) || + !ip_addr_cmp(&gw, &gw_ip_info) || !ip_addr_cmp(&dns, dns_curr)))) { if (ps2_ip_use_dhcp) { - ip4_addr_set_zero((struct ip4_addr *)&ip_info.ipaddr); - ip4_addr_set_zero((struct ip4_addr *)&ip_info.netmask); - ip4_addr_set_zero((struct ip4_addr *)&ip_info.gw); + ip4_addr_set_zero(&ipaddr_ip_info); + memcpy((struct ip4_addr *)&ip_info.ipaddr, &ipaddr_ip_info, sizeof(ipaddr_ip_info)); + ip4_addr_set_zero(&netmask_ip_info); + memcpy((struct ip4_addr *)&ip_info.netmask, &netmask_ip_info, sizeof(netmask_ip_info)); + ip4_addr_set_zero(&gw_ip_info); + memcpy((struct ip4_addr *)&ip_info.gw, &gw_ip_info, sizeof(gw_ip_info)); ip4_addr_set_zero(&dns); ip_info.dhcp_enabled = 1; } else { - ip_addr_set((struct ip4_addr *)&ip_info.ipaddr, &ipaddr); - ip_addr_set((struct ip4_addr *)&ip_info.netmask, &netmask); - ip_addr_set((struct ip4_addr *)&ip_info.gw, &gw); + ip_addr_set(&ipaddr_ip_info, &ipaddr); + ip_addr_set(&netmask_ip_info, &netmask); + ip_addr_set(&gw_ip_info, &gw); ip_info.dhcp_enabled = 0; } From 78e46db177a8f80c91f918eabf1831e5d4b07fe6 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:20:15 -0500 Subject: [PATCH 03/22] cdvdman: copy without an intermediate buffer --- modules/iopcore/cdvdman/cdvdman.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/iopcore/cdvdman/cdvdman.c b/modules/iopcore/cdvdman/cdvdman.c index 4efed3bbd..c9f4a2c36 100644 --- a/modules/iopcore/cdvdman/cdvdman.c +++ b/modules/iopcore/cdvdman/cdvdman.c @@ -431,7 +431,6 @@ static int cdvdman_writeSCmd(u8 cmd, const void *in, u16 in_size, void *out, u16 { int i; u8 *p; - u8 rdbuf[64]; WaitSema(cdvdman_scmdsema); @@ -463,16 +462,20 @@ static int cdvdman_writeSCmd(u8 cmd, const void *in, u16 in_size, void *out, u16 i = 0; if (!(CDVDreg_SDATAIN & 0x40)) { do { - p = (void *)(rdbuf + i); + if (i >= out_size) { + break; + } + p = (void *)(out + i); *p = CDVDreg_SDATAOUT; i++; } while (!(CDVDreg_SDATAIN & 0x40)); } - if (out_size > i) - out_size = i; - - memcpy((void *)out, (void *)rdbuf, out_size); + if (!(CDVDreg_SDATAIN & 0x40)) { + do { + (void)CDVDreg_SDATAOUT; + } while (!(CDVDreg_SDATAIN & 0x40)); + } SignalSema(cdvdman_scmdsema); From 67e887dbdc3b701910106af4c50b9355e4384760 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:21:26 -0500 Subject: [PATCH 04/22] ps2link/net_fio: call memcpy on ctime/atime/mtime individually --- modules/debug/ps2link/net_fio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/debug/ps2link/net_fio.c b/modules/debug/ps2link/net_fio.c index ec63a305f..9fccf2cb2 100644 --- a/modules/debug/ps2link/net_fio.c +++ b/modules/debug/ps2link/net_fio.c @@ -602,7 +602,9 @@ int pko_read_dir(int fd, void *buf) dirent->stat.attr = ntohl(dirrly->attr); dirent->stat.size = ntohl(dirrly->size); dirent->stat.hisize = ntohl(dirrly->hisize); - memcpy(dirent->stat.ctime, dirrly->ctime, 8 * 3); + memcpy(dirent->stat.ctime, dirrly->ctime, 8); + memcpy(dirent->stat.atime, dirrly->atime, 8); + memcpy(dirent->stat.mtime, dirrly->mtime, 8); strncpy(dirent->name, dirrly->name, 256); dirent->unknown = 0; From 4768c3107296c9b4c73bf0e7036b2cd83ce6a57a Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:22:49 -0500 Subject: [PATCH 05/22] textures: return error if texId is -1 and path not given --- src/textures.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/textures.c b/src/textures.c index 942686eac..0467ec9dd 100644 --- a/src/textures.c +++ b/src/textures.c @@ -475,6 +475,8 @@ static int texPngLoadAll(GSTEXTURE *texture, const char *filePath, int texId) readFunction = NULL; // Use default reading function. } else { + if (texId == -1) + return ERR_BAD_FILE; if (!internalDefault[texId].texture) return ERR_BAD_FILE; From 6f8032f0d6bc764d12e32e775fa25005e941c969 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:24:06 -0500 Subject: [PATCH 06/22] Remove useless size assignment when reading sector --- modules/iopcore/cdvdman/ioops.c | 1 - modules/isofs/isofs.c | 1 - 2 files changed, 2 deletions(-) diff --git a/modules/iopcore/cdvdman/ioops.c b/modules/iopcore/cdvdman/ioops.c index d512d417f..059431612 100644 --- a/modules/iopcore/cdvdman/ioops.c +++ b/modules/iopcore/cdvdman/ioops.c @@ -296,7 +296,6 @@ static int cdrom_read(iop_file_t *f, void *buf, int size) while (sceCdRead(fh->lsn + (fh->position / 2048), 1, cdvdman_fs_buf, NULL) == 0) DelayThread(10000); - size -= nbytes; fh->position += nbytes; rpos += nbytes; diff --git a/modules/isofs/isofs.c b/modules/isofs/isofs.c index 02368bc6d..c43567fd7 100644 --- a/modules/isofs/isofs.c +++ b/modules/isofs/isofs.c @@ -423,7 +423,6 @@ static int IsofsRead(iop_file_t *f, void *buf, int size) if ((nbytes = size) > 0) { cdEmuRead(fh->lsn + (fh->position / 2048), 1, cdvdman_fs_buf); - size -= nbytes; fh->position += nbytes; rpos += nbytes; From 95b82082766071aae8faa831c6eb3d3052509033 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:25:05 -0500 Subject: [PATCH 07/22] smap: make comparison more explicit --- modules/network/smap-ingame/smap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/network/smap-ingame/smap.c b/modules/network/smap-ingame/smap.c index fb666f18d..83d16f3ca 100644 --- a/modules/network/smap-ingame/smap.c +++ b/modules/network/smap-ingame/smap.c @@ -563,7 +563,7 @@ int smap_init(int argc, char *argv[]) SmapDriverData.smap_regbase = smap_regbase; SmapDriverData.emac3_regbase = emac3_regbase; - if (!SPD_REG16(SPD_R_REV_3) & SPD_CAPS_SMAP) + if ((SPD_REG16(SPD_R_REV_3) & SPD_CAPS_SMAP) == 0) return -1; if (SPD_REG16(SPD_R_REV_1) < 0x11) return -6; // Minimum: revision 17, ES2. From f850e1509a4243e7f8d1038bc82ca4f57362276c Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:26:35 -0500 Subject: [PATCH 08/22] Remove always true conditions --- modules/debug/ps2link/cmdHandler.c | 5 +---- src/opl.c | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/debug/ps2link/cmdHandler.c b/modules/debug/ps2link/cmdHandler.c index 7e9dfc1b0..bc320e73d 100644 --- a/modules/debug/ps2link/cmdHandler.c +++ b/modules/debug/ps2link/cmdHandler.c @@ -240,16 +240,13 @@ pkoWriteMem(char *buf, int len) static void cmdListener(int sock) { - int done; int len; int addrlen; unsigned int cmd; pko_pkt_hdr *header; struct sockaddr_in remote_addr; - done = 0; - - while (!done) { + while (1) { addrlen = sizeof(remote_addr); len = recvfrom(sock, &recvbuf[0], BUF_SIZE, 0, diff --git a/src/opl.c b/src/opl.c index cb10016ff..5c267412b 100644 --- a/src/opl.c +++ b/src/opl.c @@ -368,7 +368,7 @@ static void initSupport(item_list_t *itemList, int startMode, int mode, int forc initMenuForListSupport(mode); } - if (((force_reinit) && (startMode && mod->support->enabled)) || (startMode == START_MODE_AUTO && !mod->support->enabled)) { + if (((force_reinit) && (mod->support->enabled)) || (startMode == START_MODE_AUTO && !mod->support->enabled)) { mod->support->itemInit(); moduleUpdateMenu(mode, 0, 0); From aec42f8bc0696c80f62c1eb2af0c48974cea395b Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:31:38 -0500 Subject: [PATCH 09/22] lwnbdsvr/nbd_protocol: check size is matching --- modules/network/lwnbdsvr/nbd_protocol.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/network/lwnbdsvr/nbd_protocol.c b/modules/network/lwnbdsvr/nbd_protocol.c index d4cd6833e..4d2b46e30 100644 --- a/modules/network/lwnbdsvr/nbd_protocol.c +++ b/modules/network/lwnbdsvr/nbd_protocol.c @@ -133,6 +133,8 @@ err_t negotiation_phase(const int client_socket, nbd_context **ctxs, nbd_context memset(handshake_finish.zeroes, 0, sizeof(handshake_finish.zeroes)); size = send(client_socket, &handshake_finish, (cflags & NBD_FLAG_NO_ZEROES) ? offsetof(struct nbd_export_name_option_reply, zeroes) : sizeof handshake_finish, 0); + if (size < ((cflags & NBD_FLAG_NO_ZEROES) ? offsetof(struct nbd_export_name_option_reply, zeroes) : sizeof handshake_finish)) + return -1; return NBD_OPT_EXPORT_NAME; } @@ -143,6 +145,8 @@ err_t negotiation_phase(const int client_socket, nbd_context **ctxs, nbd_context fixed_new_option_reply.replylen = 0; size = send(client_socket, &fixed_new_option_reply, sizeof(struct nbd_fixed_new_option_reply), 0); + if (size < (sizeof(struct nbd_fixed_new_option_reply))) + return -1; return NBD_OPT_ABORT; case NBD_OPT_LIST: { @@ -161,15 +165,25 @@ err_t negotiation_phase(const int client_socket, nbd_context **ctxs, nbd_context size = send(client_socket, &fixed_new_option_reply, sizeof(struct nbd_fixed_new_option_reply), MSG_MORE); + if (size < (sizeof(struct nbd_fixed_new_option_reply))) + return -1; size = send(client_socket, &len, sizeof len, MSG_MORE); + if (size < (sizeof len)) + return -1; size = send(client_socket, (*ptr_ctx)->export_name, name_len, MSG_MORE); + if (size < name_len) + return -1; size = send(client_socket, (*ptr_ctx)->export_desc, desc_len, MSG_MORE); + if (size < desc_len) + return -1; ptr_ctx++; } fixed_new_option_reply.reply = htonl(NBD_REP_ACK); fixed_new_option_reply.replylen = 0; size = send(client_socket, &fixed_new_option_reply, sizeof(struct nbd_fixed_new_option_reply), 0); + if (size < sizeof(struct nbd_fixed_new_option_reply)) + return -1; break; } @@ -186,6 +200,8 @@ err_t negotiation_phase(const int client_socket, nbd_context **ctxs, nbd_context fixed_new_option_reply.replylen = 0; size = send(client_socket, &fixed_new_option_reply, sizeof(struct nbd_fixed_new_option_reply), 0); + if (size < sizeof(struct nbd_fixed_new_option_reply)) + return -1; break; } } From 82d10f91f0ba17ccaf8478ef883d049c1c6a3e7a Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:32:08 -0500 Subject: [PATCH 10/22] themes: ensure SIZING_WRAP will be set on sizingMode --- src/themes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/themes.c b/src/themes.c index 78228987c..be8a51c28 100644 --- a/src/themes.c +++ b/src/themes.c @@ -114,7 +114,7 @@ static mutable_text_t *initMutableText(const char *themePath, config_set_t *them snprintf(elemProp, sizeof(elemProp), "%s_wrap", name); if (configGetInt(themeConfig, elemProp, &sizingMode)) { if (sizingMode > 0) - mutableText->sizingMode = SIZING_WRAP; + sizingMode = SIZING_WRAP; } if ((elem->width != DIM_UNDEF) || (elem->height != DIM_UNDEF)) { From 56f02b82137f1cdaddaac2f3d14471e0d2bbd554 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:32:35 -0500 Subject: [PATCH 11/22] cdvdman/atad: use void instead of assigning to dummy variable --- modules/iopcore/cdvdman/atad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/iopcore/cdvdman/atad.c b/modules/iopcore/cdvdman/atad.c index cace7d02f..2bff60d60 100644 --- a/modules/iopcore/cdvdman/atad.c +++ b/modules/iopcore/cdvdman/atad.c @@ -260,8 +260,8 @@ static int ata_device_select(int device) /* Select the device. */ ata_hwport->r_select = (device & 1) << 4; - res = ata_hwport->r_control; - res = ata_hwport->r_control; //Only done once in v1.04. + (void)(ata_hwport->r_control); + (void)(ata_hwport->r_control); //Only done once in v1.04. return ata_wait_bus_busy(); } From 953cf4f653af26f354109220f560ef0eafc6f0a1 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:36:48 -0500 Subject: [PATCH 12/22] Remove unused assignments --- modules/mcemu/device-hdd.c | 1 - modules/network/httpclient/httpclient.c | 1 - src/cheatman.c | 1 - src/ethsupport.c | 4 +--- src/gui.c | 2 +- 5 files changed, 2 insertions(+), 7 deletions(-) diff --git a/modules/mcemu/device-hdd.c b/modules/mcemu/device-hdd.c index 7c5be0f4b..848eea46f 100644 --- a/modules/mcemu/device-hdd.c +++ b/modules/mcemu/device-hdd.c @@ -13,7 +13,6 @@ static u32 Mcpage_to_Apasector(int mc_num, u32 mc_page) register int i; register u32 sector_to_read, lbound, ubound; - lbound = 0; ubound = 0; sector_to_read = 0; diff --git a/modules/network/httpclient/httpclient.c b/modules/network/httpclient/httpclient.c index 0b32bb051..0157faaa9 100644 --- a/modules/network/httpclient/httpclient.c +++ b/modules/network/httpclient/httpclient.c @@ -61,7 +61,6 @@ static int GetData(int socket, char *buffer, int length) FD_ZERO(&readfds); FD_SET(socket, &readfds); if (select(socket + 1, &readfds, NULL, NULL, &timeout) <= 0) { - result = -EPIPE; break; } diff --git a/src/cheatman.c b/src/cheatman.c index 3239a62b2..b37186eb4 100644 --- a/src/cheatman.c +++ b/src/cheatman.c @@ -282,7 +282,6 @@ static int parse_buf(const char *buf) gCheatList[i] = 0; i++; gCheatList[i] = 0; - i++; return 0; } diff --git a/src/ethsupport.c b/src/ethsupport.c index 4fa728162..1aded0a7a 100644 --- a/src/ethsupport.c +++ b/src/ethsupport.c @@ -480,13 +480,11 @@ static int ethNeedsUpdate(void) static int ethUpdateGameList(void) { - int result; - if (gPCShareName[0]) { if (gNetworkStartup != 0) return 0; - if ((result = sbReadList(ðGames, ethPrefix, ðULSizePrev, ðGameCount)) < 0) { + if ((sbReadList(ðGames, ethPrefix, ðULSizePrev, ðGameCount)) < 0) { gNetworkStartup = ERROR_ETH_SMB_LISTGAMES; ethDisplayErrorStatus(); } diff --git a/src/gui.c b/src/gui.c index 0a46579a6..c8e953686 100644 --- a/src/gui.c +++ b/src/gui.c @@ -424,7 +424,7 @@ void guiShowNetCompatUpdateSingle(int id, item_list_t *support, config_set_t *co if (guiMsgBox(_l(_STR_CONFIRMATION_SETTINGS_UPDATE), 1, NULL)) { guiRenderTextScreen(_l(_STR_PLEASE_WAIT)); - if ((result = ethLoadInitModules()) == 0) { + if ((ethLoadInitModules()) == 0) { if ((result = oplUpdateGameCompatSingle(id, support, configSet)) == OPL_COMPAT_UPDATE_STAT_DONE) { configSetInt(configSet, CONFIG_ITEM_CONFIGSOURCE, CONFIG_SOURCE_DLOAD); } From 871b111edda43cedb05419099304d30064db72c5 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:37:18 -0500 Subject: [PATCH 13/22] mcemu/mcemu: mark r as used --- modules/mcemu/mcemu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/mcemu/mcemu.c b/modules/mcemu/mcemu.c index fc0596192..371c01c2f 100644 --- a/modules/mcemu/mcemu.c +++ b/modules/mcemu/mcemu.c @@ -68,6 +68,7 @@ void StartNow(void *param) /* configuring the virtual memory cards */ if (!(r = mc_configure(memcards))) { + (void)r; DPRINTF("mc_configure return %d.\n", r); readyToGo = MODULE_NO_RESIDENT_END; return; From 112a0d21e193353cc98d53d3842ea6860d826e13 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:47:27 -0500 Subject: [PATCH 14/22] Fix printf format specifier --- modules/network/smap-ingame/smap.c | 2 +- pc/iso2opl/src/iso2opl.c | 2 +- pc/iso2opl/src/isofs.c | 18 +++++++++--------- src/gsm.c | 2 +- src/system.c | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/network/smap-ingame/smap.c b/modules/network/smap-ingame/smap.c index 83d16f3ca..c9a0388a9 100644 --- a/modules/network/smap-ingame/smap.c +++ b/modules/network/smap-ingame/smap.c @@ -104,7 +104,7 @@ static u16 _smap_read_phy(volatile u8 *emac3_regbase, unsigned int address) } while (i < 100); if (i >= 100) - printf("smap: %s: > %d ms\n", "_smap_read_phy", i); + printf("smap: %s: > %u ms\n", "_smap_read_phy", i); return result; } diff --git a/pc/iso2opl/src/iso2opl.c b/pc/iso2opl/src/iso2opl.c index 3ad3e1d56..cf07d316d 100644 --- a/pc/iso2opl/src/iso2opl.c +++ b/pc/iso2opl/src/iso2opl.c @@ -557,7 +557,7 @@ int main(int argc, char **argv, char **env) #ifdef DEBUG printf("ISO filesize: 0x%llx\n", filesize); - printf("Number of parts: %d\n", num_parts); + printf("Number of parts: %lld\n", num_parts); // return 0; #endif diff --git a/pc/iso2opl/src/isofs.c b/pc/iso2opl/src/isofs.c index daacce8df..6774e550f 100644 --- a/pc/iso2opl/src/isofs.c +++ b/pc/iso2opl/src/isofs.c @@ -160,7 +160,7 @@ int isofs_ReadISO(s64 offset, u32 nbytes, void *buf) int r; #ifdef DEBUG - printf("isofs_ReadISO: offset = %lld nbytes = %d\n", offset, nbytes); + printf("isofs_ReadISO: offset = %lld nbytes = %u\n", offset, nbytes); #endif // lseek64(g_fh_iso, offset, SEEK_SET); @@ -189,7 +189,7 @@ int isofs_ReadSect(u32 lsn, u32 nsectors, void *buf) s64 offset; #ifdef DEBUG - printf("isofs_ReadSect: LBA = %d nsectors = %d\n", lsn, nsectors); + printf("isofs_ReadSect: LBA = %u nsectors = %u\n", lsn, nsectors); #endif offset = lsn * 2048; @@ -410,7 +410,7 @@ int FindPath(char *pathname) strcat(CachedDirInfo.pathname, "/"); #ifdef DEBUG - printf("Adding '%s' to cached pathname - path depth = %d\n", dirname, CachedDirInfo.path_depth); + printf("Adding '%s' to cached pathname - path depth = %u\n", dirname, CachedDirInfo.path_depth); #endif strcat(CachedDirInfo.pathname, dirname); @@ -456,7 +456,7 @@ int FindPath(char *pathname) if (isofs_ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache) != 1) { #ifdef DEBUG - printf("Couldn't Read from CD, trying to read %d sectors, starting at sector %d !\n", + printf("Couldn't Read from CD, trying to read %u sectors, starting at sector %u !\n", CachedDirInfo.cache_size, CachedDirInfo.sector_start + CachedDirInfo.cache_offset); #endif @@ -669,7 +669,7 @@ int isofs_Cache_Dir(const char *pathname, enum Cache_getMode getMode) } #ifdef DEBUG - printf("Read the CD root TOC - LBA = %d size = %d\n", + printf("Read the CD root TOC - LBA = %u size = %u\n", (gIsBigEnd ? CDVolDesc.rootToc.tocLBA_bigend : CDVolDesc.rootToc.tocLBA), (gIsBigEnd ? CDVolDesc.rootToc.tocSize_bigend : CDVolDesc.rootToc.tocSize)); #endif @@ -833,7 +833,7 @@ int isofs_FindFile(const char *fname, struct TocEntry *tocEntry) // Export #6 // If we've got here, then we have a block of the directory cached, and want to check // from this point, to the end of the dir #ifdef DEBUG - printf("cache_size = %d\n", CachedDirInfo.cache_size); + printf("cache_size = %u\n", CachedDirInfo.cache_size); #endif while (CachedDirInfo.cache_size > 0) { @@ -959,7 +959,7 @@ int isofs_Read(int fd, void *buf, u32 nbytes) s64 offset; #ifdef DEBUG - printf("isofs_Read: fd = %d nbytes = %d\n", fd, nbytes); + printf("isofs_Read: fd = %d nbytes = %u\n", fd, nbytes); #endif if (!isofs_inited) @@ -981,7 +981,7 @@ int isofs_Read(int fd, void *buf, u32 nbytes) offset = (((s64)fh->lsn) * 2048) + fh->position; #ifdef DEBUG - printf("isofs_Read: offset =%lld nbytes = %d\n", offset, nbytes); + printf("isofs_Read: offset =%lld nbytes = %u\n", offset, nbytes); #endif r = isofs_ReadISO(offset, nbytes, buf); @@ -1001,7 +1001,7 @@ int isofs_Seek(int fd, u32 offset, int origin) FHANDLE *fh; #ifdef DEBUG - printf("isofs_Seek: fd = %d offset = %d origin = %d\n", fd, offset, origin); + printf("isofs_Seek: fd = %d offset = %u origin = %d\n", fd, offset, origin); #endif if (!isofs_inited) diff --git a/src/gsm.c b/src/gsm.c index 464482adc..19910f4dc 100644 --- a/src/gsm.c +++ b/src/gsm.c @@ -138,7 +138,7 @@ void PrepareGSM(char *cmdline) FIELD_fix = gGSMFIELDFix != 0 ? 1 : 0; - sprintf(cmdline, "%d %d %d %llu %llu %u %u %u %d %d %d", predef_vmode[gGSMVMode].interlace, + sprintf(cmdline, "%hhu %hhu %hhu %llu %llu %hu %d %d %d %d %d", predef_vmode[gGSMVMode].interlace, predef_vmode[gGSMVMode].mode, predef_vmode[gGSMVMode].ffmd, predef_vmode[gGSMVMode].display, diff --git a/src/system.c b/src/system.c index 9eafdaa26..617eb0b53 100644 --- a/src/system.c +++ b/src/system.c @@ -824,7 +824,7 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv argc++; char cmask[10]; - snprintf(cmask, 10, "%d", compatflags); + snprintf(cmask, 10, "%u", compatflags); argv[argc] = cmask; argc++; From 5c1d3791f7103c10036dce1f1dfd35ae7d63f2ae Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:48:00 -0500 Subject: [PATCH 15/22] Normalize cheat manager address/value type --- include/cheatman.h | 6 +++--- src/cheatman.c | 8 ++++---- src/supportbase.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/cheatman.h b/include/cheatman.h index 5a3b99ec5..2068a1736 100644 --- a/include/cheatman.h +++ b/include/cheatman.h @@ -55,13 +55,13 @@ */ typedef struct { - int addr; - int val; + u32 addr; + u32 val; } code_t; void InitCheatsConfig(config_set_t *configSet); int GetCheatsEnabled(void); -const int *GetCheatsList(void); +const u32 *GetCheatsList(void); int load_cheats(const char *cheatfile); #endif /* _CHEATMAN_H_ */ diff --git a/src/cheatman.c b/src/cheatman.c index b37186eb4..22cea59f5 100644 --- a/src/cheatman.c +++ b/src/cheatman.c @@ -29,7 +29,7 @@ static int gEnableCheat; // Enables PS2RD Cheat Engine - 0 for Off, 1 for On static int gCheatMode; // Cheat Mode - 0 Enable all cheats, 1 Cheats selected by user -static int gCheatList[MAX_CHEATLIST]; // Store hooks/codes addr+val pairs +static u32 gCheatList[MAX_CHEATLIST]; // Store hooks/codes addr+val pairs void InitCheatsConfig(config_set_t *configSet) { @@ -58,7 +58,7 @@ int GetCheatsEnabled(void) return gEnableCheat; } -const int *GetCheatsList(void) +const u32 *GetCheatsList(void) { return gCheatList; } @@ -69,8 +69,8 @@ const int *GetCheatsList(void) static code_t make_code(const char *s) { code_t code; - int address; - int value; + u32 address; + u32 value; char digits[CODE_DIGITS]; int i = 0; diff --git a/src/supportbase.c b/src/supportbase.c index ea0a6d8f9..97c30c805 100644 --- a/src/supportbase.c +++ b/src/supportbase.c @@ -763,7 +763,7 @@ void sbCreateFolders(const char *path, int createDiscImgFolders) int sbLoadCheats(const char *path, const char *file) { char cheatfile[64]; - const int *cheatList; + const u32 *cheatList; int result; if (GetCheatsEnabled()) { From 208cb57b7399c1af457a9b1f1ee616acecc61dea Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:49:17 -0500 Subject: [PATCH 16/22] Remove extra unneeded null assignments --- src/lang.c | 1 - src/themes.c | 1 - src/util.c | 1 - 3 files changed, 3 deletions(-) diff --git a/src/lang.c b/src/lang.c index 6151c2f8e..812348d20 100644 --- a/src/lang.c +++ b/src/lang.c @@ -30,7 +30,6 @@ static void lngFreeFromFile(char **lang_strs) lang_strs[strId] = NULL; } free(lang_strs); - lang_strs = NULL; } static int lngLoadFont(const char *dir, const char *name) diff --git a/src/themes.c b/src/themes.c index be8a51c28..3076cda17 100644 --- a/src/themes.c +++ b/src/themes.c @@ -1052,7 +1052,6 @@ static void thmFree(theme_t *theme) fntRelease(theme->fonts[id]); free(theme); - theme = NULL; } } diff --git a/src/util.c b/src/util.c index e6b1d3057..946062462 100644 --- a/src/util.c +++ b/src/util.c @@ -402,7 +402,6 @@ void closeFileBuffer(file_buffer_t *fileBuffer) } free(fileBuffer->buffer); free(fileBuffer); - fileBuffer = NULL; } // a simple maximum of two From ce329328b7c00bed671fa8900aaff705db1a00e6 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 00:52:56 -0500 Subject: [PATCH 17/22] Fix instances of redundent / possible null conditions --- src/bdmsupport.c | 4 +++- src/gui.c | 6 +++++- src/menusys.c | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bdmsupport.c b/src/bdmsupport.c index 1555d8eac..64e07b51e 100644 --- a/src/bdmsupport.c +++ b/src/bdmsupport.c @@ -322,7 +322,9 @@ static void bdmLaunchGame(int id, config_set_t *configSet) *pBDMDriver = fileXioIoctl(fd, USBMASS_IOCTL_GET_DRIVERNAME, ""); LOG("bdmDriver=%s\n", bdmDriver); - settings->LBAs[i] = fileXioIoctl(fd, USBMASS_IOCTL_GET_LBA, ""); + if (settings != NULL) + settings->LBAs[i] = fileXioIoctl(fd, USBMASS_IOCTL_GET_LBA, ""); + if (fileXioIoctl(fd, USBMASS_IOCTL_CHECK_CHAIN, "") != 1) { close(fd); // Game is fragmented. Do not continue. diff --git a/src/gui.c b/src/gui.c index c8e953686..2bfaf11c4 100644 --- a/src/gui.c +++ b/src/gui.c @@ -1237,9 +1237,13 @@ void guiDrawBGPlasma() int guiDrawIconAndText(int iconId, int textId, int font, int x, int y, u64 color) { GSTEXTURE *iconTex = thmGetTexture(iconId); - int w = (iconTex->Width * 20) / iconTex->Height; + int w = 0; int h = 20; + if (iconTex) { + w = (iconTex->Width * 20) / iconTex->Height; + } + if (iconTex && iconTex->Mem) { y += h >> 1; rmDrawPixmap(iconTex, x, y, ALIGN_VCENTER, w, h, SCALING_RATIO, gDefaultCol); diff --git a/src/menusys.c b/src/menusys.c index 62ed170fd..871c551d7 100644 --- a/src/menusys.c +++ b/src/menusys.c @@ -528,12 +528,14 @@ void submenuSort(submenu_list_t **submenu) { // a simple bubblesort // *submenu = mergeSort(*submenu); - submenu_list_t *head = *submenu; + submenu_list_t *head; int sorted = 0; if ((submenu == NULL) || (*submenu == NULL) || ((*submenu)->next == NULL)) return; + head = *submenu; + while (!sorted) { sorted = 1; From d7cc36ec847decabc5eaf01e7c4601e4c6f47cbf Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 01:13:40 -0500 Subject: [PATCH 18/22] Avoid using void pointers in calculations --- ee_core/src/igs_api.c | 4 ++-- modules/ds34bt/iop/ds34bt.c | 10 ++++----- modules/ds34usb/iop/ds34usb.c | 8 +++---- modules/iopcore/cdvdman/cdvdman.c | 8 +++---- modules/iopcore/cdvdman/device-hdd.c | 2 +- modules/iopcore/cdvdman/ioops.c | 2 +- modules/iopcore/cdvdman/ioplib_util.c | 4 ++-- modules/iopcore/udnl-t300/udnl.c | 32 +++++++++++++-------------- modules/iopcore/udnl/udnl.c | 30 ++++++++++++------------- modules/isofs/isofs.c | 2 +- modules/mcemu/mcemu.c | 4 ++-- modules/network/lwnbdsvr/lwnbd.c | 2 +- modules/network/smap-ingame/xfer.c | 2 +- src/ioprp.c | 12 +++++----- src/system.c | 8 +++---- src/util.c | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ee_core/src/igs_api.c b/ee_core/src/igs_api.c index dff5bc0ac..688d72dd9 100644 --- a/ee_core/src/igs_api.c +++ b/ee_core/src/igs_api.c @@ -637,7 +637,7 @@ static u8 SaveBitmapFile(u16 width, u16 height, u8 pixel_size, void *buffer, u8 if (ret != 2) BlinkColour(5, 0x0000FF, 1); // Red //(...then, write the remaining info!) - bh = buffer + image_size; + bh = (void *)((u8 *)buffer + image_size); bh->filesize = (u32)file_size; bh->reserved = (u32)0; bh->headersize = (u32)54; @@ -663,7 +663,7 @@ static u8 SaveBitmapFile(u16 width, u16 height, u8 pixel_size, void *buffer, u8 if (intffmd == 3) // Interlace Mode, FRAME Mode (Read every line) height >>= 1; for (i = 1; i <= height; i++) { - addr = buffer + ((height - i) * lenght); + addr = (void *)((u8 *)buffer + ((height - i) * lenght)); // Ensure that all the data has indeed been written back to main memory FlushCache(GS_WRITEBACK_DCACHE); diff --git a/modules/ds34bt/iop/ds34bt.c b/modules/ds34bt/iop/ds34bt.c index 29bed079e..56559866b 100644 --- a/modules/ds34bt/iop/ds34bt.c +++ b/modules/ds34bt/iop/ds34bt.c @@ -1645,13 +1645,13 @@ void *rpc_sf(int cmd, void *data, int size) *(u8 *)data = ds34bt_get_status(*(u8 *)data); break; case DS34BT_GET_BDADDR: - *(u8 *)(data + 6) = ds34bt_get_bdaddr((u8 *)data); + *((u8 *)data + 6) = ds34bt_get_bdaddr((u8 *)data); break; case DS34BT_SET_RUMBLE: - ds34bt_set_rumble(*(u8 *)(data + 1), *(u8 *)(data + 2), *(u8 *)data); + ds34bt_set_rumble(*((u8 *)data + 1), *((u8 *)data + 2), *(u8 *)data); break; case DS34BT_SET_LED: - ds34bt_set_led((u8 *)(data + 1), *(u8 *)data); + ds34bt_set_led(((u8 *)data + 1), *(u8 *)data); break; case DS34BT_GET_DATA: ds34bt_get_data((char *)data, 18, *(u8 *)data); @@ -1660,10 +1660,10 @@ void *rpc_sf(int cmd, void *data, int size) ds34bt_reset(); break; case DS34BT_GET_VERSION: - *(u8 *)(data + sizeof(hci_information_t)) = ds34bt_get_ver((u8 *)data); + *((u8 *)data + sizeof(hci_information_t)) = ds34bt_get_ver((u8 *)data); break; case DS34BT_GET_FEATURES: - *(u8 *)(data + 8) = ds34bt_get_feat((u8 *)data); + *((u8 *)data + 8) = ds34bt_get_feat((u8 *)data); break; default: break; diff --git a/modules/ds34usb/iop/ds34usb.c b/modules/ds34usb/iop/ds34usb.c index a3b6cfcc1..7c0fbbc9c 100644 --- a/modules/ds34usb/iop/ds34usb.c +++ b/modules/ds34usb/iop/ds34usb.c @@ -716,16 +716,16 @@ void *rpc_sf(int cmd, void *data, int size) *(u8 *)data = ds34usb_get_status(*(u8 *)data); break; case DS34USB_GET_BDADDR: - *(u8 *)data = ds34usb_get_bdaddr((u8 *)(data + 1), *(u8 *)data); + *(u8 *)data = ds34usb_get_bdaddr(((u8 *)data + 1), *(u8 *)data); break; case DS34USB_SET_BDADDR: - ds34usb_set_bdaddr((u8 *)(data + 1), *(u8 *)data); + ds34usb_set_bdaddr(((u8 *)data + 1), *(u8 *)data); break; case DS34USB_SET_RUMBLE: - ds34usb_set_rumble(*(u8 *)(data + 1), *(u8 *)(data + 2), *(u8 *)data); + ds34usb_set_rumble(*((u8 *)data + 1), *((u8 *)data + 2), *(u8 *)data); break; case DS34USB_SET_LED: - ds34usb_set_led((u8 *)(data + 1), *(u8 *)data); + ds34usb_set_led(((u8 *)data + 1), *(u8 *)data); break; case DS34USB_GET_DATA: ds34usb_get_data((char *)data, 18, *(u8 *)data); diff --git a/modules/iopcore/cdvdman/cdvdman.c b/modules/iopcore/cdvdman/cdvdman.c index c9f4a2c36..94ca637a8 100644 --- a/modules/iopcore/cdvdman/cdvdman.c +++ b/modules/iopcore/cdvdman/cdvdman.c @@ -189,7 +189,7 @@ static int cdvdman_read_sectors(u32 lsn, unsigned int sectors, void *buf) } } - ptr += SectorsToRead * 2048; + ptr = (void *)((u8 *)ptr + (SectorsToRead * 2048)); remaining -= SectorsToRead; lsn += SectorsToRead; ReadPos += SectorsToRead * 2048; @@ -229,7 +229,7 @@ static int cdvdman_read(u32 lsn, u32 sectors, void *buf) memcpy(buf, cdvdman_buf, nbytes); - buf = (void *)(buf + nbytes); + buf = (void *)((u8 *)buf + nbytes); } SignalSema(cdvdman_searchfilesema); @@ -447,7 +447,7 @@ static int cdvdman_writeSCmd(u8 cmd, const void *in, u16 in_size, void *out, u16 if (in_size > 0) { for (i = 0; i < in_size; i++) { - p = (void *)(in + i); + p = (void *)((const u8 *)in + i); CDVDreg_SDATAIN = *p; } } @@ -465,7 +465,7 @@ static int cdvdman_writeSCmd(u8 cmd, const void *in, u16 in_size, void *out, u16 if (i >= out_size) { break; } - p = (void *)(out + i); + p = (void *)((u8 *)out + i); *p = CDVDreg_SDATAOUT; i++; } while (!(CDVDreg_SDATAIN & 0x40)); diff --git a/modules/iopcore/cdvdman/device-hdd.c b/modules/iopcore/cdvdman/device-hdd.c index 9cfb15181..79e8d634d 100644 --- a/modules/iopcore/cdvdman/device-hdd.c +++ b/modules/iopcore/cdvdman/device-hdd.c @@ -118,7 +118,7 @@ int DeviceReadSectors(u32 lsn, void *buffer, unsigned int sectors) nsectors = sectors; u32 lba = cdvdman_partspecs[CurrentPart].data_start + ((lsn - cdvdman_partspecs[CurrentPart].part_offset) << 2); - if (ata_device_sector_io(0, (void *)(buffer + offset), lba, nsectors << 2, ATA_DIR_READ) != 0) { + if (ata_device_sector_io(0, (void *)((u8 *)buffer + offset), lba, nsectors << 2, ATA_DIR_READ) != 0) { return SCECdErREAD; } offset += nsectors * 2048; diff --git a/modules/iopcore/cdvdman/ioops.c b/modules/iopcore/cdvdman/ioops.c index 059431612..5d0b87b7b 100644 --- a/modules/iopcore/cdvdman/ioops.c +++ b/modules/iopcore/cdvdman/ioops.c @@ -273,7 +273,7 @@ static int cdrom_read(iop_file_t *f, void *buf, int size) sceCdSync(0); memcpy(buf, &cdvdman_fs_buf[offset], nbytes); - buf += nbytes; + buf = (void *)((u8 *)buf + nbytes); } //Phase 2: read the data to the middle of the buffer, in units of 2048. diff --git a/modules/iopcore/cdvdman/ioplib_util.c b/modules/iopcore/cdvdman/ioplib_util.c index 80675dba3..a805071c4 100644 --- a/modules/iopcore/cdvdman/ioplib_util.c +++ b/modules/iopcore/cdvdman/ioplib_util.c @@ -185,9 +185,9 @@ static int Hook_LoadModuleBuffer(void *ptr) { const struct FakeModule *mod; - DPRINTF("Hook_LoadModuleBuffer() modname = %s\n", (char *)(ptr + 0x8e)); + DPRINTF("Hook_LoadModuleBuffer() modname = %s\n", ((char *)ptr + 0x8e)); - mod = checkFakemodByName((char *)(ptr + 0x8e), modulefake_list); + mod = checkFakemodByName(((char *)ptr + 0x8e), modulefake_list); if (mod != NULL) return mod->id; diff --git a/modules/iopcore/udnl-t300/udnl.c b/modules/iopcore/udnl-t300/udnl.c index 18d297a36..7f9ebab11 100644 --- a/modules/iopcore/udnl-t300/udnl.c +++ b/modules/iopcore/udnl-t300/udnl.c @@ -166,7 +166,7 @@ static struct RomdirFileStat *GetFileStatFromImage(const struct RomImgData *Imag if (((unsigned int *)filename_temp)[0] == ((unsigned int *)RomdirEntry->name)[0] && ((unsigned int *)filename_temp)[1] == ((unsigned int *)RomdirEntry->name)[1] && (*(unsigned short int *)&((unsigned int *)filename_temp)[2] == *(unsigned short int *)&((unsigned int *)RomdirEntry->name)[2])) { stat->romdirent = RomdirEntry; - stat->data = ImageStat->ImageStart + offset; + stat->data = (void *)((u8 *)(ImageStat->ImageStart) + offset); stat->extinfo = NULL; if (RomdirEntry->ExtInfoEntrySize > 0) { @@ -502,7 +502,7 @@ static void LoadIRXModule(const void *module, struct ModuleInfo *ModuleInfo) /* 0x00000fec */ if (ELF_phdr[1].filesz < ELF_phdr[1].memsz) { - ZeroSection((unsigned int *)(ModuleInfo->text_start + ELF_phdr[1].filesz), (ELF_phdr[1].memsz - ELF_phdr[1].filesz) >> 2); + ZeroSection((unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_phdr[1].filesz), (ELF_phdr[1].memsz - ELF_phdr[1].filesz) >> 2); } /* 0x00001048 */ @@ -512,31 +512,31 @@ static void LoadIRXModule(const void *module, struct ModuleInfo *ModuleInfo) /* 0x0000107c - Warning: beware of sign extension! The code here depends on sign extension. */ for (i = 0, ELF_relocation = (elf_rel *)((unsigned int)module + CurrentELF_shdr->offset); i < NumRelocs; i++, ELF_relocation++) { - // DEBUG_PRINTF("Reloc %d: %p\n", (unsigned char)ELF_relocation->info&0xFF, ModuleInfo->text_start+ELF_relocation->offset); //Code for debugging only: Not originally present. + // DEBUG_PRINTF("Reloc %d: %p\n", (unsigned char)ELF_relocation->info&0xFF, (u8 *)(ModuleInfo->text_start)+ELF_relocation->offset); //Code for debugging only: Not originally present. switch (ELF_relocation->info & 0xFF) { case R_MIPS_NONE: break; case R_MIPS_16: - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation->offset); - *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (((unsigned int)ModuleInfo->text_start + *(short int *)(ModuleInfo->text_start + ELF_relocation->offset)) & 0xFFFF); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset); + *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (((unsigned int)ModuleInfo->text_start + *(short int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset)) & 0xFFFF); break; case R_MIPS_32: - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation->offset); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset); *WordPatchLocation += (unsigned int)ModuleInfo->text_start; break; case R_MIPS_REL32: break; case R_MIPS_26: - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation->offset); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset); *WordPatchLocation = (((unsigned int)ModuleInfo->text_start + ((*WordPatchLocation & 0x03FFFFFF) << 2 | ((unsigned int)WordPatchLocation & 0xF0000000))) << 4 >> 6) | (*WordPatchLocation & 0xFC000000); break; case R_MIPS_HI16: // 0x00001120 - Ouch. D: - temp = (((unsigned int)*(unsigned short int *)(ModuleInfo->text_start + ELF_relocation->offset)) << 16) + *(short int *)(ModuleInfo->text_start + ELF_relocation[1].offset); + temp = (((unsigned int)*(unsigned short int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset)) << 16) + *(short int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation[1].offset); temp += (unsigned int)ModuleInfo->text_start; - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation->offset); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset); *WordPatchLocation = (((temp >> 15) + 1) >> 1 & 0xFFFF) | (*WordPatchLocation & 0xFFFF0000); - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation[1].offset); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation[1].offset); *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (temp & 0xFFFF); ELF_relocation++; i++; @@ -607,7 +607,7 @@ static int LoadModule(const void *module, struct ModuleInfo *ModuleInfo) } /* 0x00000dd4 */ - InitLoadedModInfo(ModuleInfo, ModuleInfo->text_start - 0x30); + InitLoadedModInfo(ModuleInfo, (void *)((u8 *)(ModuleInfo->text_start) - 0x30)); return 0; } @@ -1035,7 +1035,7 @@ int _start(int argc, char *argv[]) ResetData = buffer; memset(ResetData, 0, sizeof(struct ResetData)); - ResetData->ModData = (void *)buffer + sizeof(struct ResetData); + ResetData->ModData = (void *)((u8 *)buffer + sizeof(struct ResetData)); IoprpBuffer = (void *)((unsigned int)buffer + MAX_MODULES * sizeof(void *) + sizeof(struct ResetData)); ResetData->IOPRPBuffer = (void *)((unsigned int)IoprpBuffer & 0x1FFFFF00); ResetData->MemSize = QueryMemSize() >> 20; @@ -1051,7 +1051,7 @@ int _start(int argc, char *argv[]) ImageDataBuffer[0].filename = "ROM"; } if (BootMode3 & 0x00000100) { - if (GetFileStatFromImage(&ImageDataBuffer[0].stat, "OLDROM", &ROMStat) != 0 && GetIOPRPStat(ROMStat.data, ROMStat.data + 0x40000, &ImageDataBuffer[1].stat)) { + if (GetFileStatFromImage(&ImageDataBuffer[0].stat, "OLDROM", &ROMStat) != 0 && GetIOPRPStat(ROMStat.data, (const void *)((const u8 *)(ROMStat.data) + 0x40000), &ImageDataBuffer[1].stat)) { memcpy(&ImageDataBuffer[0].stat, &ImageDataBuffer[1].stat, sizeof(ImageDataBuffer[0].stat)); printf(" use alternate ROM image\n"); } @@ -1067,7 +1067,7 @@ int _start(int argc, char *argv[]) memcpy(IoprpBuffer, IOPRP_img, size_IOPRP_img); if (GetIOPRPStat(IoprpBuffer, (void *)((unsigned int)IoprpBuffer + size_IOPRP_img), &ImageDataBuffer[1].stat) != NULL) { ImageDataBuffer[1].filename = "DATA"; - IoprpBuffer += (size_IOPRP_img + 0xF) & ~0xF; + IoprpBuffer = (void *)((u8 *)IoprpBuffer + ((size_IOPRP_img + 0xF) & ~0xF)); } } @@ -1079,9 +1079,9 @@ int _start(int argc, char *argv[]) do { if (read(ImageData->fd, IoprpBuffer, ImageData->size) == ImageData->size) { - if (GetIOPRPStat(IoprpBuffer, IoprpBuffer + 0x4000, &ImageData->stat) != NULL) { + if (GetIOPRPStat(IoprpBuffer, (void *)((u8 *)IoprpBuffer + 0x4000), &ImageData->stat) != NULL) { /* 0x00000420 */ - IoprpBuffer += (ImageData->size + 0xF) & ~0xF; + IoprpBuffer = (void *)((u8 *)IoprpBuffer + ((ImageData->size + 0xF) & ~0xF)); } } diff --git a/modules/iopcore/udnl/udnl.c b/modules/iopcore/udnl/udnl.c index 0dc313991..277df38b4 100644 --- a/modules/iopcore/udnl/udnl.c +++ b/modules/iopcore/udnl/udnl.c @@ -171,7 +171,7 @@ static struct RomdirFileStat *GetFileStatFromImage(const struct RomImgData *Imag if (((unsigned int *)filename_temp)[0] == ((unsigned int *)RomdirEntry->name)[0] && ((unsigned int *)filename_temp)[1] == ((unsigned int *)RomdirEntry->name)[1] && (*(unsigned short int *)&((unsigned int *)filename_temp)[2] == *(unsigned short int *)&((unsigned int *)RomdirEntry->name)[2])) { stat->romdirent = RomdirEntry; - stat->data = ImageStat->ImageStart + offset; + stat->data = (void *)((u8 *)(ImageStat->ImageStart) + offset); stat->extinfo = NULL; if (RomdirEntry->ExtInfoEntrySize > 0) { @@ -403,7 +403,7 @@ static void LoadIRXModule(const void *module, struct ModuleInfo *ModuleInfo) /* 0x00000fec */ if (ELF_phdr[1].filesz < ELF_phdr[1].memsz) { - ZeroSection((unsigned int *)(ModuleInfo->text_start + ELF_phdr[1].filesz), (ELF_phdr[1].memsz - ELF_phdr[1].filesz) >> 2); + ZeroSection((unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_phdr[1].filesz), (ELF_phdr[1].memsz - ELF_phdr[1].filesz) >> 2); } /* 0x00001048 */ @@ -413,31 +413,31 @@ static void LoadIRXModule(const void *module, struct ModuleInfo *ModuleInfo) /* 0x0000107c - Warning: beware of sign extension! The code here depends on sign extension. */ for (i = 0, ELF_relocation = (elf_rel *)((unsigned int)module + CurrentELF_shdr->offset); i < NumRelocs; i++, ELF_relocation++) { - // DEBUG_PRINTF("Reloc %d: %p\n", (unsigned char)ELF_relocation->info&0xFF, ModuleInfo->text_start+ELF_relocation->offset); //Code for debugging only: Not originally present. + // DEBUG_PRINTF("Reloc %d: %p\n", (unsigned char)ELF_relocation->info&0xFF, (u8 *)(ModuleInfo->text_start)+ELF_relocation->offset); //Code for debugging only: Not originally present. switch (ELF_relocation->info & 0xFF) { case R_MIPS_NONE: break; case R_MIPS_16: - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation->offset); - *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (((unsigned int)ModuleInfo->text_start + *(short int *)(ModuleInfo->text_start + ELF_relocation->offset)) & 0xFFFF); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset); + *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (((unsigned int)ModuleInfo->text_start + *(short int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset)) & 0xFFFF); break; case R_MIPS_32: - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation->offset); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset); *WordPatchLocation += (unsigned int)ModuleInfo->text_start; break; case R_MIPS_REL32: break; case R_MIPS_26: - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation->offset); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset); *WordPatchLocation = (((unsigned int)ModuleInfo->text_start + ((*WordPatchLocation & 0x03FFFFFF) << 2 | ((unsigned int)WordPatchLocation & 0xF0000000))) << 4 >> 6) | (*WordPatchLocation & 0xFC000000); break; case R_MIPS_HI16: // 0x00001120 - Ouch. D: - temp = (((unsigned int)*(unsigned short int *)(ModuleInfo->text_start + ELF_relocation->offset)) << 16) + *(short int *)(ModuleInfo->text_start + ELF_relocation[1].offset); + temp = (((unsigned int)*(unsigned short int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset)) << 16) + *(short int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation[1].offset); temp += (unsigned int)ModuleInfo->text_start; - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation->offset); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation->offset); *WordPatchLocation = (((temp >> 15) + 1) >> 1 & 0xFFFF) | (*WordPatchLocation & 0xFFFF0000); - WordPatchLocation = (unsigned int *)(ModuleInfo->text_start + ELF_relocation[1].offset); + WordPatchLocation = (unsigned int *)((u8 *)(ModuleInfo->text_start) + ELF_relocation[1].offset); *WordPatchLocation = (*WordPatchLocation & 0xFFFF0000) | (temp & 0xFFFF); ELF_relocation++; i++; @@ -508,7 +508,7 @@ static int LoadModule(const void *module, struct ModuleInfo *ModuleInfo) } /* 0x00000dd4 */ - InitLoadedModInfo(ModuleInfo, ModuleInfo->text_start - 0x30); + InitLoadedModInfo(ModuleInfo, (void *)((u8 *)(ModuleInfo->text_start) - 0x30)); return 0; } @@ -903,7 +903,7 @@ int _start(int argc, char *argv[]) ResetData = buffer; memset(ResetData, 0, sizeof(struct ResetData)); - ResetData->ModData = (void *)buffer + sizeof(struct ResetData); + ResetData->ModData = (void *)((u8 *)buffer + sizeof(struct ResetData)); IoprpBuffer = (void *)((unsigned int)buffer + MAX_MODULES * sizeof(void *) + sizeof(struct ResetData)); ResetData->IOPRPBuffer = (void *)((unsigned int)IoprpBuffer & 0x1FFFFF00); ResetData->MemSize = QueryMemSize() >> 20; @@ -922,7 +922,7 @@ int _start(int argc, char *argv[]) memcpy(IoprpBuffer, IOPRP_img, size_IOPRP_img); if (GetIOPRPStat(IoprpBuffer, (void *)((unsigned int)IoprpBuffer + size_IOPRP_img), &ImageDataBuffer[1].stat) != NULL) { ImageDataBuffer[1].filename = "DATA"; - IoprpBuffer += (size_IOPRP_img + 0xF) & ~0xF; + IoprpBuffer = (void *)((u8 *)IoprpBuffer + ((size_IOPRP_img + 0xF) & ~0xF)); } } @@ -934,9 +934,9 @@ int _start(int argc, char *argv[]) do { if (read(ImageData->fd, IoprpBuffer, ImageData->size) == ImageData->size) { - if (GetIOPRPStat(IoprpBuffer, IoprpBuffer + 0x4000, &ImageData->stat) != NULL) { + if (GetIOPRPStat(IoprpBuffer, (void *)((u8 *)IoprpBuffer) + 0x4000, &ImageData->stat) != NULL) { /* 0x00000420 */ - IoprpBuffer += (ImageData->size + 0xF) & ~0xF; + IoprpBuffer = (void *)((u8 *)IoprpBuffer + ((ImageData->size + 0xF) & ~0xF)); } } i++; diff --git a/modules/isofs/isofs.c b/modules/isofs/isofs.c index c43567fd7..6bc29c55d 100644 --- a/modules/isofs/isofs.c +++ b/modules/isofs/isofs.c @@ -404,7 +404,7 @@ static int IsofsRead(iop_file_t *f, void *buf, int size) rpos += nbytes; memcpy(buf, &cdvdman_fs_buf[offset], nbytes); - buf += nbytes; + buf = (void *)((u8 *)buf + nbytes); } // Phase 2: read the data to the middle of the buffer, in units of 2048. diff --git a/modules/mcemu/mcemu.c b/modules/mcemu/mcemu.c index 371c01c2f..ef344e57c 100644 --- a/modules/mcemu/mcemu.c +++ b/modules/mcemu/mcemu.c @@ -682,7 +682,7 @@ int MceRead(MemoryCard *mcd, void *buf, u32 size) u32 csize = (size < 16) ? size : 16; mips_memcpy(buf, mcd->cbufp, csize); mcd->rcoff = (csize > 12) ? 0 : (mcd->rcoff - csize); - buf += csize; + buf = (void *)((u8 *)buf + csize); size -= csize; if (size <= 0) return 1; @@ -700,7 +700,7 @@ int MceRead(MemoryCard *mcd, void *buf, u32 size) mcd->rcoff += 3; } if (mcd->rdoff == mcd->cspec.PageSize) { - buf += size; + buf = (void *)((u8 *)buf + size); size = tot_size - size; mcd->rpage++; mcd->rdoff = 0; diff --git a/modules/network/lwnbdsvr/lwnbd.c b/modules/network/lwnbdsvr/lwnbd.c index 08cbcfb97..88e9b8e3a 100644 --- a/modules/network/lwnbdsvr/lwnbd.c +++ b/modules/network/lwnbdsvr/lwnbd.c @@ -112,7 +112,7 @@ uint32_t nbd_recv(int s, void *mem, size_t len, int flags) // LWIP_DEBUGF(NBD_DEBUG | LWIP_DBG_STATE("nbd_recv(-, 0x%X, %d)\n", (int)mem, size); // dbgLOG("left = %u\n", left); do { - bytesRead = recv(s, mem + totalRead, left, flags); + bytesRead = recv(s, (void *)((uint8_t *)mem + totalRead), left, flags); // dbgLOG("bytesRead = %u\n", bytesRead); if (bytesRead <= 0) // if (bytesRead == -1) failed for nbdfuse, seems it not send NBD_CMD_DISC break; diff --git a/modules/network/smap-ingame/xfer.c b/modules/network/smap-ingame/xfer.c index 8b4647de2..cc75904d7 100644 --- a/modules/network/smap-ingame/xfer.c +++ b/modules/network/smap-ingame/xfer.c @@ -86,7 +86,7 @@ static inline void CopyFromFIFO(volatile u8 *smap_regbase, void *buffer, unsigne if ((result = CopyFromFIFOWithDMA(smap_regbase, buffer, length)) > 0) { length -= result; - buffer = buffer + result; + buffer = (void *)((u8 *)buffer + result); } __asm__ __volatile__( diff --git a/src/ioprp.c b/src/ioprp.c index e89f5c6b9..ef4367a35 100644 --- a/src/ioprp.c +++ b/src/ioprp.c @@ -44,14 +44,14 @@ unsigned int patch_IOPRP_image(void *ioprp_image, void *cdvdman_module, unsigned memset(romdir_out, 0, sizeof(struct romdir_entry)); if (!strcmp(romdir_in->fileName, "CDVDMAN")) - patch_CDVDMAN((void *)(ioprp_image + offset_out), romdir_out, cdvdman_module, size_cdvdman); + patch_CDVDMAN((void *)((u8 *)ioprp_image + offset_out), romdir_out, cdvdman_module, size_cdvdman); else if (!strcmp(romdir_in->fileName, "CDVDFSV")) - patch_CDVDFSV((void *)(ioprp_image + offset_out), romdir_out); + patch_CDVDFSV((void *)((u8 *)ioprp_image + offset_out), romdir_out); else if (!strcmp(romdir_in->fileName, "EESYNC")) - patch_EESYNC((void *)(ioprp_image + offset_out), romdir_out); - else { /* Other modules that should not be tampered with */ - memcpy((void *)(ioprp_image + offset_out), (void *)(IOPRP_img + offset_in), romdir_in->fileSize); /* Copy the file/entry's contents. */ - romdir_out->fileSize = romdir_in->fileSize; /* Copy the file size. */ + patch_EESYNC((void *)((u8 *)ioprp_image + offset_out), romdir_out); + else { /* Other modules that should not be tampered with */ + memcpy((void *)((u8 *)ioprp_image + offset_out), (void *)(IOPRP_img + offset_in), romdir_in->fileSize); /* Copy the file/entry's contents. */ + romdir_out->fileSize = romdir_in->fileSize; /* Copy the file size. */ } /* For ALL modules */ diff --git a/src/system.c b/src/system.c index 617eb0b53..d291ad1c7 100644 --- a/src/system.c +++ b/src/system.c @@ -541,7 +541,7 @@ static unsigned int sendIrxKernelRAM(const char *startup, const char *mode_str, // For DECI2 debugging mode, the UDNL module will have to be stored within kernel RAM because there isn't enough space below user RAM. // total_size will hence not include the IOPRP image, but it's okay because the EE core is interested in protecting the module storage within user RAM. irxptr = (void *)0x00033000; - LOG("SYSTEM DECI2 UDNL address start: %p end: %p\n", irxptr, irxptr + GET_OPL_MOD_SIZE(irxptr_tab[0].info)); + LOG("SYSTEM DECI2 UDNL address start: %p end: %p\n", irxptr, (void *)((u8 *)irxptr + GET_OPL_MOD_SIZE(irxptr_tab[0].info))); DI(); ee_kmode_enter(); memcpy((void *)(0x80000000 | (unsigned int)irxptr), irxptr_tab[0].ptr, GET_OPL_MOD_SIZE(irxptr_tab[0].info)); @@ -562,11 +562,11 @@ static unsigned int sendIrxKernelRAM(const char *startup, const char *mode_str, curIrxSize = GET_OPL_MOD_SIZE(irxptr_tab[i].info); if (curIrxSize > 0) { - LOG("SYSTEM IRX %u address start: %p end: %p\n", GET_OPL_MOD_ID(irxptr_tab[i].info), irxptr, irxptr + curIrxSize); + LOG("SYSTEM IRX %u address start: %p end: %p\n", GET_OPL_MOD_ID(irxptr_tab[i].info), irxptr, (void *)((u8 *)irxptr + curIrxSize)); memcpy(irxptr, irxptr_tab[i].ptr, curIrxSize); irxptr_tab[i].ptr = irxptr; - irxptr += ((curIrxSize + 0xF) & ~0xF); + irxptr = (void *)((u8 *)irxptr + ((curIrxSize + 0xF) & ~0xF)); total_size += ((curIrxSize + 0xF) & ~0xF); } else { irxptr_tab[i].ptr = NULL; @@ -780,7 +780,7 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv if (eph[i].type != ELF_PT_LOAD) continue; - pdata = (void *)(boot_elf + eph[i].offset); + pdata = (void *)((u8 *)boot_elf + eph[i].offset); memcpy(eph[i].vaddr, pdata, eph[i].filesz); if (eph[i].memsz > eph[i].filesz) diff --git a/src/util.c b/src/util.c index 946062462..27f5e8c48 100644 --- a/src/util.c +++ b/src/util.c @@ -510,7 +510,7 @@ int CheckPS2Logo(int fd, u32 lba) w = !(hddReadSectors(lba + k, 1, buffer)); if (!w) break; - buffer += 512; + buffer = (void *)((u8 *)buffer + 512); } } From 090258150119c168be91077f1afee17611f6774b Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 01:17:32 -0500 Subject: [PATCH 19/22] lng_pack: quote paths --- lng_pack.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lng_pack.sh b/lng_pack.sh index 347a625c1..d46aae8f0 100755 --- a/lng_pack.sh +++ b/lng_pack.sh @@ -13,28 +13,28 @@ then export OPL_VERSION=$(make oplversion) else echo "Falling back to old OPL Lang Pack" - VERSION=$(cat ${CURRENT_DIR}/Makefile | grep "VERSION =" | head -1 | cut -d " " -f 3) - SUBVERSION=$(cat ${CURRENT_DIR}/Makefile | grep "SUBVERSION =" | head -1 | cut -d " " -f 3) - PATCHLEVEL=$(cat ${CURRENT_DIR}/Makefile | grep "PATCHLEVEL =" | head -1 | cut -d " " -f 3) - REVISION=$(($(cat ${CURRENT_DIR}/DETAILED_CHANGELOG | grep "rev" | head -1 | cut -d " " -f 1 | cut -c 4-) + 1)) - EXTRAVERSION=$(cat ${CURRENT_DIR}/Makefile | grep "EXTRAVERSION =" | head -1 | cut -d " " -f 3) - if [ ${EXTRAVERSION} != "" ]; then EXTRAVERSION=-${EXTRAVERSION}; fi - GIT_HASH=$(git -C ${CURRENT_DIR}/ rev-parse --short=7 HEAD 2>/dev/null) - if [ ${GIT_HASH} != "" ]; then GIT_HASH=-${GIT_HASH}; fi + VERSION=$(cat "${CURRENT_DIR}/Makefile" | grep "VERSION =" | head -1 | cut -d " " -f 3) + SUBVERSION=$(cat "${CURRENT_DIR}/Makefile" | grep "SUBVERSION =" | head -1 | cut -d " " -f 3) + PATCHLEVEL=$(cat "${CURRENT_DIR}/Makefile" | grep "PATCHLEVEL =" | head -1 | cut -d " " -f 3) + REVISION=$(($(cat "${CURRENT_DIR}/DETAILED_CHANGELOG" | grep "rev" | head -1 | cut -d " " -f 1 | cut -c 4-) + 1)) + EXTRAVERSION=$(cat "${CURRENT_DIR}/Makefile" | grep "EXTRAVERSION =" | head -1 | cut -d " " -f 3) + if [ "${EXTRAVERSION}" != "" ]; then EXTRAVERSION=-${EXTRAVERSION}; fi + GIT_HASH=$(git -C "${CURRENT_DIR}/" rev-parse --short=7 HEAD 2>/dev/null) + if [ "${GIT_HASH}" != "" ]; then GIT_HASH=-${GIT_HASH}; fi export OPL_VERSION=${VERSION}.${SUBVERSION}.${PATCHLEVEL}.${REVISION}${EXTRAVERSION}${GIT_HASH} fi # Print a list -printf "$(ls ${CURRENT_DIR}/lng/ | cut -c 6- | rev | cut -c 5- | rev)" > ${LANG_LIST} +printf "$(ls ${CURRENT_DIR}/lng/ | cut -c 6- | rev | cut -c 5- | rev)" > "${LANG_LIST}" # Copy format while IFS= read -r CURRENT_FILE do - mkdir -p ${BUILD_DIR}/${CURRENT_FILE}-${OPL_VERSION}/ - cp ${CURRENT_DIR}/lng/lang_${CURRENT_FILE}.lng ${BUILD_DIR}/${CURRENT_FILE}-${OPL_VERSION}/lang_${CURRENT_FILE}.lng - if [ -e thirdparty/font_${CURRENT_FILE}.ttf ] + mkdir -p "${BUILD_DIR}/${CURRENT_FILE}-${OPL_VERSION}/" + cp "${CURRENT_DIR}/lng/lang_${CURRENT_FILE}.lng" "${BUILD_DIR}/${CURRENT_FILE}-${OPL_VERSION}/lang_${CURRENT_FILE}.lng" + if [ -e "thirdparty/font_${CURRENT_FILE}.ttf" ] then - cp ${CURRENT_DIR}/thirdparty/font_${CURRENT_FILE}.ttf ${BUILD_DIR}/${CURRENT_FILE}-${OPL_VERSION}/font_${CURRENT_FILE}.ttf + cp "${CURRENT_DIR}/thirdparty/font_${CURRENT_FILE}.ttf" "${BUILD_DIR}/${CURRENT_FILE}-${OPL_VERSION}/font_${CURRENT_FILE}.ttf" fi done < ${LANG_LIST} @@ -65,13 +65,13 @@ EOF # Lets pack it! cd ${BUILD_DIR}/ -zip -r ${CURRENT_DIR}/OPNPS2LD_LANGS-${OPL_VERSION}.zip * +zip -r "${CURRENT_DIR}/OPNPS2LD_LANGS-${OPL_VERSION}.zip" * if [ -f "${CURRENT_DIR}/OPNPS2LD_LANGS-${OPL_VERSION}.zip" ] then echo "OPL Lang Package Complete: OPNPS2LD_LANGS-${OPL_VERSION}.zip" else echo "OPL Lang Package not found!" fi # Cleanup -cd ${CURRENT_DIR} +cd "${CURRENT_DIR}" rm -rf ${BUILD_DIR}/ ${LANG_LIST} unset CURRENT_DIR BUILD_DIR LANG_LIST OPL_VERSION CURRENT_FILE From 9d3d3a55d5b96a553deffc1c0266ef2cebab8fec Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 01:17:58 -0500 Subject: [PATCH 20/22] lng_pack: glob relative to current directory to avoid adding options --- lng_pack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lng_pack.sh b/lng_pack.sh index d46aae8f0..65318c9fe 100755 --- a/lng_pack.sh +++ b/lng_pack.sh @@ -65,7 +65,7 @@ EOF # Lets pack it! cd ${BUILD_DIR}/ -zip -r "${CURRENT_DIR}/OPNPS2LD_LANGS-${OPL_VERSION}.zip" * +zip -r "${CURRENT_DIR}/OPNPS2LD_LANGS-${OPL_VERSION}.zip" ./* if [ -f "${CURRENT_DIR}/OPNPS2LD_LANGS-${OPL_VERSION}.zip" ] then echo "OPL Lang Package Complete: OPNPS2LD_LANGS-${OPL_VERSION}.zip" else echo "OPL Lang Package not found!" From e40c5938d7d1649e3b90a9d6e2a77851ac979758 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 01:20:28 -0500 Subject: [PATCH 21/22] Use shell builtin for stdin --- lng_pack.sh | 10 +++++----- make_changelog.sh | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lng_pack.sh b/lng_pack.sh index 65318c9fe..257748437 100755 --- a/lng_pack.sh +++ b/lng_pack.sh @@ -13,11 +13,11 @@ then export OPL_VERSION=$(make oplversion) else echo "Falling back to old OPL Lang Pack" - VERSION=$(cat "${CURRENT_DIR}/Makefile" | grep "VERSION =" | head -1 | cut -d " " -f 3) - SUBVERSION=$(cat "${CURRENT_DIR}/Makefile" | grep "SUBVERSION =" | head -1 | cut -d " " -f 3) - PATCHLEVEL=$(cat "${CURRENT_DIR}/Makefile" | grep "PATCHLEVEL =" | head -1 | cut -d " " -f 3) - REVISION=$(($(cat "${CURRENT_DIR}/DETAILED_CHANGELOG" | grep "rev" | head -1 | cut -d " " -f 1 | cut -c 4-) + 1)) - EXTRAVERSION=$(cat "${CURRENT_DIR}/Makefile" | grep "EXTRAVERSION =" | head -1 | cut -d " " -f 3) + VERSION=$(grep "VERSION =" < "${CURRENT_DIR}/Makefile" | head -1 | cut -d " " -f 3) + SUBVERSION=$(grep "SUBVERSION =" < "${CURRENT_DIR}/Makefile" | head -1 | cut -d " " -f 3) + PATCHLEVEL=$(grep "PATCHLEVEL =" < "${CURRENT_DIR}/Makefile" | head -1 | cut -d " " -f 3) + REVISION=$(($(grep "rev" < "${CURRENT_DIR}/DETAILED_CHANGELOG" | head -1 | cut -d " " -f 1 | cut -c 4-) + 1)) + EXTRAVERSION=$(grep "EXTRAVERSION =" < "${CURRENT_DIR}/Makefile" | head -1 | cut -d " " -f 3) if [ "${EXTRAVERSION}" != "" ]; then EXTRAVERSION=-${EXTRAVERSION}; fi GIT_HASH=$(git -C "${CURRENT_DIR}/" rev-parse --short=7 HEAD 2>/dev/null) if [ "${GIT_HASH}" != "" ]; then GIT_HASH=-${GIT_HASH}; fi diff --git a/make_changelog.sh b/make_changelog.sh index 9c3ce0dcd..cce60696f 100755 --- a/make_changelog.sh +++ b/make_changelog.sh @@ -38,8 +38,8 @@ fi printf '\n' >> /tmp/commit_summary # Store number of commits -old_number_commits=$(($(cat OLD_DETAILED_CHANGELOG | grep "rev" | head -1 | cut -d " " -f 1 | cut -c 4-))) -number_commits=$(cat /tmp/commit_summary | wc -l) +old_number_commits=$(($(grep "rev" < OLD_DETAILED_CHANGELOG | head -1 | cut -d " " -f 1 | cut -c 4-))) +number_commits=$(wc -l < /tmp/commit_summary) new_number_commits=$((${number_commits} - ${old_number_commits} + 2)) # Echo it! From 99ad8b4840308714d48a202862533cc86d0ae07d Mon Sep 17 00:00:00 2001 From: uyjulian Date: Tue, 15 Mar 2022 01:21:24 -0500 Subject: [PATCH 22/22] Remove unneeded brackets for math variables --- make_changelog.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make_changelog.sh b/make_changelog.sh index cce60696f..0e3d016f3 100755 --- a/make_changelog.sh +++ b/make_changelog.sh @@ -40,7 +40,7 @@ printf '\n' >> /tmp/commit_summary # Store number of commits old_number_commits=$(($(grep "rev" < OLD_DETAILED_CHANGELOG | head -1 | cut -d " " -f 1 | cut -c 4-))) number_commits=$(wc -l < /tmp/commit_summary) -new_number_commits=$((${number_commits} - ${old_number_commits} + 2)) +new_number_commits=$((number_commits - old_number_commits + 2)) # Echo it! echo "Current Revision ${number_commits} (Of BitBucket r${old_number_commits} + Of GIT r${new_number_commits})" @@ -62,7 +62,7 @@ gawk '{ L[n++] = $0 } END { while(n--) print L[n] }' /tmp/commit_summary > /tmp/ # Store each commit in one variable[list] while read line_commit_summary do - old_number_commits=$((${old_number_commits} + 1)) + old_number_commits=$((old_number_commits + 1)) echo "rev${old_number_commits} - ${line_commit_summary}" >> /tmp/commit_summary_new done < /tmp/commit_summary_reverse