Skip to content

(WIP) Rework of DTLS code, add DTLS PKI/RPK #168

(WIP) Rework of DTLS code, add DTLS PKI/RPK

(WIP) Rework of DTLS code, add DTLS PKI/RPK #168

GitHub Actions / clippy (libcoap-rs) completed Sep 30, 2024 in 1s

reviewdog [clippy (libcoap-rs)] report

reported by reviewdog 🐶

Findings (13)

libcoap/src/context.rs|18 col 5| warning: unused import: coap_context_set_pki_root_cas
--> libcoap/src/context.rs:18:5
|
18 | coap_context_set_pki_root_cas, coap_context_set_session_timeout, coap_context_t, coap_event_t, coap_free_context,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
libcoap/src/context.rs|23 col 5| warning: unused import: std::ffi::CString
--> libcoap/src/context.rs:23:5
|
23 | use std::ffi::CString;
| ^^^^^^^^^^^^^^^^^
libcoap/src/context.rs|24 col 5| warning: unused import: std::path::Path
--> libcoap/src/context.rs:24:5
|
24 | use std::path::Path;
| ^^^^^^^^^^^^^^^
libcoap/src/context.rs|45 col 5| warning: unused import: std::os::unix::ffi::OsStrExt
--> libcoap/src/context.rs:45:5
|
45 | use std::os::unix::ffi::OsStrExt;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
libcoap/src/crypto/psk/client.rs|71 col 37| warning: use of .then_some(..).unwrap_or(..) can be written more clearly with if .. else ..
--> libcoap/src/crypto/psk/client.rs:71:37
|
71 | self.ctx.raw_cfg.ec_jpake = ec_jpake.then_some(1).unwrap_or(0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: if ec_jpake { 1 } else { 0 }
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
= note: #[warn(clippy::obfuscated_if_else)] on by default
libcoap/src/crypto/psk/client.rs|77 col 36| warning: use of .then_some(..).unwrap_or(..) can be written more clearly with if .. else ..
--> libcoap/src/crypto/psk/client.rs:77:36
|
77 | self.ctx.raw_cfg.use_cid = use_cid.then_some(1).unwrap_or(0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: if use_cid { 1 } else { 0 }
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
libcoap/src/crypto/psk/client.rs|231 col 39| warning: derefed type is same as origin
--> libcoap/src/crypto/psk/client.rs:231:39
|
231 | if identity_hint.is_none() || key.identity().as_deref() == identity_hint {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: key.identity()
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref
= note: #[warn(clippy::needless_option_as_deref)] on by default
libcoap/src/crypto/psk/key.rs|127 col 43| warning: casting the result of from_raw_parts_mut to *mut [u8]
--> libcoap/src/crypto/psk/key.rs:127:43
|
127 | let data = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(key.s as *mut u8, key.length) as *mut [u8]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: core::ptr::slice_from_raw_parts_mut(key.s as *mut u8, key.length)
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_from_raw_parts
= note: #[warn(clippy::cast_slice_from_raw_parts)] on by default
libcoap/src/crypto/psk/key.rs|136 col 19| warning: useless conversion to the same type: std::boxed::Box<[u8]>
--> libcoap/src/crypto/psk/key.rs:136:19
|
136 | data: value.into(),
| ^^^^^^^^^^^^ help: consider removing .into(): value
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
libcoap/src/crypto/psk/server.rs|75 col 37| warning: use of .then_some(..).unwrap_or(..) can be written more clearly with if .. else ..
--> libcoap/src/crypto/psk/server.rs:75:37
|
75 | self.ctx.raw_cfg.ec_jpake = ec_jpake.then_some(1).unwrap_or(0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: if ec_jpake { 1 } else { 0 }
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
libcoap/src/crypto/psk/server.rs|236 col 23| warning: derefed type is same as origin
--> libcoap/src/crypto/psk/server.rs:236:23
|
236 | .find(|k| k.identity().as_deref().is_some_and(|kid| kid == identity))
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: k.identity()
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref
libcoap/src/crypto/psk/server.rs|255 col 20| warning: this call to as_ref does nothing
--> libcoap/src/crypto/psk/server.rs:255:20
|
255 | let keys = self.as_ref();
| ^^^^^^^^^^^^^ help: try: self
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref
= note: #[warn(clippy::useless_asref)] on by default
libcoap/src/types.rs|779 col 17| warning: using libc::strlen on a CString or CStr value
--> libcoap/src/types.rs:779:17
|
779 | libc::strlen(uri.uri_str.0.as_ptr()),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: uri.uri_str.0.as_bytes().len()
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#strlen_on_c_strings
= note: #[warn(clippy::strlen_on_c_strings)] on by default

Filtered Findings (0)

Annotations

Check warning on line 18 in libcoap/src/context.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/context.rs#L18

warning: unused import: `coap_context_set_pki_root_cas`
  --> libcoap/src/context.rs:18:5
   |
18 |     coap_context_set_pki_root_cas, coap_context_set_session_timeout, coap_context_t, coap_event_t, coap_free_context,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default
Raw output
libcoap/src/context.rs:18:5:w:warning: unused import: `coap_context_set_pki_root_cas`
  --> libcoap/src/context.rs:18:5
   |
18 |     coap_context_set_pki_root_cas, coap_context_set_session_timeout, coap_context_t, coap_event_t, coap_free_context,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default


__END__

Check warning on line 23 in libcoap/src/context.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/context.rs#L23

warning: unused import: `std::ffi::CString`
  --> libcoap/src/context.rs:23:5
   |
23 | use std::ffi::CString;
   |     ^^^^^^^^^^^^^^^^^
Raw output
libcoap/src/context.rs:23:5:w:warning: unused import: `std::ffi::CString`
  --> libcoap/src/context.rs:23:5
   |
23 | use std::ffi::CString;
   |     ^^^^^^^^^^^^^^^^^


__END__

Check warning on line 24 in libcoap/src/context.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/context.rs#L24

warning: unused import: `std::path::Path`
  --> libcoap/src/context.rs:24:5
   |
24 | use std::path::Path;
   |     ^^^^^^^^^^^^^^^
Raw output
libcoap/src/context.rs:24:5:w:warning: unused import: `std::path::Path`
  --> libcoap/src/context.rs:24:5
   |
24 | use std::path::Path;
   |     ^^^^^^^^^^^^^^^


__END__

Check warning on line 45 in libcoap/src/context.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/context.rs#L45

warning: unused import: `std::os::unix::ffi::OsStrExt`
  --> libcoap/src/context.rs:45:5
   |
45 | use std::os::unix::ffi::OsStrExt;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Raw output
libcoap/src/context.rs:45:5:w:warning: unused import: `std::os::unix::ffi::OsStrExt`
  --> libcoap/src/context.rs:45:5
   |
45 | use std::os::unix::ffi::OsStrExt;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^


__END__

Check warning on line 71 in libcoap/src/crypto/psk/client.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/crypto/psk/client.rs#L71

warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`
  --> libcoap/src/crypto/psk/client.rs:71:37
   |
71 |         self.ctx.raw_cfg.ec_jpake = ec_jpake.then_some(1).unwrap_or(0);
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if ec_jpake { 1 } else { 0 }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
   = note: `#[warn(clippy::obfuscated_if_else)]` on by default
Raw output
libcoap/src/crypto/psk/client.rs:71:37:w:warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`
  --> libcoap/src/crypto/psk/client.rs:71:37
   |
71 |         self.ctx.raw_cfg.ec_jpake = ec_jpake.then_some(1).unwrap_or(0);
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if ec_jpake { 1 } else { 0 }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
   = note: `#[warn(clippy::obfuscated_if_else)]` on by default


__END__

Check warning on line 77 in libcoap/src/crypto/psk/client.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/crypto/psk/client.rs#L77

warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`
  --> libcoap/src/crypto/psk/client.rs:77:36
   |
77 |         self.ctx.raw_cfg.use_cid = use_cid.then_some(1).unwrap_or(0);
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if use_cid { 1 } else { 0 }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
Raw output
libcoap/src/crypto/psk/client.rs:77:36:w:warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`
  --> libcoap/src/crypto/psk/client.rs:77:36
   |
77 |         self.ctx.raw_cfg.use_cid = use_cid.then_some(1).unwrap_or(0);
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if use_cid { 1 } else { 0 }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else


__END__

Check warning on line 231 in libcoap/src/crypto/psk/client.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/crypto/psk/client.rs#L231

warning: derefed type is same as origin
   --> libcoap/src/crypto/psk/client.rs:231:39
    |
231 |         if identity_hint.is_none() || key.identity().as_deref() == identity_hint {
    |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `key.identity()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref
    = note: `#[warn(clippy::needless_option_as_deref)]` on by default
Raw output
libcoap/src/crypto/psk/client.rs:231:39:w:warning: derefed type is same as origin
   --> libcoap/src/crypto/psk/client.rs:231:39
    |
231 |         if identity_hint.is_none() || key.identity().as_deref() == identity_hint {
    |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `key.identity()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref
    = note: `#[warn(clippy::needless_option_as_deref)]` on by default


__END__

Check warning on line 127 in libcoap/src/crypto/psk/key.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/crypto/psk/key.rs#L127

warning: casting the result of `from_raw_parts_mut` to *mut [u8]
   --> libcoap/src/crypto/psk/key.rs:127:43
    |
127 |         let data = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(key.s as *mut u8, key.length) as *mut [u8]) };
    |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts_mut(key.s as *mut u8, key.length)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_from_raw_parts
    = note: `#[warn(clippy::cast_slice_from_raw_parts)]` on by default
Raw output
libcoap/src/crypto/psk/key.rs:127:43:w:warning: casting the result of `from_raw_parts_mut` to *mut [u8]
   --> libcoap/src/crypto/psk/key.rs:127:43
    |
127 |         let data = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(key.s as *mut u8, key.length) as *mut [u8]) };
    |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts_mut(key.s as *mut u8, key.length)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_from_raw_parts
    = note: `#[warn(clippy::cast_slice_from_raw_parts)]` on by default


__END__

Check warning on line 136 in libcoap/src/crypto/psk/key.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/crypto/psk/key.rs#L136

warning: useless conversion to the same type: `std::boxed::Box<[u8]>`
   --> libcoap/src/crypto/psk/key.rs:136:19
    |
136 |             data: value.into(),
    |                   ^^^^^^^^^^^^ help: consider removing `.into()`: `value`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
Raw output
libcoap/src/crypto/psk/key.rs:136:19:w:warning: useless conversion to the same type: `std::boxed::Box<[u8]>`
   --> libcoap/src/crypto/psk/key.rs:136:19
    |
136 |             data: value.into(),
    |                   ^^^^^^^^^^^^ help: consider removing `.into()`: `value`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion


__END__

Check warning on line 75 in libcoap/src/crypto/psk/server.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/crypto/psk/server.rs#L75

warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`
  --> libcoap/src/crypto/psk/server.rs:75:37
   |
75 |         self.ctx.raw_cfg.ec_jpake = ec_jpake.then_some(1).unwrap_or(0);
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if ec_jpake { 1 } else { 0 }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
Raw output
libcoap/src/crypto/psk/server.rs:75:37:w:warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..`
  --> libcoap/src/crypto/psk/server.rs:75:37
   |
75 |         self.ctx.raw_cfg.ec_jpake = ec_jpake.then_some(1).unwrap_or(0);
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if ec_jpake { 1 } else { 0 }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else


__END__

Check warning on line 236 in libcoap/src/crypto/psk/server.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/crypto/psk/server.rs#L236

warning: derefed type is same as origin
   --> libcoap/src/crypto/psk/server.rs:236:23
    |
236 |             .find(|k| k.identity().as_deref().is_some_and(|kid| kid == identity))
    |                       ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `k.identity()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref
Raw output
libcoap/src/crypto/psk/server.rs:236:23:w:warning: derefed type is same as origin
   --> libcoap/src/crypto/psk/server.rs:236:23
    |
236 |             .find(|k| k.identity().as_deref().is_some_and(|kid| kid == identity))
    |                       ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `k.identity()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref


__END__

Check warning on line 255 in libcoap/src/crypto/psk/server.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/crypto/psk/server.rs#L255

warning: this call to `as_ref` does nothing
   --> libcoap/src/crypto/psk/server.rs:255:20
    |
255 |         let keys = self.as_ref();
    |                    ^^^^^^^^^^^^^ help: try: `self`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref
    = note: `#[warn(clippy::useless_asref)]` on by default
Raw output
libcoap/src/crypto/psk/server.rs:255:20:w:warning: this call to `as_ref` does nothing
   --> libcoap/src/crypto/psk/server.rs:255:20
    |
255 |         let keys = self.as_ref();
    |                    ^^^^^^^^^^^^^ help: try: `self`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref
    = note: `#[warn(clippy::useless_asref)]` on by default


__END__

Check warning on line 779 in libcoap/src/types.rs

See this annotation in the file changed.

@github-actions github-actions / clippy (libcoap-rs)

[clippy (libcoap-rs)] libcoap/src/types.rs#L779

warning: using `libc::strlen` on a `CString` or `CStr` value
   --> libcoap/src/types.rs:779:17
    |
779 |                 libc::strlen(uri.uri_str.0.as_ptr()),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uri.uri_str.0.as_bytes().len()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#strlen_on_c_strings
    = note: `#[warn(clippy::strlen_on_c_strings)]` on by default
Raw output
libcoap/src/types.rs:779:17:w:warning: using `libc::strlen` on a `CString` or `CStr` value
   --> libcoap/src/types.rs:779:17
    |
779 |                 libc::strlen(uri.uri_str.0.as_ptr()),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uri.uri_str.0.as_bytes().len()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#strlen_on_c_strings
    = note: `#[warn(clippy::strlen_on_c_strings)]` on by default


__END__