Skip to content

Commit

Permalink
Codacy warnings
Browse files Browse the repository at this point in the history
Github action
  • Loading branch information
AKuHAK committed Mar 23, 2022
1 parent b6cfac0 commit d07ba02
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 29 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI-compile

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
container: ps2dev/ps2dev:v1.0
# instead of "ps2dev/ps2dev:latest" you can use different tags, for example for old projects you can use "ps2dev/ps2dev:v1.0"
steps:
- name: Install dependencies
run: |
apk add build-base git zip
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- name: Get short SHA and repository name
id: slug
run: |
echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
echo "::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")"
- name: Compile osd
run: |
make -C osd
ls -l osd
# zip HDDChecker-${{ steps.slug.outputs.sha8 }}.zip HDDChecker.elf lang/*
- name: Compile kpatch
run: |
make -C kpatch/patch0100
make -C kpatch/patch0101
ls -l kpatch/patch0100
ls -l kpatch/patch0101
- name: Upload artifacts
if: ${{ success() }}
uses: actions/upload-artifact@v2
with:
path: |
osd/example.elf
kpatch/patch0100/osdsys.elf
kpatch/patch0101/osd110.elf
- name: Create pre-release
if: github.ref == 'refs/heads/main'
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
automatic_release_tag: "latest"
title: "Development build"
files: |
osd/example.elf
kpatch/patch0100/osdsys.elf
kpatch/patch0101/osd110.elf
- name: Create Tagged Release Draft
if: startsWith(github.ref, 'refs/tags/v')
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
draft: true
files: |
osd/example.elf
kpatch/patch0100/osdsys.elf
kpatch/patch0101/osd110.elf
2 changes: 1 addition & 1 deletion kpatch/Rules.patch.make
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ $(EE_BIN) : $(EE_OBJS)
-o $(EE_BIN) $(EE_CRT0_OBJ) $(EE_OBJS) $(EE_LDFLAGS) $(EE_LIBS)
$(EE_STRIP) -s -d -R .mdebug.eabi64 -R .reginfo -R .comment $(EE_BIN)

clean::
clean:
rm -f $(EE_BIN) $(EE_OBJS) $(MAPFILE)
94 changes: 94 additions & 0 deletions kpatch/crt0-eeload.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright (c) 2001-2007 ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
#
# Modified startup file for MBR EELOAD
# Removed libc initialization, support for C++ and kernel patches.

.extern _heap_size
.extern _stack
.extern _stack_size

.extern Exit
.extern FlushCache

.set noat
.set noreorder

.section .start
.align 2

.globl _start
.ent _start
_start:

zerobss:
# clear bss area

la $2, _fbss
la $3, _end

1:
sltu $1, $2, $3
beq $1, $0, 2f
nop
sq $0, ($2)
addiu $2, $2, 16
j 1b
nop
2:

setupthread:
# setup current thread

la $4, _gp
la $5, _stack
la $6, _stack_size
la $7, _args
la $8, _root
move $gp, $4
addiu $3, $0, 60
syscall # SetupThread(_gp, _stack, _stack_size, _args, _root)
move $sp, $2

# initialize heap

la $4, _end
la $5, _heap_size
addiu $3, $0, 61
syscall # SetupHeap(_end, _heap_size)

# writeback data cache
jal FlushCache # FlushCache(0)
move $4, $0

# call main
ei

la $16, _args
lw $4, ($16)
jal main # main(argc, argv)
addiu $5, $16, 4

# call _exit

j Exit # Exit(retval) (noreturn)
move $4, $2
.end _start

.align 3

.ent _root
_root:
addiu $3, $0, 35
syscall # ExitThread() (noreturn)
.end _root

