Browse Source

fix: format check

Samuka007 5 months ago
parent
commit
6c812d2607

+ 1 - 1
kernel/src/arch/x86_64/syscall/mod.rs

@@ -148,4 +148,4 @@ pub(super) unsafe fn init_syscall_64() {
     // 初始化LSTAR,该寄存器存储syscall指令入口
     x86::msr::wrmsr(x86::msr::IA32_LSTAR, syscall_64 as usize as u64);
     x86::msr::wrmsr(x86::msr::IA32_FMASK, 0xfffffffe);
-}
+}

+ 1 - 1
kernel/src/arch/x86_64/syscall/nr.rs

@@ -354,4 +354,4 @@ pub const SYS_VSERVER: usize = 236;
 pub const SYS_WAIT4: usize = 61;
 pub const SYS_WAITID: usize = 247;
 pub const SYS_WRITE: usize = 1;
-pub const SYS_WRITEV: usize = 20;
+pub const SYS_WRITEV: usize = 20;

+ 2 - 12
kernel/src/net/socket/base.rs

@@ -58,12 +58,7 @@ pub trait Socket: Sync + Send + Debug + Any {
     }
     /// # `get_option`
     /// 对应于 Posix `getsockopt` ,获取socket选项
-    fn get_option(
-        &self,
-        level: PSOL,
-        name: usize,
-        value: &mut [u8],
-    ) -> Result<usize, SystemError> {
+    fn get_option(&self, level: PSOL, name: usize, value: &mut [u8]) -> Result<usize, SystemError> {
         log::warn!("getsockopt is not implemented");
         Ok(0)
     }
@@ -106,12 +101,7 @@ pub trait Socket: Sync + Send + Debug + Any {
         Err(ENOSYS)
     }
     /// # `send_to`
-    fn send_to(
-        &self,
-        buffer: &[u8],
-        flags: PMSG,
-        address: Endpoint,
-    ) -> Result<usize, SystemError> {
+    fn send_to(&self, buffer: &[u8], flags: PMSG, address: Endpoint) -> Result<usize, SystemError> {
         Err(ENOSYS)
     }
     /// # `set_option`

+ 1 - 6
kernel/src/net/socket/inet/datagram/mod.rs

@@ -215,12 +215,7 @@ impl Socket for UdpSocket {
         return self.try_send(buffer, None);
     }
 
-    fn send_to(
-        &self,
-        buffer: &[u8],
-        flags: PMSG,
-        address: Endpoint,
-    ) -> Result<usize, SystemError> {
+    fn send_to(&self, buffer: &[u8], flags: PMSG, address: Endpoint) -> Result<usize, SystemError> {
         if flags.contains(PMSG::DONTWAIT) {
             log::warn!("Nonblock send is not implemented yet");
         }

+ 6 - 4
kernel/src/net/socket/inet/stream/mod.rs

@@ -303,8 +303,10 @@ impl Socket for TcpSocket {
     }
 
     fn close(&self) -> Result<(), SystemError> {
-        self.inner.read().as_ref().map(
-            |inner| match inner {
+        self.inner
+            .read()
+            .as_ref()
+            .map(|inner| match inner {
                 Inner::Connecting(_) => Err(EINPROGRESS),
                 Inner::Established(es) => {
                     es.close();
@@ -312,8 +314,8 @@ impl Socket for TcpSocket {
                     Ok(())
                 }
                 _ => Ok(()),
-            }
-        ).unwrap_or(Ok(()))
+            })
+            .unwrap_or(Ok(()))
     }
 }
 

+ 1 - 6
kernel/src/net/socket/inode.rs

@@ -99,12 +99,7 @@ impl Inode {
         self.inner.bind(endpoint)
     }
 
-    pub fn set_option(
-        &self,
-        level: PSOL,
-        name: usize,
-        value: &[u8],
-    ) -> Result<(), SystemError> {
+    pub fn set_option(&self, level: PSOL, name: usize, value: &[u8]) -> Result<(), SystemError> {
         self.inner.set_option(level, name, value)
     }
 

+ 2 - 2
kernel/src/net/socket/mod.rs

@@ -1,11 +1,11 @@
 mod base;
 mod buffer;
 mod common;
-mod posix;
 mod endpoint;
 mod family;
 pub mod inet;
 mod inode;
+mod posix;
 pub mod unix;
 mod utils;
 
@@ -17,10 +17,10 @@ pub use common::{
     // poll_unit::{EPollItems, WaitQueue},
     EPollItems,
 };
-pub use posix::*;
 pub use endpoint::*;
 pub use family::{AddressFamily, Family};
 pub use inode::Inode;
+pub use posix::*;
 pub use utils::create_socket;
 
 pub use crate::net::event_poll::EPollEventType;

+ 1 - 1
kernel/src/net/socket/posix/mod.rs

@@ -1,5 +1,5 @@
 // posix socket and arguments definitions
-// now all posix definitions are with P front like MSG -> PMSG, 
+// now all posix definitions are with P front like MSG -> PMSG,
 // for better understanding and avoiding conflicts with other definitions
 mod msg_flag;
 mod option;

+ 1 - 5
kernel/src/net/socket/unix/seqpacket/mod.rs

@@ -349,11 +349,7 @@ impl Socket for SeqpacketSocket {
         Err(SystemError::ENOSYS)
     }
 
-    fn send(
-        &self,
-        buffer: &[u8],
-        flags: crate::net::socket::PMSG,
-    ) -> Result<usize, SystemError> {
+    fn send(&self, buffer: &[u8], flags: crate::net::socket::PMSG) -> Result<usize, SystemError> {
         if flags.contains(PMSG::OOB) {
             return Err(SystemError::EOPNOTSUPP_OR_ENOTSUP);
         }

+ 1 - 6
kernel/src/net/socket/unix/stream/mod.rs

@@ -241,12 +241,7 @@ impl Socket for StreamSocket {
         }
     }
 
-    fn set_option(
-        &self,
-        _level: PSOL,
-        _optname: usize,
-        _optval: &[u8],
-    ) -> Result<(), SystemError> {
+    fn set_option(&self, _level: PSOL, _optname: usize, _optval: &[u8]) -> Result<(), SystemError> {
         log::warn!("setsockopt is not implemented");
         Ok(())
     }

+ 1 - 1
kernel/src/net/syscall.rs

@@ -142,7 +142,7 @@ impl Syscall {
             .get_socket(fd as i32)
             .ok_or(EBADF)?;
 
-        use socket::{PSOL, PSO};
+        use socket::{PSO, PSOL};
 
         let level = PSOL::try_from(level as u32)?;