Update .clang-format rules

This commit is contained in:
Maschell 2022-02-03 15:30:41 +01:00
parent e61bc53afa
commit 2b2810cb96
4 changed files with 70 additions and 70 deletions

View File

@ -2,7 +2,7 @@
BasedOnStyle: LLVM BasedOnStyle: LLVM
AccessModifierOffset: -4 AccessModifierOffset: -4
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align AlignOperands: Align
AllowAllArgumentsOnNextLine: false AllowAllArgumentsOnNextLine: false

View File

@ -95,7 +95,7 @@ int IOSUHAX_Close(void) {
if (iosuhaxHandle < 0) if (iosuhaxHandle < 0)
return 0; return 0;
int res = IOS_Close(iosuhaxHandle); int res = IOS_Close(iosuhaxHandle);
iosuhaxHandle = -1; iosuhaxHandle = -1;
return res; return res;
} }
@ -123,12 +123,12 @@ int IOSUHAX_ODM_GetDiscKey(uint8_t *discKey) {
return -2; return -2;
} }
int odm_handle = IOS_Open("/dev/odm", 1); int odm_handle = IOS_Open("/dev/odm", 1);
res = odm_handle; res = odm_handle;
if (odm_handle >= 0) { if (odm_handle >= 0) {
uint32_t io_buffer[0x20 / 4]; uint32_t io_buffer[0x20 / 4];
// disc encryption key, only works with patched IOSU // disc encryption key, only works with patched IOSU
io_buffer[0] = 3; io_buffer[0] = 3;
res = IOS_Ioctl(odm_handle, 0x06, io_buffer, 0x14, io_buffer, 0x20); res = IOS_Ioctl(odm_handle, 0x06, io_buffer, 0x14, io_buffer, 0x20);
if (res == 0) { if (res == 0) {
memcpy(discKey, io_buffer, 16); memcpy(discKey, io_buffer, 16);
} }
@ -207,16 +207,16 @@ int IOSUHAX_read_seeprom(uint8_t *out_buffer, uint32_t offset, uint32_t size) {
return -1; return -1;
} }
uint32_t sizeInShorts = size >> 1; uint32_t sizeInShorts = size >> 1;
uint32_t offsetInShorts = offset >> 1; uint32_t offsetInShorts = offset >> 1;
int32_t maxReadCount = 0x100 - offsetInShorts; int32_t maxReadCount = 0x100 - offsetInShorts;
if (maxReadCount <= 0) { if (maxReadCount <= 0) {
return 0; return 0;
} }
uint32_t count = sizeInShorts > maxReadCount ? maxReadCount : sizeInShorts; uint32_t count = sizeInShorts > maxReadCount ? maxReadCount : sizeInShorts;
uint16_t *ptr = (uint16_t *) out_buffer; uint16_t *ptr = (uint16_t *) out_buffer;
int res = 0; int res = 0;
@ -703,7 +703,7 @@ int IOSUHAX_FSA_StatFile(int fsaFd, int fileHandle, fileStat_s *out_data) {
io_buf[0] = fsaFd; io_buf[0] = fsaFd;
io_buf[1] = fileHandle; io_buf[1] = fileHandle;
int out_buf_size = 4 + sizeof(fileStat_s); int out_buf_size = 4 + sizeof(fileStat_s);
uint32_t *out_buffer = (uint32_t *) memalign(0x20, out_buf_size); uint32_t *out_buffer = (uint32_t *) memalign(0x20, out_buf_size);
if (!out_buffer) { if (!out_buffer) {
free(io_buf); free(io_buf);
@ -796,7 +796,7 @@ int IOSUHAX_FSA_GetStat(int fsaFd, const char *path, fileStat_s *out_data) {
io_buf[1] = sizeof(uint32_t) * input_cnt; io_buf[1] = sizeof(uint32_t) * input_cnt;
strcpy(((char *) io_buf) + io_buf[1], path); strcpy(((char *) io_buf) + io_buf[1], path);
int out_buf_size = 4 + sizeof(fileStat_s); int out_buf_size = 4 + sizeof(fileStat_s);
uint32_t *out_buffer = (uint32_t *) memalign(0x20, out_buf_size); uint32_t *out_buffer = (uint32_t *) memalign(0x20, out_buf_size);
if (!out_buffer) { if (!out_buffer) {
free(io_buf); free(io_buf);
@ -894,7 +894,7 @@ int IOSUHAX_FSA_RawRead(int fsaFd, void *data, uint32_t block_size, uint32_t blo
const int input_cnt = 6; const int input_cnt = 6;
int io_buf_size = 0x40 + block_size * block_cnt; int io_buf_size = 0x40 + block_size * block_cnt;
uint32_t *io_buf = (uint32_t *) memalign(0x40, ROUNDUP(io_buf_size, 0x40)); uint32_t *io_buf = (uint32_t *) memalign(0x40, ROUNDUP(io_buf_size, 0x40));
if (!io_buf) if (!io_buf)

View File

@ -60,7 +60,7 @@ typedef struct _fs_dev_dir_entry_t {
static fs_dev_private_t *fs_dev_get_device_data(const char *path) { static fs_dev_private_t *fs_dev_get_device_data(const char *path) {
const devoptab_t *devoptab = NULL; const devoptab_t *devoptab = NULL;
char name[128] = {0}; char name[128] = {0};
int i; int i;
// Get the device name from the path // Get the device name from the path
@ -121,35 +121,35 @@ static int fs_dev_open_r(struct _reent *r, void *fileStruct, const char *path, i
// Map flags to open modes // Map flags to open modes
if (flags == 0) { if (flags == 0) {
file->read = 1; file->read = 1;
file->write = 0; file->write = 0;
file->append = 0; file->append = 0;
fsMode = "r"; fsMode = "r";
} else if (flags == 2) { } else if (flags == 2) {
file->read = 1; file->read = 1;
file->write = 1; file->write = 1;
file->append = 0; file->append = 0;
fsMode = "r+"; fsMode = "r+";
} else if (flags == 0x601) { } else if (flags == 0x601) {
file->read = 0; file->read = 0;
file->write = 1; file->write = 1;
file->append = 0; file->append = 0;
fsMode = "w"; fsMode = "w";
} else if (flags == 0x602) { } else if (flags == 0x602) {
file->read = 1; file->read = 1;
file->write = 1; file->write = 1;
file->append = 0; file->append = 0;
fsMode = "w+"; fsMode = "w+";
} else if (flags == 0x209) { } else if (flags == 0x209) {
file->read = 0; file->read = 0;
file->write = 1; file->write = 1;
file->append = 1; file->append = 1;
fsMode = "a"; fsMode = "a";
} else if (flags == 0x20A) { } else if (flags == 0x20A) {
file->read = 1; file->read = 1;
file->write = 1; file->write = 1;
file->append = 1; file->append = 1;
fsMode = "a+"; fsMode = "a+";
} else { } else {
r->_errno = EINVAL; r->_errno = EINVAL;
return -1; return -1;
@ -180,7 +180,7 @@ static int fs_dev_open_r(struct _reent *r, void *fileStruct, const char *path, i
OSUnlockMutex(dev->pMutex); OSUnlockMutex(dev->pMutex);
return -1; return -1;
} }
file->fd = fd; file->fd = fd;
file->pos = 0; file->pos = 0;
file->len = stats.size; file->len = stats.size;
OSUnlockMutex(dev->pMutex); OSUnlockMutex(dev->pMutex);
@ -307,7 +307,7 @@ static ssize_t fs_dev_read_r(struct _reent *r, void *fd, char *ptr, size_t len)
int result = IOSUHAX_FSA_ReadFile(file->dev->fsaFd, ptr + done, 0x01, read_size, file->fd, 0); int result = IOSUHAX_FSA_ReadFile(file->dev->fsaFd, ptr + done, 0x01, read_size, file->fd, 0);
if (result < 0) { if (result < 0) {
r->_errno = result; r->_errno = result;
done = 0; done = 0;
break; break;
} else if (result == 0) { } else if (result == 0) {
//! TODO: error on read_size > 0 //! TODO: error on read_size > 0
@ -343,16 +343,16 @@ static int fs_dev_fstat_r(struct _reent *r, void *fd, struct stat *st) {
return -1; return -1;
} }
st->st_mode = S_IFREG; st->st_mode = S_IFREG;
st->st_size = stats.size; st->st_size = stats.size;
st->st_blocks = (stats.size + 511) >> 9; st->st_blocks = (stats.size + 511) >> 9;
st->st_nlink = 1; st->st_nlink = 1;
// Fill in the generic entry stats // Fill in the generic entry stats
st->st_dev = stats.id; st->st_dev = stats.id;
st->st_uid = stats.owner_id; st->st_uid = stats.owner_id;
st->st_gid = stats.group_id; st->st_gid = stats.group_id;
st->st_ino = stats.id; st->st_ino = stats.id;
st->st_atime = stats.mtime; st->st_atime = stats.mtime;
st->st_ctime = stats.ctime; st->st_ctime = stats.ctime;
st->st_mtime = stats.mtime; st->st_mtime = stats.mtime;
@ -416,15 +416,15 @@ static int fs_dev_stat_r(struct _reent *r, const char *path, struct stat *st) {
} }
// mark root also as directory // mark root also as directory
st->st_mode = ((stats.flag & 0x80000000) || (strlen(dev->mount_path) + 1 == strlen(real_path))) ? S_IFDIR : S_IFREG; st->st_mode = ((stats.flag & 0x80000000) || (strlen(dev->mount_path) + 1 == strlen(real_path))) ? S_IFDIR : S_IFREG;
st->st_nlink = 1; st->st_nlink = 1;
st->st_size = stats.size; st->st_size = stats.size;
st->st_blocks = (stats.size + 511) >> 9; st->st_blocks = (stats.size + 511) >> 9;
// Fill in the generic entry stats // Fill in the generic entry stats
st->st_dev = stats.id; st->st_dev = stats.id;
st->st_uid = stats.owner_id; st->st_uid = stats.owner_id;
st->st_gid = stats.group_id; st->st_gid = stats.group_id;
st->st_ino = stats.id; st->st_ino = stats.id;
st->st_atime = stats.mtime; st->st_atime = stats.mtime;
st->st_ctime = stats.ctime; st->st_ctime = stats.ctime;
st->st_mtime = stats.mtime; st->st_mtime = stats.mtime;
@ -692,7 +692,7 @@ static DIR_ITER *fs_dev_diropen_r(struct _reent *r, DIR_ITER *dirState, const ch
return NULL; return NULL;
} }
dirIter->dev = dev; dirIter->dev = dev;
dirIter->dirHandle = dirHandle; dirIter->dirHandle = dirHandle;
return dirState; return dirState;
@ -762,17 +762,17 @@ static int fs_dev_dirnext_r(struct _reent *r, DIR_ITER *dirState, char *filename
if (st) { if (st) {
memset(st, 0, sizeof(struct stat)); memset(st, 0, sizeof(struct stat));
st->st_mode = (dir_entry->stat.flag & 0x80000000) ? S_IFDIR : S_IFREG; st->st_mode = (dir_entry->stat.flag & 0x80000000) ? S_IFDIR : S_IFREG;
st->st_nlink = 1; st->st_nlink = 1;
st->st_size = dir_entry->stat.size; st->st_size = dir_entry->stat.size;
st->st_blocks = (dir_entry->stat.size + 511) >> 9; st->st_blocks = (dir_entry->stat.size + 511) >> 9;
st->st_dev = dir_entry->stat.id; st->st_dev = dir_entry->stat.id;
st->st_uid = dir_entry->stat.owner_id; st->st_uid = dir_entry->stat.owner_id;
st->st_gid = dir_entry->stat.group_id; st->st_gid = dir_entry->stat.group_id;
st->st_ino = dir_entry->stat.id; st->st_ino = dir_entry->stat.id;
st->st_atime = dir_entry->stat.mtime; st->st_atime = dir_entry->stat.mtime;
st->st_ctime = dir_entry->stat.ctime; st->st_ctime = dir_entry->stat.ctime;
st->st_mtime = dir_entry->stat.mtime; st->st_mtime = dir_entry->stat.mtime;
} }
free(dir_entry); free(dir_entry);
@ -811,8 +811,8 @@ static const devoptab_t devops_fs = {
static int fs_dev_add_device(const char *name, const char *mount_path, int fsaFd, int isMounted) { static int fs_dev_add_device(const char *name, const char *mount_path, int fsaFd, int isMounted) {
devoptab_t *dev = NULL; devoptab_t *dev = NULL;
char *devname = NULL; char *devname = NULL;
char *devpath = NULL; char *devpath = NULL;
int i; int i;
// Sanity check // Sanity check
@ -845,9 +845,9 @@ static int fs_dev_add_device(const char *name, const char *mount_path, int fsaFd
// setup private data // setup private data
priv->mount_path = devpath; priv->mount_path = devpath;
priv->fsaFd = fsaFd; priv->fsaFd = fsaFd;
priv->mounted = isMounted; priv->mounted = isMounted;
priv->pMutex = malloc(OS_MUTEX_SIZE); priv->pMutex = malloc(OS_MUTEX_SIZE);
if (!priv->pMutex) { if (!priv->pMutex) {
free(dev); free(dev);
@ -860,7 +860,7 @@ static int fs_dev_add_device(const char *name, const char *mount_path, int fsaFd
// Setup the devoptab // Setup the devoptab
memcpy(dev, &devops_fs, sizeof(devoptab_t)); memcpy(dev, &devops_fs, sizeof(devoptab_t));
dev->name = devname; dev->name = devname;
dev->deviceData = priv; dev->deviceData = priv;
// Add the device to the devoptab table (if there is a free slot) // Add the device to the devoptab table (if there is a free slot)
@ -882,7 +882,7 @@ static int fs_dev_add_device(const char *name, const char *mount_path, int fsaFd
static int fs_dev_remove_device(const char *path) { static int fs_dev_remove_device(const char *path) {
const devoptab_t *devoptab = NULL; const devoptab_t *devoptab = NULL;
char name[128] = {0}; char name[128] = {0};
int i; int i;
// Get the device name from the path // Get the device name from the path

View File

@ -31,18 +31,18 @@
static int initialized = 0; static int initialized = 0;
static int fsaFdSd = 0; static int fsaFdSd = 0;
static int fsaFdUsb = 0; static int fsaFdUsb = 0;
static int sdioFd = 0; static int sdioFd = 0;
static int usbFd = 0; static int usbFd = 0;
static void IOSUHAX_disc_io_initialize(void) { static void IOSUHAX_disc_io_initialize(void) {
if (initialized == 0) { if (initialized == 0) {
initialized = 1; initialized = 1;
fsaFdSd = -1; fsaFdSd = -1;
fsaFdUsb = -1; fsaFdUsb = -1;
sdioFd = -1; sdioFd = -1;
usbFd = -1; usbFd = -1;
} }
} }