Skip to content

Commit a47aca1

Browse files
committed
Added clippy workflow
1 parent 89be0f4 commit a47aca1

File tree

3 files changed

+73
-19
lines changed

3 files changed

+73
-19
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
push:
3+
branches: [ master ]
4+
pull_request:
5+
merge_group:
6+
7+
name: Lints compliance check
8+
9+
env:
10+
CLIPPY_PARAMS: -W clippy::all -W clippy::pedantic -W clippy::nursery -W clippy::cargo
11+
12+
jobs:
13+
clippy:
14+
strategy:
15+
matrix:
16+
toolchain: [ stable, nightly ]
17+
cargo_flags:
18+
- "--no-default-features"
19+
- "--all-features"
20+
include:
21+
# Nightly is only for reference and allowed to fail
22+
- toolchain: nightly
23+
experimental: true
24+
runs-on: ubuntu-latest
25+
continue-on-error: ${{ matrix.experimental || false }}
26+
steps:
27+
- uses: actions/checkout@v3
28+
- uses: dtolnay/rust-toolchain@master
29+
with:
30+
toolchain: ${{ matrix.toolchain }}
31+
components: clippy
32+
- name: Run clippy
33+
run: cargo clippy --all ${{ matrix.cargo_flags }} -- -D warnings
34+
35+
# Job to check that all the lint checks succeeded
36+
clippy-check:
37+
needs:
38+
- clippy
39+
runs-on: ubuntu-latest
40+
if: always()
41+
steps:
42+
- run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

riscv-rt/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- New GitHub workflow for checking clippy lints in PRs
13+
1014
### Changed
1115

1216
- Use inline assembly instead of pre-compiled blobs
1317
- Removed bors in favor of GitHub Merge Queue
18+
- `start_trap_rust` is now marked as `unsafe`
1419

1520
## [v0.11.0] - 2023-01-18
1621

riscv-rt/src/lib.rs

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@
106106
//! Disassembly of section .text:
107107
//!
108108
//! 20000000 <_start>:
109-
//! 20000000: 800011b7 lui gp,0x80001
110-
//! 20000004: 80018193 addi gp,gp,-2048 # 80000800 <_stack_start+0xffffc800>
111-
//! 20000008: 80004137 lui sp,0x80004
109+
//! 20000000: 800011b7 lui gp,0x80001
110+
//! 20000004: 80018193 addi gp,gp,-2048 # 80000800 <_stack_start+0xffffc800>
111+
//! 20000008: 80004137 lui sp,0x80004
112112
//! ```
113113
//!
114114
//! # Symbol interfaces
@@ -393,8 +393,12 @@ extern "C" {
393393

394394
/// Rust entry point (_start_rust)
395395
///
396-
/// Zeros bss section, initializes data section and calls main. This function
397-
/// never returns.
396+
/// Zeros bss section, initializes data section and calls main. This function never returns.
397+
///
398+
/// # Safety
399+
///
400+
/// This function must be called only from assembly `_start` function.
401+
/// Do **NOT** call this function directly.
398402
#[link_section = ".init.rust"]
399403
#[export_name = "_start_rust"]
400404
pub unsafe extern "C" fn start_rust(a0: usize, a1: usize, a2: usize) -> ! {
@@ -459,29 +463,32 @@ pub struct TrapFrame {
459463
/// `scause`/`mcause` is read to determine the cause of the trap. XLEN-1 bit indicates
460464
/// if it's an interrupt or an exception. The result is examined and ExceptionHandler
461465
/// or one of the core interrupt handlers is called.
466+
///
467+
/// # Safety
468+
///
469+
/// This function must be called only from assembly `_start_trap` function.
470+
/// Do **NOT** call this function directly.
462471
#[link_section = ".trap.rust"]
463472
#[export_name = "_start_trap_rust"]
464-
pub extern "C" fn start_trap_rust(trap_frame: *const TrapFrame) {
473+
pub unsafe extern "C" fn start_trap_rust(trap_frame: *const TrapFrame) {
465474
extern "C" {
466475
fn ExceptionHandler(trap_frame: &TrapFrame);
467476
fn DefaultHandler();
468477
}
469478

470-
unsafe {
471-
let cause = xcause::read();
472-
473-
if cause.is_exception() {
474-
ExceptionHandler(&*trap_frame)
475-
} else if cause.code() < __INTERRUPTS.len() {
476-
let h = &__INTERRUPTS[cause.code()];
477-
if h.reserved == 0 {
478-
DefaultHandler();
479-
} else {
480-
(h.handler)();
481-
}
482-
} else {
479+
let cause = xcause::read();
480+
481+
if cause.is_exception() {
482+
ExceptionHandler(&*trap_frame)
483+
} else if cause.code() < __INTERRUPTS.len() {
484+
let h = &__INTERRUPTS[cause.code()];
485+
if h.reserved == 0 {
483486
DefaultHandler();
487+
} else {
488+
(h.handler)();
484489
}
490+
} else {
491+
DefaultHandler();
485492
}
486493
}
487494

0 commit comments

Comments
 (0)