]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
select_tut.2: Clean up error checking in example program (no semantic changes)
authorMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 24 Jan 2009 22:34:23 +0000 (23:34 +0100)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 24 Jan 2009 22:34:23 +0000 (23:34 +0100)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man2/select_tut.2

index 596983d3dc3ba4afc07c2e2e81b7d92c88cded53..b51fcbdf39d4ebeec8c0ba10ae9923f6450e471a 100644 (file)
@@ -584,13 +584,13 @@ listen_socket(int listen_port)
     int s;
     int yes;
 
-    if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+    if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) {
         perror("socket");
         return \-1;
     }
     yes = 1;
     if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
-            (char *) &yes, sizeof(yes)) < 0) {
+            (char *) &yes, sizeof(yes)) == \-1) {
         perror("setsockopt");
         close(s);
         return \-1;
@@ -598,7 +598,7 @@ listen_socket(int listen_port)
     memset(&a, 0, sizeof(a));
     a.sin_port = htons(listen_port);
     a.sin_family = AF_INET;
-    if (bind(s, (struct sockaddr *) &a, sizeof(a)) < 0) {
+    if (bind(s, (struct sockaddr *) &a, sizeof(a)) == \-1) {
         perror("bind");
         close(s);
         return \-1;
@@ -614,7 +614,7 @@ connect_socket(int connect_port, char *address)
     struct sockaddr_in a;
     int s;
 
-    if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+    if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) {
         perror("socket");
         close(s);
         return \-1;
@@ -630,7 +630,7 @@ connect_socket(int connect_port, char *address)
         return \-1;
     }
 
-    if (connect(s, (struct sockaddr *) &a, sizeof(a)) < 0) {
+    if (connect(s, (struct sockaddr *) &a, sizeof(a)) == \-1) {
         perror("connect()");
         shutdown(s, SHUT_RDWR);
         close(s);
@@ -677,7 +677,7 @@ main(int argc, char **argv)
     forward_port = atoi(argv[2]);
 
     h = listen_socket(atoi(argv[1]));
-    if (h < 0)
+    if (h == \-1)
         exit(EXIT_FAILURE);
 
     for (;;) {
@@ -719,7 +719,7 @@ main(int argc, char **argv)
 
         if (r == \-1 && errno == EINTR)
             continue;
-        if (r < 0) {
+        if (r == \-1) {
             perror("select()");
             exit(EXIT_FAILURE);
         }
@@ -729,7 +729,7 @@ main(int argc, char **argv)
 
             memset(&client_address, 0, l = sizeof(client_address));
             r = accept(h, (struct sockaddr *) &client_address, &l);
-            if (r < 0) {
+            if (r == \-1) {
                 perror("accept()");
             } else {
                 SHUT_FD1;
@@ -738,7 +738,7 @@ main(int argc, char **argv)
                 buf2_avail = buf2_written = 0;
                 fd1 = r;
                 fd2 = connect_socket(forward_port, argv[3]);
-                if (fd2 < 0)
+                if (fd2 == \-1)
                     SHUT_FD1;
                 else
                     printf("connect from %s\\n",