Skip to content

Commit 074d507

Browse files
authored
Remove None-safety from various net functions (#1912)
Signed-off-by: John Gardiner Myers <[email protected]>
1 parent 0f56740 commit 074d507

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

kclvm/runtime/src/net/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ pub extern "C-unwind" fn kclvm_net_split_host_port(
2222
let ctx = mut_ptr_as_ref(ctx);
2323

2424
if let Some(ip_end_point) = get_call_arg(args, kwargs, 0, Some("ip_end_point")) {
25-
if ip_end_point.is_none() {
26-
return ValueRef::none().into_raw(ctx);
27-
}
2825
let ip_end_point_str = ip_end_point.as_str();
2926
match ip_end_point_str.rsplit_once(':') {
3027
None => panic!(
@@ -113,9 +110,6 @@ pub extern "C-unwind" fn kclvm_net_join_host_port(
113110

114111
if let Some(host) = get_call_arg(args, kwargs, 0, Some("host")) {
115112
if let Some(port) = get_call_arg(args, kwargs, 1, Some("port")) {
116-
if host.is_none() || port.is_none() {
117-
return ValueRef::none().into_raw(ctx);
118-
}
119113
if host.as_str().contains(':') {
120114
return ValueRef::str(format!("[{host}]:{port}").as_ref()).into_raw(ctx);
121115
}
@@ -477,9 +471,6 @@ pub extern "C-unwind" fn kclvm_net_parse_CIDR(
477471
let ctx = mut_ptr_as_ref(ctx);
478472

479473
if let Some(cidr) = get_call_arg(args, kwargs, 0, Some("cidr")) {
480-
if cidr.is_none() {
481-
return ValueRef::none().into_raw(ctx);
482-
}
483474
if let Ok(cidr) = IpCidr::from_str(&cidr.as_str()) {
484475
let ip = ValueRef::str(&cidr.first_address().to_string());
485476
let mask = ValueRef::int(cidr.network_length().into());
@@ -676,7 +667,6 @@ mod test_net {
676667
#[test]
677668
fn test_split_host_port() {
678669
let cases = [
679-
(ValueRef::none(), ValueRef::none()),
680670
(
681671
ValueRef::str("invalid.invalid:21"),
682672
ValueRef::list(Some(&[
@@ -789,14 +779,6 @@ mod test_net {
789779
#[test]
790780
fn test_join_host_port() {
791781
let cases = [
792-
(ValueRef::none(), ValueRef::none(), ValueRef::none()),
793-
(ValueRef::none(), ValueRef::int(21), ValueRef::none()),
794-
(ValueRef::none(), ValueRef::str("21"), ValueRef::none()),
795-
(
796-
ValueRef::str("invalid.invalid"),
797-
ValueRef::none(),
798-
ValueRef::none(),
799-
),
800782
(
801783
ValueRef::str("invalid.invalid"),
802784
ValueRef::int(21),
@@ -900,7 +882,6 @@ mod test_net {
900882
#[allow(non_snake_case)]
901883
fn test_parse_CIDR() {
902884
let cases = [
903-
(ValueRef::none(), ValueRef::none()),
904885
(
905886
ValueRef::str("0.0.0.0/0"),
906887
ValueRef::dict(Some(&[

0 commit comments

Comments
 (0)