.bss
.align 6
_args:
.space 4+16*4+256 # argc, 16 arguments, 256 bytes payload
6 changes: 3 additions & 3 deletions kpatch/patch0100/EELOAD/EELOAD.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ static void PatchOSDSYS(void)
/* 0x000821d0 */
static void SyncSIF0(void)
{
int i;

// If SIF0 has incoming data, initialize SIF0 and acknowledge incoming data.
if (*DMA_REG_STAT & 0x20)
{
int i;

SifSetDChain(); // Re-initialize SIF0 (IOP -> EE)
*DMA_REG_STAT = 0x20;
while (*R_EE_SBUS_REG40 & 0x3000) {};
Expand Down Expand Up @@ -198,7 +198,6 @@ static void BootError(const char *path)
/* 0x00082440 */
int main(int argc, char *argv[])
{
const char *CommandString;
int i;

if (argc >= 2)
Expand All @@ -219,6 +218,7 @@ int main(int argc, char *argv[])

while (argc > 0)
{
const char *CommandString;
if ((CommandString = IsSwitchCheck("-m ", argv[0])) != NULL)
{
SifLoadModule(CommandString, 0, NULL);
Expand Down
6 changes: 3 additions & 3 deletions kpatch/patch0101/EELOAD/EELOAD.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ static void PatchOSDSYS(void)
/* 0x00082180 */
static void SyncSIF0(void)
{
int i;

// If SIF0 has incoming data, initialize SIF0 and acknowledge incoming data.
if (*DMA_REG_STAT & 0x20)
{
int i;

SifSetDChain(); // Re-initialize SIF0 (IOP -> EE)
*DMA_REG_STAT = 0x20;
while (*R_EE_SBUS_REG40 & 0x3000) {};
Expand Down Expand Up @@ -197,7 +197,6 @@ static void BootError(const char *path)
// 0x000823d8
int main(int argc, char *argv[])
{
const char *CommandString;
int i;

if (argc >= 2)
Expand All @@ -217,6 +216,7 @@ int main(int argc, char *argv[])

while (argc > 0)
{
const char *CommandString;
if ((CommandString = IsSwitchCheck("-m ", argv[0])) != NULL)
{
SifLoadModule(CommandString, 0, NULL);
Expand Down
7 changes: 3 additions & 4 deletions osd/common/OSDHistory.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,9 @@ static u16 GetTimestamp(void)

static void AddHistoryRecord(const char *name)
{
struct HistoryEntry *NewEntry;
int i, value, LeastUsedRecord, LeastUsedRecordLaunchCount, LeastUsedRecordTimestamp, NewLaunchCount;
u8 BlankSlotList[MAX_HISTORY_ENTRIES];
int NumBlankSlots, NumSlotsUsed, IsNewRecord;
int IsNewRecord;

LeastUsedRecord = 0;
LeastUsedRecordTimestamp = INT_MAX;
Expand Down Expand Up @@ -360,8 +359,7 @@ static void AddHistoryRecord(const char *name)
if (IsNewRecord)
{
// Count and consolidate a list of blank slots.
NumBlankSlots = 0;
NumSlotsUsed = 0;
int NumBlankSlots = 0, NumSlotsUsed = 0;
for (i = 0; i < MAX_HISTORY_ENTRIES; i++)
{
if (HistoryEntries[i].name[0] == '\0')
Expand All @@ -378,6 +376,7 @@ static void AddHistoryRecord(const char *name)

if (NumSlotsUsed != MAX_HISTORY_ENTRIES)
{
struct HistoryEntry *NewEntry;
if (NumBlankSlots > 0)
{ // Randomly choose an empty slot.
NewEntry = &HistoryEntries[BlankSlotList[rand() % NumBlankSlots]];
Expand Down
17 changes: 8 additions & 9 deletions osd/common/OSDInit.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ char ConsoleROMVER[ROMVER_MAX_LEN];
static int InitMGRegion(void)
{
u32 stat;
int result;

if (ConsoleRegionParamInitStatus == 0)
{
int result;
do
{
if ((result = sceCdReadRegionParams(ConsoleRegionData, &stat)) == 0)
Expand Down Expand Up @@ -85,9 +85,9 @@ static int InitMGRegion(void)
void OSDInitSystemPaths(void)
{
int region;
char regions[CONSOLE_REGION_COUNT] = {'I', 'A', 'E', 'C'};
const char regions[CONSOLE_REGION_COUNT] = {'I', 'A', 'E', 'C'};

region = OSDGetConsoleRegion();
region = OSDGetConsoleRegion();
if (region >= 0 && region < CONSOLE_REGION_COUNT)
{
SystemDataFolder[1] = regions[region];
Expand Down Expand Up @@ -170,13 +170,14 @@ int OSDGetDVDPlayerRegion(char *region)

static int GetConsoleRegion(void)
{
char romver[16];
int fd, result;
int result;

if ((result = ConsoleRegion) < 0)
{
int fd;
if ((fd = open("rom0:ROMVER", O_RDONLY)) >= 0)
{
char romver[16];
read(fd, romver, sizeof(romver));
close(fd);
ConsoleRegionParamsInitPS1DRV(romver);
Expand Down Expand Up @@ -235,10 +236,10 @@ static int CdReadOSDRegionParams(char *OSDVer)
static int GetOSDRegion(void)
{
char OSDVer[16];
int fd;

if (ConsoleOSDRegionInitStatus == 0 || ConsoleOSDRegion == -1)
{
int fd;
ConsoleOSDRegionInitStatus = 1;
if ((fd = open("rom0:OSDVER", O_RDONLY)) >= 0)
{
Expand Down Expand Up @@ -284,11 +285,9 @@ static int GetOSDRegion(void)

static void InitOSDDefaultLanguage(int region, const char *language)
{
int DefaultLang;

DefaultLang = -1;
if (ConsoleOSDLanguage == -1)
{
int DefaultLang = -1;
if (language != NULL)
{
if (strncmp(language, "jpn", 3) == 0)
Expand Down
2 changes: 1 addition & 1 deletion osd/common/libcdvd_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int cdInitAdd(void)
}
}

// printf("Failed to get MECHACON version: %d 0x%x\n", result, status);
// printf("Failed to get MECHACON version: %d 0x%x\n", result, status);

return -1;
}
Expand Down
3 changes: 2 additions & 1 deletion osd/common/modelname.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern char ConsoleROMVER[];

static int ReadModelName(char *name)
{
int stat, result, fd;
int stat, result;

/* This function is a hybrid between the late ROM browser program and the HDD Browser.
In v2.20, there was only a simple null-terminate before calling sceCdRM(), as below.
Expand All @@ -40,6 +40,7 @@ static int ReadModelName(char *name)
strcpy(name, "SCPH-10000");
else
{ // For ROM v1.01 (Late SCPH-10000, and all SCPH-15000 units).
int fd;
if ((fd = open("rom0:OSDSYS", O_RDONLY)) >= 0)
{ // The model name is located at this address.
lseek(fd, 0x8C808, SEEK_SET);
Expand Down
10 changes: 6 additions & 4 deletions osd/common/ps1.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ const char *PS1DRVGetVersion(void)

static void CNFGetKey(char *cnf, char *line, const char *key)
{
const char *pKey;
int len;

if ((len = strlen(key)) != 0)
Expand All @@ -115,6 +114,7 @@ static void CNFGetKey(char *cnf, char *line, const char *key)

if (*cnf == '=')
{ // Equals sign found
const char *pKey;
++cnf;

for (; isspace(*cnf); cnf++)
Expand Down Expand Up @@ -155,10 +155,8 @@ static void CNFGetKey(char *cnf, char *line, const char *key)

static int ParseBootCNF(void)
{
char system_cnf[2048], line[128];
const char *pChar;
u32 stat;
int fd, size, i, len;
int fd;

strcpy(ps1drv_ver, "???");
strcpy(ps1drv_boot, "???");
Expand Down Expand Up @@ -192,6 +190,10 @@ static int ParseBootCNF(void)

if ((fd = open("cdrom0:\\SYSTEM.CNF;1", O_RDWR)) >= 0)
{
char system_cnf[2048], line[128];
const char *pChar;
int size, i, len;

size = read(fd, system_cnf, sizeof(system_cnf));
close(fd);

Expand Down
Loading

0 comments on commit d07ba02

Please sign in to comment.