Skip to content

Commit

Permalink
fix: apply code review suggestions from #26
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Romann <[email protected]>
  • Loading branch information
pulsastrix and JKRhb authored Aug 22, 2024
1 parent 7815176 commit 8fef921
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion libcoap-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ q-block = []
# Corresponding libcoap configure flag: --enable-thread-safe
thread-safe = []
# Enable this feature to enable/require recursive lock detection in the C library.
# Will also implicitly enable the `thread-safe` feature.
# Corresponding libcoap configure flag: --enable-thread-recursive-lock-detection
thread-recursive-lock-detection = ["thread-safe"]
# Enable this feature to set/require the small stack flag in the C library.
Expand All @@ -114,7 +115,7 @@ epoll = []
# Enable this feature to require support for CoAP over WebSockets using TLS in the C library.
# Whether this feature is supported by the C library depends on the used DTLS library.
secure-websockets = ["tls", "websockets"]
# Enabling this feature to require support for CIDs in DTLS in the C library.
# Enable this feature to require support for CIDs in DTLS in the C library.
# Whether this feature is supported by the C library depends on the used DTLS library.
dtls-cid = ["dtls"]
# Enabling this feature to require support for DTLS-PSK in the C library.
Expand Down
8 changes: 4 additions & 4 deletions libcoap-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use bindgen::{
use pkg_config::probe_library;
use version_compare::{Cmp, Version};

/// Features whose availability can be checked during compile time based on defines.
/// Features whose availability can be checked during compile time based on `#define` directives.
const COMPILE_TIME_FEATURE_CHECKS: [&str; 16] = [
"af-unix",
"async",
Expand Down Expand Up @@ -63,14 +63,14 @@ impl Default for LibcoapMetadata {
package_version: Default::default(),
version: 0,
feature_defines_available: false,
// COAP_DISABLE_TCP is set if TCP is _not_ supported, assume it is supported otherwise.
// By default, TCP is assumed to be supported if COAP_DISABLE_TCP is unset.
feature_defines: BTreeSet::from(["tcp".to_string()]),
dtls_backend: None,
}
}
}

/// Implementation of bindgen's [ParseCallbacks] that allow reading some metainformation about the
/// Implementation of bindgen's [ParseCallbacks] that allow reading some meta-information about the
/// used libcoap version from its defines (package version, supported features, ...)
#[derive(Debug, Default)]
struct CoapDefineParser {
Expand Down Expand Up @@ -794,7 +794,7 @@ fn main() {
println!("cargo:warning=DTLS library used by libcoap does not match chosen one. This might lead to issues.")
}
} else {
println!("cargo:warning=The used version of libcoap does not provide a coap_defines.h file, either because it is too old (<4.3.5) or because this file is somehow not included. Compile-time feature checks are not available, and the availability of some features (small-stack, IPv4/IPv6,) can not be asserted at all!");
println!("cargo:warning=The used version of libcoap does not provide a coap_defines.h file, either because it is too old (<4.3.5) or because this file is somehow not included. Compile-time feature checks are not available, and the availability of some features (small-stack, IPv4/IPv6,) cannot be asserted at all!");
}

let out_path = PathBuf::from(out_dir);
Expand Down
2 changes: 2 additions & 0 deletions libcoap/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BSD-2-CLAUSE

use version_compare::{Cmp, Version};

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion libcoap/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,9 @@ impl CoapUri {
parsing_fn: unsafe extern "C" fn(*const u8, usize, *mut coap_uri_t) -> c_int,
is_proxy: bool,
) -> Result<CoapUri, UriParsingError> {
ensure_coap_started();
let mut uri = Self::create_unparsed_uri(uri_str, is_proxy);

ensure_coap_started();
// SAFETY: The provided pointers to raw_uri and uri_str are valid.
// Because uri_str is pinned (and its type is not Unpin), the pointer locations are always
// valid while this object lives, therefore the resulting coap_uri_t remains valid for the
Expand Down

0 comments on commit 8fef921

Please sign in to comment.