Skip to content

Commit

Permalink
test pre-commit
Browse files Browse the repository at this point in the history
Signed-off-by: Zone.N <[email protected]>
  • Loading branch information
MRNIU committed Dec 6, 2024
1 parent 65c0d4c commit e40971a
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 28 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ Checks: >
-readability-named-parameter,
-readability-braces-around-statements,
-readability-magic-numbers
HeaderFilterRegex: '^${sourceDir}/src/*'
FormatStyle: google
...
39 changes: 24 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,30 @@ repos:
- id: clang-format
args:
- --style=file
- id: clang-tidy
args:
- --checks=.clang-tidy
- -p=/root/SimpleKernel/build_riscv64/compiler_commands.json
- -extra-arg=--std=c++2b
- id: clang-tidy
args:
- --checks=.clang-tidy
- -p=/root/SimpleKernel/build_x86_64/compiler_commands.json
- -extra-arg=--std=c++2b
- id: clang-tidy
args:
- --checks=.clang-tidy
- -p=/root/SimpleKernel/build_aarch64/compiler_commands.json
- -extra-arg=--std=c++2b
# - id: clang-tidy
# args:
# - --checks=.clang-tidy
# - -p=/root/SimpleKernel/build_x86_64/build_x86_64/compiler_commands.json
# - -extra-arg=--std=c++2b
# - --fix
# - --header-filter=^(?/root/SimpleKernel/build_x86_64/src/).*
# - --exclude-header-filter=^(?/root/SimpleKernel/build_x86_64/src/arch/x86_64|/root/SimpleKernel/build_x86_64/src/arch/aarch64).*
# - id: clang-tidy
# args:
# - --checks=.clang-tidy
# - -p=/root/SimpleKernel/build_x86_64/build_x86_64/compiler_commands.json
# - -extra-arg=--std=c++2b
# - --fix
# - --header-filter=^(?/root/SimpleKernel/build_x86_64/src/).*
# - --exclude-header-filter=^(?/root/SimpleKernel/build_x86_64/src/arch/riscv_64|/root/SimpleKernel/build_x86_64/src/arch/aarch64).*
# - id: clang-tidy
# args:
# - --checks=.clang-tidy
# - -p=/root/SimpleKernel/build_x86_64/build_aarch64/compiler_commands.json
# - -extra-arg=--std=c++2b
# - --fix
# - --header-filter=^(?/root/SimpleKernel/build_x86_64/src/).*
# - --exclude-header-filter=^(?/root/SimpleKernel/build_x86_64/src/arch/riscv64|/root/SimpleKernel/build_x86_64/src/arch/x86_64).*

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
Expand Down
4 changes: 2 additions & 2 deletions cmake/project_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ ENDIF()
# 生成项目配置头文件,传递给代码
CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/tools/project_config.h.in
${CMAKE_SOURCE_DIR}/src/project_config.h @ONLY)
# CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/tools/.pre-commit-config.yaml.in
# ${CMAKE_SOURCE_DIR}/.pre-commit-config.yaml @ONLY)
CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/tools/.pre-commit-config.yaml.in
${CMAKE_SOURCE_DIR}/.pre-commit-config.yaml @ONLY)
11 changes: 6 additions & 5 deletions src/kernel/arch/x86_64/include/cpu/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ namespace cpu {
* @param port 要读的端口
* @return uint8_t 读取到的数据
*/
static __always_inline uint8_t InByte(const uint32_t port) {
static __always_inline auto InByte(const uint32_t port) -> uint8_t {
uint8_t data;

__asm__ volatile("inb %1, %0" : "=a"(data) : "dN"(port));
return data;
}
Expand All @@ -48,7 +49,7 @@ static __always_inline uint8_t InByte(const uint32_t port) {
* @param port 要读的端口
* @return uint16_t 读取到的数据
*/
static __always_inline uint16_t InWord(const uint32_t port) {
static __always_inline auto InWord(const uint32_t port) -> uint16_t {
uint16_t data;
__asm__ volatile("inw %1, %0" : "=a"(data) : "dN"(port));
return data;
Expand All @@ -59,7 +60,7 @@ static __always_inline uint16_t InWord(const uint32_t port) {
* @param port 要读的端口
* @return uint32_t 读取到的数据
*/
static __always_inline uint32_t InLong(const uint32_t port) {
static __always_inline auto InLong(const uint32_t port) -> uint32_t {
uint32_t data;
__asm__ volatile("inl %1, %0" : "=a"(data) : "dN"(port));
return data;
Expand Down Expand Up @@ -170,7 +171,7 @@ class Serial {
* @return false
*/
[[nodiscard]] auto SerialReceived() const -> bool {
return InByte(port_ + 5) & 1;
return bool(InByte(port_ + 5) & 1);
}

/**
Expand All @@ -179,7 +180,7 @@ class Serial {
* @return false
*/
[[nodiscard]] auto IsTransmitEmpty() const -> bool {
return InByte(port_ + 5) & 0x20;
return bool((InByte(port_ + 5) & 0x20) != 0);
}
};
}; // namespace cpu
Expand Down
29 changes: 24 additions & 5 deletions tools/.pre-commit-config.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,30 @@ repos:
- id: clang-format
args:
- --style=file
- id: clang-tidy
args:
- --checks=.clang-tidy
- -p=@CMAKE_BINARY_DIR@/compiler_commands.json
- -extra-arg=--std=c++2b
# - id: clang-tidy
# args:
# - --checks=.clang-tidy
# - -p=@CMAKE_BINARY_DIR@/build_x86_64/compiler_commands.json
# - -extra-arg=--std=c++2b
# - --fix
# - --header-filter=^(?@CMAKE_BINARY_DIR@/src/).*
# - --exclude-header-filter=^(?@CMAKE_BINARY_DIR@/src/arch/x86_64|@CMAKE_BINARY_DIR@/src/arch/aarch64).*
# - id: clang-tidy
# args:
# - --checks=.clang-tidy
# - -p=@CMAKE_BINARY_DIR@/build_x86_64/compiler_commands.json
# - -extra-arg=--std=c++2b
# - --fix
# - --header-filter=^(?@CMAKE_BINARY_DIR@/src/).*
# - --exclude-header-filter=^(?@CMAKE_BINARY_DIR@/src/arch/riscv_64|@CMAKE_BINARY_DIR@/src/arch/aarch64).*
# - id: clang-tidy
# args:
# - --checks=.clang-tidy
# - -p=@CMAKE_BINARY_DIR@/build_aarch64/compiler_commands.json
# - -extra-arg=--std=c++2b
# - --fix
# - --header-filter=^(?@CMAKE_BINARY_DIR@/src/).*
# - --exclude-header-filter=^(?@CMAKE_BINARY_DIR@/src/arch/riscv64|@CMAKE_BINARY_DIR@/src/arch/x86_64).*

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
Expand Down

0 comments on commit e40971a

Please sign in to comment.