Bläddra i källkod

Make tcp_connect() void; it will eventually have no failure case.

tags/v0.9.3
Michael Brown 18 år sedan
förälder
incheckning
7af478b30d
4 ändrade filer med 7 tillägg och 17 borttagningar
  1. 1
    1
      src/include/gpxe/hello.h
  2. 1
    1
      src/include/gpxe/tcp.h
  3. 4
    13
      src/net/tcp.c
  4. 1
    2
      src/proto/iscsi.c

+ 1
- 1
src/include/gpxe/hello.h Visa fil

@@ -41,6 +41,6 @@ struct hello_request {
41 41
 	int complete;
42 42
 };
43 43
 
44
-extern int hello_connect ( struct hello_request *hello );
44
+extern void hello_connect ( struct hello_request *hello );
45 45
 
46 46
 #endif

+ 1
- 1
src/include/gpxe/tcp.h Visa fil

@@ -94,7 +94,7 @@ struct tcp_connection {
94 94
 
95 95
 extern void *tcp_buffer;
96 96
 extern size_t tcp_buflen;
97
-extern int tcp_connect ( struct tcp_connection *conn );
97
+extern void tcp_connect ( struct tcp_connection *conn );
98 98
 extern void tcp_send ( struct tcp_connection *conn, const void *data,
99 99
 		       size_t len );
100 100
 extern void tcp_close ( struct tcp_connection *conn );

+ 4
- 13
src/net/tcp.c Visa fil

@@ -64,18 +64,11 @@ size_t tcp_buflen = UIP_BUFSIZE - ( 40 + UIP_LLH_LEN );
64 64
  * Open a TCP connection
65 65
  *
66 66
  * @v conn	TCP connection
67
- * @ret 0	Success
68
- * @ret <0	Failure
69 67
  * 
70 68
  * This sets up a new TCP connection to the remote host specified in
71
- * tcp_connection::sin.  The actual SYN packet will not be sent out
72
- * until run_tcpip() is called for the first time.
73
- *
74
- * @todo Use linked lists instead of a static buffer, and thereby
75
- *       remove the only potential failure case, giving this function
76
- *       a void return type.
69
+ * tcp_connection::sin.
77 70
  */
78
-int tcp_connect ( struct tcp_connection *conn ) {
71
+void tcp_connect ( struct tcp_connection *conn ) {
79 72
 	struct uip_conn *uip_conn;
80 73
 	u16_t ipaddr[2];
81 74
 
@@ -86,11 +79,9 @@ int tcp_connect ( struct tcp_connection *conn ) {
86 79
 
87 80
 	* ( ( uint32_t * ) ipaddr ) = conn->sin.sin_addr.s_addr;
88 81
 	uip_conn = uip_connect ( ipaddr, conn->sin.sin_port );
89
-	if ( ! uip_conn )
90
-		return -1;
91
-
82
+#warning "Use linked lists so that uip_connect() cannot fail"
83
+	assert ( uip_conn != NULL );
92 84
 	*( ( void ** ) uip_conn->appstate ) = conn;
93
-	return 0;
94 85
 }
95 86
 
96 87
 /**

+ 1
- 2
src/proto/iscsi.c Visa fil

@@ -544,8 +544,7 @@ void iscsi_wakeup ( struct iscsi_session *iscsi ) {
544 544
 	switch ( iscsi->state ) {
545 545
 	case ISCSI_STATE_NOT_CONNECTED:
546 546
 	case ISCSI_STATE_FAILED:
547
-		if ( tcp_connect ( &iscsi->tcp ) != 0 )
548
-			iscsi_fail ( iscsi );
547
+		tcp_connect ( &iscsi->tcp );
549 548
 		iscsi_start_login ( iscsi );
550 549
 		break;
551 550
 	case ISCSI_STATE_IDLE:

Laddar…
Avbryt
Spara