Always cleanup winsock
authorJoseph C. Lehner <joseph.c.lehner@gmail.com>
Mon, 8 Feb 2016 13:06:04 +0000 (14:06 +0100)
committerJoseph C. Lehner <joseph.c.lehner@gmail.com>
Mon, 8 Feb 2016 13:06:04 +0000 (14:06 +0100)
main.c

diff --git a/main.c b/main.c
index 1ee2986f09cef1c2c92dd74adffd0eee6f3473b8..b8963e9e3ca0a65c7aaf5ad3a1a0b699301ef1b6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -132,25 +132,30 @@ int main(int argc, char **argv)
                                break;
                        case 'V':
                                printf("nmrp-flash v%s\n", NMRPD_VERSION);
-                               return 0;
+                               val = 0;
+                               goto out;
                        case 'v':
                                ++verbosity;
                                break;
                        case 'L':
-                               return ethsock_list_all();
+                               val = ethsock_list_all();
+                               goto out;
                        case 'h':
                                usage(stdout);
-                               return 0;
+                               val = 0;
+                               goto out;
 #ifdef NMRPFLASH_TFTP_TEST
                        case 'U':
                                if (args.ipaddr && args.filename) {
-                                       return tftp_put(&args);
+                                       val = tftp_put(&args);
+                                       goto out;
                                }
                                /* fall through */
 #endif
                        default:
                                usage(stderr);
-                               return 1;
+                               val = 1;
+                               goto out;
                }
        }
 
@@ -167,6 +172,8 @@ int main(int argc, char **argv)
 #endif
 
        val = nmrp_do(&args);
+
+out:
 #ifdef NMRPFLASH_WINDOWS
        WSACleanup();
 #endif