Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lints #22

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install toml
- name: Install reuse
run: |
sudo apt install -y reuse
- name: Install rust
run: |
rustup show
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ serde = ["dep:serde", "serde_bytes"]
builder = ["typed-builder"]

log-all = []
log-trace = []
log-debug = []
log-info = []
log-warn = []
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ check: src/se05x/commands.rs

.PHONY: lint
lint: src/se05x/commands.rs verify-commands
reuse lint
cargo c
cargo fmt --check
cargo clippy
Expand All @@ -34,7 +35,11 @@ lint: src/se05x/commands.rs verify-commands
cargo doc --features aes-session,builder,serde --no-deps

README.md: src/lib.rs Makefile
grep '//!' src/lib.rs |grep -v '//! # ' | sed 's/^...//g' | sed 's/^ //g' > README.md
# REUSE-IgnoreStart
echo '<!-- Copyright (C) 2023 Nitrokey GmbH -->' > README.md
echo '<!-- SPDX-License-Identifier: LGPL-3.0-only -->' >> README.md
# REUSE-IgnoreEnd
grep '//!' src/lib.rs |grep -v '//! # ' | sed 's/^...//g' | sed 's/^ //g' >> README.md

.PHONY: ci
ci: export RUSTFLAGS=-Dwarnings
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Copyright (C) 2023 Nitrokey GmbH -->
<!-- SPDX-License-Identifier: LGPL-3.0-only -->

SE05X driver
===========
Expand Down
14 changes: 7 additions & 7 deletions generate_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,16 @@ def flatten(items):
break

payload_lifetime = ""
payload_lifetime_inferred = ""
if payload_has_lifetime:
payload_lifetime = "<'data>"
payload_lifetime_inferred = "<'_>"

response_lifetime = ""
response_lifetime_inferred = ""
if response_has_lifetime:
response_lifetime = "<'data>"
response_lifetime_inferred = "<'_>"


outfile.write("#[derive(Clone, Debug, PartialEq, Eq)]\n")
Expand Down Expand Up @@ -207,7 +211,7 @@ def flatten(items):
if force_extended:
command_builder = f'{command_builder}.force_extended()'

outfile.write(f'impl{payload_lifetime} DataSource for {name}{payload_lifetime} {{\n')
outfile.write(f'impl DataSource for {name}{payload_lifetime_inferred} {{\n')
outfile.write(' fn len(&self) -> usize {\n')
outfile.write(f' {slice_val_pre}')
outfile.write(f' let __data: &[&dyn DataSource] = {slice_val};\n')
Expand All @@ -222,12 +226,8 @@ def flatten(items):
outfile.write(' }\n')
outfile.write("}\n")

bound = "<W: Writer>"
if payload_has_lifetime:
bound = "<'data, W: Writer>"


outfile.write(f'impl{bound} DataStream<W> for {name}{payload_lifetime} {{\n')
outfile.write(f'impl<W: Writer> DataStream<W> for {name}{payload_lifetime_inferred} {{\n')
outfile.write(' fn to_writer(&self, writer: &mut W) -> Result<(), <W as iso7816::command::Writer>::Error> {\n')
outfile.write(f' {slice_val_pre}')
outfile.write(f' let __data: &[&dyn DataStream<W>] = {slice_val};\n')
Expand Down Expand Up @@ -264,7 +264,7 @@ def flatten(items):
outfile.write("}\n")

outfile.write("\n")
outfile.write(f'impl{bound} Se05XCommand<W> for {name}{payload_lifetime} {{\n')
outfile.write(f'impl<W: Writer> Se05XCommand<W> for {name}{payload_lifetime_inferred} {{\n')
if "response" not in v:
outfile.write(f' type Response<\'rdata> = ();\n')
elif response_has_lifetime:
Expand Down
2 changes: 2 additions & 0 deletions src/doc_utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (C) 2023 Nitrokey GmbH
// SPDX-License-Identifier: LGPL-3.0-only
// utilities for doctests
//
// Not included in the crate, meant to be used with `include!`
Expand Down
4 changes: 2 additions & 2 deletions src/se05x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub trait Se05XCommand<W: Writer>: DataStream<W> {
type Response<'a>: Se05XResponse<'a>;
}

impl<'b, W: Writer, C: Se05XCommand<W>> Se05XCommand<W> for &'b C {
impl<W: Writer, C: Se05XCommand<W>> Se05XCommand<W> for &'_ C {
type Response<'a> = C::Response<'a>;
}

Expand Down Expand Up @@ -1749,7 +1749,7 @@ where
Ok((value.map(TryInto::try_into).transpose()?, rem))
}

impl<'a> commands::ReadEcCurveListResponse<'a> {
impl commands::ReadEcCurveListResponse<'_> {
pub fn is_set(&self, curve: EcCurve) -> bool {
let id: u8 = curve.into();
if id >= 0x40 {
Expand Down
Loading