Skip to content

Commit

Permalink
fix: non_upper_case_globals check after previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bavshin-f5 committed Jan 1, 2025
1 parent f4e8486 commit f3b36f3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
9 changes: 5 additions & 4 deletions examples/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Default for ModuleConfig {
}
}

static mut ngx_http_async_commands: [ngx_command_t; 2] = [
static mut NGX_HTTP_ASYNC_COMMANDS: [ngx_command_t; 2] = [
ngx_command_t {
name: ngx_string!("async"),
type_: (NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1) as ngx_uint_t,
Expand All @@ -66,7 +66,7 @@ static mut ngx_http_async_commands: [ngx_command_t; 2] = [
ngx_null_command!(),
];

static ngx_http_async_module_ctx: ngx_http_module_t = ngx_http_module_t {
static NGX_HTTP_ASYNC_MODULE_CTX: ngx_http_module_t = ngx_http_module_t {
preconfiguration: Some(Module::preconfiguration),
postconfiguration: Some(Module::postconfiguration),
create_main_conf: Some(Module::create_main_conf),
Expand All @@ -83,6 +83,7 @@ static ngx_http_async_module_ctx: ngx_http_module_t = ngx_http_module_t {
ngx::ngx_modules!(ngx_http_async_module);

#[used]
#[allow(non_upper_case_globals)]
#[cfg_attr(not(feature = "export-modules"), no_mangle)]
pub static mut ngx_http_async_module: ngx_module_t = ngx_module_t {
ctx_index: ngx_uint_t::MAX,
Expand All @@ -93,8 +94,8 @@ pub static mut ngx_http_async_module: ngx_module_t = ngx_module_t {
version: nginx_version as ngx_uint_t,
signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char,

ctx: &ngx_http_async_module_ctx as *const _ as *mut _,
commands: unsafe { &ngx_http_async_commands[0] as *const _ as *mut _ },
ctx: &NGX_HTTP_ASYNC_MODULE_CTX as *const _ as *mut _,
commands: unsafe { &NGX_HTTP_ASYNC_COMMANDS[0] as *const _ as *mut _ },
type_: NGX_HTTP_MODULE as ngx_uint_t,

init_master: None,
Expand Down
9 changes: 5 additions & 4 deletions examples/awssig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ModuleConfig {
s3_endpoint: String,
}

static mut ngx_http_awssigv4_commands: [ngx_command_t; 6] = [
static mut NGX_HTTP_AWSSIGV4_COMMANDS: [ngx_command_t; 6] = [
ngx_command_t {
name: ngx_string!("awssigv4"),
type_: (NGX_HTTP_LOC_CONF | NGX_HTTP_SRV_CONF | NGX_CONF_TAKE1) as ngx_uint_t,
Expand Down Expand Up @@ -86,7 +86,7 @@ static mut ngx_http_awssigv4_commands: [ngx_command_t; 6] = [
ngx_null_command!(),
];

static ngx_http_awssigv4_module_ctx: ngx_http_module_t = ngx_http_module_t {
static NGX_HTTP_AWSSIGV4_MODULE_CTX: ngx_http_module_t = ngx_http_module_t {
preconfiguration: Some(Module::preconfiguration),
postconfiguration: Some(Module::postconfiguration),
create_main_conf: Some(Module::create_main_conf),
Expand All @@ -103,6 +103,7 @@ static ngx_http_awssigv4_module_ctx: ngx_http_module_t = ngx_http_module_t {
ngx::ngx_modules!(ngx_http_awssigv4_module);

#[used]
#[allow(non_upper_case_globals)]
#[cfg_attr(not(feature = "export-modules"), no_mangle)]
pub static mut ngx_http_awssigv4_module: ngx_module_t = ngx_module_t {
ctx_index: ngx_uint_t::MAX,
Expand All @@ -113,8 +114,8 @@ pub static mut ngx_http_awssigv4_module: ngx_module_t = ngx_module_t {
version: nginx_version as ngx_uint_t,
signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char,

ctx: &ngx_http_awssigv4_module_ctx as *const _ as *mut _,
commands: unsafe { &ngx_http_awssigv4_commands[0] as *const _ as *mut _ },
ctx: &NGX_HTTP_AWSSIGV4_MODULE_CTX as *const _ as *mut _,
commands: unsafe { &NGX_HTTP_AWSSIGV4_COMMANDS[0] as *const _ as *mut _ },
type_: NGX_HTTP_MODULE as ngx_uint_t,

init_master: None,
Expand Down
9 changes: 5 additions & 4 deletions examples/curl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct ModuleConfig {
enable: bool,
}

static mut ngx_http_curl_commands: [ngx_command_t; 2] = [
static mut NGX_HTTP_CURL_COMMANDS: [ngx_command_t; 2] = [
ngx_command_t {
name: ngx_string!("curl"),
type_: (NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1) as ngx_uint_t,
Expand All @@ -48,7 +48,7 @@ static mut ngx_http_curl_commands: [ngx_command_t; 2] = [
ngx_null_command!(),
];

static ngx_http_curl_module_ctx: ngx_http_module_t = ngx_http_module_t {
static NGX_HTTP_CURL_MODULE_CTX: ngx_http_module_t = ngx_http_module_t {
preconfiguration: Some(Module::preconfiguration),
postconfiguration: Some(Module::postconfiguration),
create_main_conf: Some(Module::create_main_conf),
Expand All @@ -65,6 +65,7 @@ static ngx_http_curl_module_ctx: ngx_http_module_t = ngx_http_module_t {
ngx::ngx_modules!(ngx_http_curl_module);

#[used]
#[allow(non_upper_case_globals)]
#[cfg_attr(not(feature = "export-modules"), no_mangle)]
pub static mut ngx_http_curl_module: ngx_module_t = ngx_module_t {
ctx_index: ngx_uint_t::MAX,
Expand All @@ -75,8 +76,8 @@ pub static mut ngx_http_curl_module: ngx_module_t = ngx_module_t {
version: nginx_version as ngx_uint_t,
signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char,

ctx: &ngx_http_curl_module_ctx as *const _ as *mut _,
commands: unsafe { &ngx_http_curl_commands[0] as *const _ as *mut _ },
ctx: &NGX_HTTP_CURL_MODULE_CTX as *const _ as *mut _,
commands: unsafe { &NGX_HTTP_CURL_COMMANDS[0] as *const _ as *mut _ },
type_: NGX_HTTP_MODULE as ngx_uint_t,

init_master: None,
Expand Down
9 changes: 5 additions & 4 deletions examples/httporigdst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl NgxHttpOrigDstCtx {
}
}

static ngx_http_orig_dst_module_ctx: ngx_http_module_t = ngx_http_module_t {
static NGX_HTTP_ORIG_DST_MODULE_CTX: ngx_http_module_t = ngx_http_module_t {
preconfiguration: Some(Module::preconfiguration),
postconfiguration: Some(Module::postconfiguration),
create_main_conf: Some(Module::create_main_conf),
Expand All @@ -93,6 +93,7 @@ static ngx_http_orig_dst_module_ctx: ngx_http_module_t = ngx_http_module_t {
ngx::ngx_modules!(ngx_http_orig_dst_module);

#[used]
#[allow(non_upper_case_globals)]
#[cfg_attr(not(feature = "export-modules"), no_mangle)]
pub static mut ngx_http_orig_dst_module: ngx_module_t = ngx_module_t {
ctx_index: ngx_uint_t::MAX,
Expand All @@ -102,7 +103,7 @@ pub static mut ngx_http_orig_dst_module: ngx_module_t = ngx_module_t {
spare1: 0,
version: nginx_version as ngx_uint_t,
signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char,
ctx: &ngx_http_orig_dst_module_ctx as *const _ as *mut _,
ctx: &NGX_HTTP_ORIG_DST_MODULE_CTX as *const _ as *mut _,
commands: std::ptr::null_mut(),
type_: NGX_HTTP_MODULE as ngx_uint_t,

Expand All @@ -124,7 +125,7 @@ pub static mut ngx_http_orig_dst_module: ngx_module_t = ngx_module_t {
spare_hook7: 0,
};

static mut ngx_http_orig_dst_vars: [ngx_http_variable_t; 3] = [
static mut NGX_HTTP_ORIG_DST_VARS: [ngx_http_variable_t; 3] = [
// ngx_str_t name
// ngx_http_set_variable_pt set_handler
// ngx_http_get_variable_pt get_handler
Expand Down Expand Up @@ -297,7 +298,7 @@ impl HTTPModule for Module {

// static ngx_int_t ngx_http_orig_dst_add_variables(ngx_conf_t *cf)
unsafe extern "C" fn preconfiguration(cf: *mut ngx_conf_t) -> ngx_int_t {
for mut v in ngx_http_orig_dst_vars {
for mut v in NGX_HTTP_ORIG_DST_VARS {
if v.name.len == 0 {
break;
}
Expand Down
9 changes: 5 additions & 4 deletions examples/upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Default for UpstreamPeerData {
}
}

static ngx_http_upstream_custom_ctx: ngx_http_module_t = ngx_http_module_t {
static NGX_HTTP_UPSTREAM_CUSTOM_CTX: ngx_http_module_t = ngx_http_module_t {
preconfiguration: Some(Module::preconfiguration),
postconfiguration: Some(Module::postconfiguration),
create_main_conf: Some(Module::create_main_conf),
Expand All @@ -87,7 +87,7 @@ static ngx_http_upstream_custom_ctx: ngx_http_module_t = ngx_http_module_t {
merge_loc_conf: Some(Module::merge_loc_conf),
};

static mut ngx_http_upstream_custom_commands: [ngx_command_t; 2] = [
static mut NGX_HTTP_UPSTREAM_CUSTOM_COMMANDS: [ngx_command_t; 2] = [
ngx_command_t {
name: ngx_string!("custom"),
type_: (NGX_HTTP_UPS_CONF | NGX_CONF_NOARGS | NGX_CONF_TAKE1) as ngx_uint_t,
Expand All @@ -105,6 +105,7 @@ static mut ngx_http_upstream_custom_commands: [ngx_command_t; 2] = [
ngx::ngx_modules!(ngx_http_upstream_custom_module);

#[used]
#[allow(non_upper_case_globals)]
#[cfg_attr(not(feature = "export-modules"), no_mangle)]
pub static mut ngx_http_upstream_custom_module: ngx_module_t = ngx_module_t {
ctx_index: ngx_uint_t::MAX,
Expand All @@ -115,8 +116,8 @@ pub static mut ngx_http_upstream_custom_module: ngx_module_t = ngx_module_t {
version: nginx_version as ngx_uint_t,
signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const c_char,

ctx: &ngx_http_upstream_custom_ctx as *const _ as *mut _,
commands: unsafe { &ngx_http_upstream_custom_commands[0] as *const _ as *mut _ },
ctx: &NGX_HTTP_UPSTREAM_CUSTOM_CTX as *const _ as *mut _,
commands: unsafe { &NGX_HTTP_UPSTREAM_CUSTOM_COMMANDS[0] as *const _ as *mut _ },
type_: NGX_HTTP_MODULE as ngx_uint_t,

init_master: None,
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,21 @@ pub mod log;
macro_rules! ngx_modules {
($( $mod:ident ),+) => {
#[no_mangle]
#[allow(non_upper_case_globals)]
pub static mut ngx_modules: [*const $crate::ffi::ngx_module_t; $crate::count!($( $mod, )+) + 1] = [
$( unsafe { &$mod } as *const $crate::ffi::ngx_module_t, )+
::std::ptr::null()
];

#[no_mangle]
#[allow(non_upper_case_globals)]
pub static mut ngx_module_names: [*const ::std::ffi::c_char; $crate::count!($( $mod, )+) + 1] = [
$( concat!(stringify!($mod), "\0").as_ptr() as *const ::std::ffi::c_char, )+
::std::ptr::null()
];

#[no_mangle]
#[allow(non_upper_case_globals)]
pub static mut ngx_module_order: [*const ::std::ffi::c_char; 1] = [
::std::ptr::null()
];
Expand Down

0 comments on commit f3b36f3

Please sign in to comment.