Format the code via clang-format

This commit is contained in:
Maschell 2022-02-04 15:47:35 +01:00
parent dcbf322005
commit 3cf879dee7
21 changed files with 233 additions and 145 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

View File

@ -6,8 +6,16 @@ on:
- master
jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary

View File

@ -3,8 +3,16 @@ name: CI-PR
on: [pull_request]
jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary

View File

@ -1,3 +1,5 @@
[![CI-Release](https://github.com/wiiu-env/wiiload_plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/wiiload_plugin/actions/workflows/ci.yml)
## Usage
(`[ENVIRONMENT]` is a placeholder for the actual environment name.)
@ -19,3 +21,7 @@ docker run -it --rm -v ${PWD}:/project wiiloadplugin-builder make
# make clean
docker run -it --rm -v ${PWD}:/project wiiloadplugin-builder make clean
```
## Format the code via docker
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`

View File

@ -1,7 +1,7 @@
#include <cstdarg>
#include <cstdio>
#include <strings.h>
#include <fs/CFile.hpp>
#include <strings.h>
CFile::CFile() {
iFd = -1;
@ -170,5 +170,3 @@ int32_t CFile::fwrite(const char *format, ...) {
return result;
}

View File

@ -1,9 +1,9 @@
#pragma once
#include <cstdio>
#include <string>
#include <cstring>
#include <fcntl.h>
#include <string>
#include <unistd.h>
#include <wut_types.h>

View File

@ -24,14 +24,14 @@
* DirList Class
* for WiiXplorer 2010
***************************************************************************/
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <strings.h>
#include <algorithm>
#include <sys/stat.h>
#include <sys/dirent.h>
#include <sys/stat.h>
#include <fs/DirList.h>
#include <utils/StringTools.h>

View File

@ -26,8 +26,8 @@
***************************************************************************/
#pragma once
#include <vector>
#include <string>
#include <vector>
#include <wut_types.h>
typedef struct {
@ -59,7 +59,8 @@ public:
//!\param list index
[[nodiscard]] const char *GetFilepath(int32_t index) const {
if (!valid(index)) return "";
else return FileInfo[index].FilePath;
else
return FileInfo[index].FilePath;
}
//! Get the a filesize of the list
@ -93,6 +94,7 @@ public:
Dirs = 0x02,
CheckSubfolders = 0x08,
};
protected:
// Internal parser
BOOL InternalLoadPath(std::string &path);

View File

@ -1,10 +1,10 @@
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <fs/FSUtils.h>
#include <fs/CFile.hpp>
#include <fs/FSUtils.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <utils/logger.h>
int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
@ -139,4 +139,3 @@ BOOL FSUtils::saveBufferToFile(const char *path, void *buffer, uint32_t size) {
file.close();
return true;
}

View File

@ -1,6 +1,6 @@
#include <wups.h>
#include "utils/logger.h"
#include "utils/TcpReceiver.h"
#include "utils/logger.h"
#include <wups.h>
WUPS_PLUGIN_NAME("Wiiload");
WUPS_PLUGIN_DESCRIPTION("Wiiload Server");

View File

@ -16,11 +16,11 @@
****************************************************************************/
#pragma once
#include <malloc.h>
#include <unistd.h>
#include "utils/logger.h"
#include <coreinit/systeminfo.h>
#include <coreinit/thread.h>
#include "utils/logger.h"
#include <malloc.h>
#include <unistd.h>
class CThread {
public:
@ -128,6 +128,7 @@ public:
eAttributeDetach = 0x08,
eAttributePinnedAff = 0x10
};
private:
static int threadCallback(int argc, const char **argv) {
//! After call to start() continue with the internal function

View File

@ -23,17 +23,16 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <vector>
#include <string>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <string>
#include <strings.h>
#include <wut_types.h>
#include <stdio.h>
#include <utils/StringTools.h>
#include <vector>
#include <wchar.h>
#include <wut_types.h>
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {

View File

@ -26,8 +26,8 @@
#ifndef __STRING_TOOLS_H
#define __STRING_TOOLS_H
#include <vector>
#include <string>
#include <vector>
#include <wut_types.h>
class StringTools {
@ -85,4 +85,3 @@ public:
};
#endif /* __STRING_TOOLS_H */

View File

@ -1,24 +1,24 @@
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>
#include <zlib.h>
#include <string>
#include <sysapp/launch.h>
#include <vector>
#include <zlib.h>
#include <coreinit/dynload.h>
#include <coreinit/title.h>
#include <coreinit/messagequeue.h>
#include <coreinit/ios.h>
#include <coreinit/debug.h>
#include <coreinit/cache.h>
#include <coreinit/debug.h>
#include <coreinit/dynload.h>
#include <coreinit/ios.h>
#include <coreinit/messagequeue.h>
#include <coreinit/title.h>
#include <sysapp/title.h>
#include "TcpReceiver.h"
#include "fs/FSUtils.h"
#include "utils/net.h"
#include "utils/utils.h"
#include <wups_backend/PluginUtils.h>
#include <rpxloader.h>
#include <wups_backend/PluginUtils.h>
#define RPX_TEMP_PATH "fs:/vol/external01/wiiu/apps/"
#define RPX_TEMP_FILE "fs:/vol/external01/wiiu/apps/temp.rpx"
@ -243,8 +243,7 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
finalList.push_back(newContainer.value());
for (auto &plugin : oldPlugins) {
if (plugin.metaInformation.getName() == newContainer->metaInformation.getName() &&
plugin.metaInformation.getAuthor() == newContainer->metaInformation.getAuthor()
) {
plugin.metaInformation.getAuthor() == newContainer->metaInformation.getAuthor()) {
DEBUG_FUNCTION_LINE("Skipping duplicate");
PluginUtils::destroyPluginContainer(plugin);
continue;

View File

@ -1,7 +1,7 @@
#pragma once
#include <vector>
#include <string>
#include <vector>
#include "CThread.h"

View File

@ -1,8 +1,8 @@
#ifdef DEBUG
#include <stdint.h>
#include <whb/log_udp.h>
#include <whb/log_cafe.h>
#include <whb/log_module.h>
#include <whb/log_udp.h>
uint32_t moduleLogInit = false;
uint32_t cafeLogInit = false;

View File

@ -1,7 +1,7 @@
#pragma once
#include <whb/log.h>
#include <string.h>
#include <whb/log.h>
#ifdef __cplusplus
extern "C" {
@ -14,11 +14,13 @@ extern "C" {
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
@ -39,4 +41,3 @@ void deinitLogging();
#ifdef __cplusplus
}
#endif

View File

@ -6,16 +6,16 @@
extern "C" {
#endif
#include <stdint.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
int32_t recvwait(int32_t sock, void *buffer, int32_t len);

View File

@ -1,6 +1,6 @@
#include "utils/logger.h"
#include <string.h>
#include <whb/log.h>
#include "utils/logger.h"
// https://gist.github.com/ccbrown/9722406
void dumpHex(const void *data, size_t size) {

View File

@ -11,7 +11,8 @@ extern "C" {
typeof(x) _x = x; \
typeof(min) _min = min; \
typeof(max) _max = max; \
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
(((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
: (_x)); \
})
#define DegToRad(a) ((a) *0.01745329252f)