@@ -74,9 +74,8 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
7474 }
7575
7676 if ( typ != Type :: STREAM ) && ( typ != Type :: DGRAM ) {
77- let cause: String = format ! ( "socket type not supported (type={:?})" , typ) ;
78- error ! ( "socket(): {}" , cause) ;
79- return Err ( Fail :: new ( libc:: ENOTSUP , & cause) ) ;
77+ error ! ( "socket(): socket type not supported (type={:?})" , typ) ;
78+ return Err ( Fail :: new ( libc:: ENOTSUP , "socket type not supported" ) ) ;
8079 }
8180
8281 let queue: SharedNetworkQueue < T > = SharedNetworkQueue :: new ( domain, typ, & mut self . transport ) ?;
@@ -109,24 +108,22 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
109108 // We only support the wildcard address for UDP sockets.
110109 // FIXME: https://github.com/demikernel/demikernel/issues/189
111110 if * socket_addrv4. ip ( ) == Ipv4Addr :: UNSPECIFIED && self . get_shared_queue ( & qd) ?. qtype ( ) != QType :: UdpSocket {
112- let cause: String = format ! ( "cannot bind to wildcard address (qd={:?})" , qd) ;
113- error ! ( "bind(): {}" , cause) ;
114- return Err ( Fail :: new ( libc:: ENOTSUP , & cause) ) ;
111+ error ! ( "bind(): cannot bind to wildcard address (qd={:?})" , qd) ;
112+ return Err ( Fail :: new ( libc:: ENOTSUP , "cannot bind to wildcard address" ) ) ;
115113 }
116114
117115 // We only support the wildcard address for UDP sockets.
118116 // FIXME: https://github.com/demikernel/demikernel/issues/582
119117 if socket_addr. port ( ) == 0 && self . get_shared_queue ( & qd) ?. qtype ( ) != QType :: UdpSocket {
120- let cause: String = format ! ( "cannot bind to port 0 (qd={:?})" , qd) ;
121- error ! ( "bind(): {}" , cause) ;
122- return Err ( Fail :: new ( libc:: ENOTSUP , & cause) ) ;
118+ error ! ( "bind(): cannot bind to port 0 (qd={:?})" , qd) ;
119+ return Err ( Fail :: new ( libc:: ENOTSUP , "cannot bind to port 0" ) ) ;
123120 }
124121
125122 if self . runtime . is_addr_in_use ( socket_addrv4) {
126- let cause: String = format ! ( "address is already bound to a socket (qd={:?}" , qd) ;
127- error ! ( "bind(): {}" , & cause) ;
128- return Err ( Fail :: new ( libc:: EADDRINUSE , & cause) ) ;
123+ error ! ( "bind(): address is already bound to a socket (qd={:?}" , qd) ;
124+ return Err ( Fail :: new ( libc:: EADDRINUSE , "address is already bound to a socket" ) ) ;
129125 }
126+
130127 self . get_shared_queue ( & qd) ?. bind ( socket_addr) ?;
131128 // Insert into address to queue descriptor table.
132129 self . runtime
@@ -142,12 +139,10 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
142139
143140 // We use this API for testing, so we must check again.
144141 if !( ( backlog > 0 ) && ( backlog <= SOMAXCONN as usize ) ) {
145- let cause: String = format ! ( "invalid backlog length: {:?}" , backlog) ;
146- warn ! ( "{}" , cause) ;
147- return Err ( Fail :: new ( libc:: EINVAL , & cause) ) ;
142+ warn ! ( "invalid backlog length: {:?}" , backlog) ;
143+ return Err ( Fail :: new ( libc:: EINVAL , "invalid backlog length" ) ) ;
148144 }
149145
150- // Issue listen operation.
151146 self . get_shared_queue ( & qd) ?. listen ( backlog)
152147 }
153148
@@ -303,23 +298,23 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
303298 /// coroutine that asynchronously runs the push and any synchronous multi-queue functionality before the push
304299 /// begins.
305300 pub fn push ( & mut self , qd : QDesc , sga : & demi_sgarray_t ) -> Result < QToken , Fail > {
306- let bufs = clone_sgarray ( sga) ?;
307- if bufs . is_empty ( ) {
308- let cause = "zero-length list of buffers" ;
309- warn ! ( "push(): {}" , cause ) ;
310- return Err ( Fail :: new ( libc:: EINVAL , & cause ) ) ;
301+ let buffers = clone_sgarray ( sga) ?;
302+
303+ if buffers. is_empty ( ) {
304+ warn ! ( "push(): buffers cannot be empty" ) ;
305+ return Err ( Fail :: new ( libc:: EINVAL , "buffers cannot be empty" ) ) ;
311306 }
312- for buf in bufs . iter ( ) {
313- if buf . is_empty ( ) {
314- let cause = "zero-length buffer" ;
315- warn ! ( "push(): {}" , cause ) ;
316- return Err ( Fail :: new ( libc:: EINVAL , & cause ) ) ;
307+
308+ for buffer in buffers . iter ( ) {
309+ if buffer. is_empty ( ) {
310+ warn ! ( "push(): empty buffer" ) ;
311+ return Err ( Fail :: new ( libc:: EINVAL , "empty buffer" ) ) ;
317312 } ;
318313 }
319314
320315 let mut queue: SharedNetworkQueue < T > = self . get_shared_queue ( & qd) ?;
321316 let coroutine_constructor = || -> Result < QToken , Fail > {
322- let coroutine = Box :: pin ( self . clone ( ) . push_coroutine ( qd, bufs , None ) . fuse ( ) ) ;
317+ let coroutine = Box :: pin ( self . clone ( ) . push_coroutine ( qd, buffers , None ) . fuse ( ) ) ;
323318 self . runtime
324319 . clone ( )
325320 . schedule_coroutine ( "ioc::network::libos::push" , coroutine)
@@ -360,14 +355,14 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
360355 pub fn pushto ( & mut self , qd : QDesc , sga : & demi_sgarray_t , remote : SocketAddr ) -> Result < QToken , Fail > {
361356 trace ! ( "pushto() qd={:?}" , qd) ;
362357
363- let bufs : ArrayVec < DemiBuffer , DEMI_SGARRAY_MAXLEN > = clone_sgarray ( sga) ?;
364- if bufs . is_empty ( ) {
365- return Err ( Fail :: new ( libc:: EINVAL , "zero buffers to send " ) ) ;
358+ let buffers : ArrayVec < DemiBuffer , DEMI_SGARRAY_MAXLEN > = clone_sgarray ( sga) ?;
359+ if buffers . is_empty ( ) {
360+ return Err ( Fail :: new ( libc:: EINVAL , "buffers cannot be empty " ) ) ;
366361 }
367362
368363 let mut queue: SharedNetworkQueue < T > = self . get_shared_queue ( & qd) ?;
369364 let coroutine_constructor = || -> Result < QToken , Fail > {
370- let coroutine = Box :: pin ( self . clone ( ) . push_coroutine ( qd, bufs , Some ( remote) ) . fuse ( ) ) ;
365+ let coroutine = Box :: pin ( self . clone ( ) . push_coroutine ( qd, buffers , Some ( remote) ) . fuse ( ) ) ;
371366 self . runtime
372367 . clone ( )
373368 . schedule_coroutine ( "ioc::network::libos::pushto" , coroutine)
0 commit comments