diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cb15d60..5cb4130 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,6 +27,7 @@ jobs: needs: rust-version runs-on: ubuntu-latest strategy: + fail-fast: false matrix: rust-version: - ${{ needs.rust-version.outputs.version }} diff --git a/examples/async.rs b/examples/async.rs index 43ce3db..f46f20e 100644 --- a/examples/async.rs +++ b/examples/async.rs @@ -218,7 +218,7 @@ extern "C" fn ngx_http_async_commands_set_enable( } }; - std::ptr::null_mut() + ngx::core::NGX_CONF_OK } fn ngx_http_async_runtime() -> &'static Runtime { diff --git a/examples/awssig.rs b/examples/awssig.rs index 384f98d..7a93e10 100644 --- a/examples/awssig.rs +++ b/examples/awssig.rs @@ -188,7 +188,7 @@ extern "C" fn ngx_http_awssigv4_commands_set_enable( } }; - std::ptr::null_mut() + ngx::core::NGX_CONF_OK } extern "C" fn ngx_http_awssigv4_commands_set_access_key( @@ -202,7 +202,7 @@ extern "C" fn ngx_http_awssigv4_commands_set_access_key( conf.access_key = (*args.add(1)).to_string(); }; - std::ptr::null_mut() + ngx::core::NGX_CONF_OK } extern "C" fn ngx_http_awssigv4_commands_set_secret_key( @@ -216,7 +216,7 @@ extern "C" fn ngx_http_awssigv4_commands_set_secret_key( conf.secret_key = (*args.add(1)).to_string(); }; - std::ptr::null_mut() + ngx::core::NGX_CONF_OK } extern "C" fn ngx_http_awssigv4_commands_set_s3_bucket( @@ -230,10 +230,11 @@ extern "C" fn ngx_http_awssigv4_commands_set_s3_bucket( conf.s3_bucket = (*args.add(1)).to_string(); if conf.s3_bucket.len() == 1 { println!("Validation failed"); - return ngx::core::NGX_CONF_ERROR as _; + return ngx::core::NGX_CONF_ERROR; } }; - std::ptr::null_mut() + + ngx::core::NGX_CONF_OK } extern "C" fn ngx_http_awssigv4_commands_set_s3_endpoint( @@ -247,7 +248,7 @@ extern "C" fn ngx_http_awssigv4_commands_set_s3_endpoint( conf.s3_endpoint = (*args.add(1)).to_string(); }; - std::ptr::null_mut() + ngx::core::NGX_CONF_OK } http_request_handler!(awssigv4_header_handler, |request: &mut Request| { diff --git a/examples/curl.rs b/examples/curl.rs index c8d9d2c..da7c9da 100644 --- a/examples/curl.rs +++ b/examples/curl.rs @@ -131,5 +131,5 @@ extern "C" fn ngx_http_curl_commands_set_enable( } }; - std::ptr::null_mut() + ngx::core::NGX_CONF_OK } diff --git a/examples/upstream.rs b/examples/upstream.rs index b928672..7517ece 100644 --- a/examples/upstream.rs +++ b/examples/upstream.rs @@ -282,7 +282,7 @@ unsafe extern "C" fn ngx_http_upstream_commands_set_custom( value[1], &(*cmd).name ); - return usize::MAX as *mut c_char; + return ngx::core::NGX_CONF_ERROR; } ccf.max = n as u32; } @@ -298,8 +298,8 @@ unsafe extern "C" fn ngx_http_upstream_commands_set_custom( uscf.peer.init_upstream = Some(ngx_http_upstream_init_custom); ngx_log_debug_mask!(DebugMask::Http, cf.log, "CUSTOM UPSTREAM end module init"); - // NGX_CONF_OK - std::ptr::null_mut() + + ngx::core::NGX_CONF_OK } // The upstream module. diff --git a/nginx-sys/build/main.rs b/nginx-sys/build/main.rs index 22208dd..f2dc1af 100644 --- a/nginx-sys/build/main.rs +++ b/nginx-sys/build/main.rs @@ -216,6 +216,8 @@ fn generate_binding(nginx: &NginxSource) { // Bindings will not compile on Linux without block listing this item // It is worth investigating why this is .blocklist_item("IPPORT_RESERVED") + // will be restored later in build.rs + .blocklist_item("NGX_ALIGNMENT") .generate_cstr(true) // The input header we would like to generate bindings for. .header("build/wrapper.h") @@ -339,22 +341,19 @@ pub fn print_cargo_metadata>(includes: &[T]) -> Result<(), Box() <= NGX_ALIGNMENT); + impl ngx_command_t { /// Creates a new empty [`ngx_command_t`] instance. /// diff --git a/src/core/status.rs b/src/core/status.rs index 46bb79f..4cab884 100644 --- a/src/core/status.rs +++ b/src/core/status.rs @@ -1,4 +1,6 @@ +use core::ffi::c_char; use core::fmt; +use core::ptr; use crate::ffi::*; @@ -62,6 +64,7 @@ ngx_codes! { (NGX_ABORT); } -/// NGX_CONF_ERROR - An error occurred while parsing and validating configuration. -pub const NGX_CONF_ERROR: *const () = -1isize as *const (); -// pub const CONF_OK: Status = Status(NGX_CONF_OK as ngx_int_t); +/// An error occurred while parsing and validating configuration. +pub const NGX_CONF_ERROR: *mut c_char = ptr::null_mut::().wrapping_offset(-1); +/// Configuration handler succeeded. +pub const NGX_CONF_OK: *mut c_char = ptr::null_mut(); diff --git a/src/core/string.rs b/src/core/string.rs index a456ac6..1db73f8 100644 --- a/src/core/string.rs +++ b/src/core/string.rs @@ -73,7 +73,7 @@ impl NgxStr { /// /// See [`String::from_utf8_lossy`]. #[cfg(feature = "alloc")] - pub fn to_string_lossy(&self) -> Cow { + pub fn to_string_lossy(&self) -> Cow<'_, str> { String::from_utf8_lossy(self.as_bytes()) } diff --git a/src/http/request.rs b/src/http/request.rs index c3a2155..d17d294 100644 --- a/src/http/request.rs +++ b/src/http/request.rs @@ -375,13 +375,13 @@ impl Request { /// Iterate over headers_in /// each header item is (&str, &str) (borrowed) - pub fn headers_in_iterator(&self) -> NgxListIterator { + pub fn headers_in_iterator(&self) -> NgxListIterator<'_> { unsafe { list_iterator(&self.0.headers_in.headers) } } /// Iterate over headers_out /// each header item is (&str, &str) (borrowed) - pub fn headers_out_iterator(&self) -> NgxListIterator { + pub fn headers_out_iterator(&self) -> NgxListIterator<'_> { unsafe { list_iterator(&self.0.headers_out.headers) } } } @@ -448,7 +448,7 @@ impl<'a> From<&'a ngx_list_part_t> for ListPart<'a> { /// # Safety /// /// The caller has provided a valid [`ngx_str_t`] which can be dereferenced validly. -pub unsafe fn list_iterator(list: &ngx_list_t) -> NgxListIterator { +pub unsafe fn list_iterator(list: &ngx_list_t) -> NgxListIterator<'_> { NgxListIterator { part: Some((&list.part).into()), i: 0,