sbin/hammer2: Don't assume pthread_t is a pointer
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 31 Aug 2019 12:47:45 +0000 (21:47 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 31 Aug 2019 14:25:18 +0000 (23:25 +0900)
NULL initialization isn't necessary.
Also having assumption on actual type breaks portability.

sbin/hammer2/cmd_service.c
sbin/hammer2/subs.c

index f05869c..5642edb 100644 (file)
@@ -227,7 +227,6 @@ service_thread(void *data)
         * Start up a thread to handle block device monitoring for
         * export to the cluster.
         */
-       thread = NULL;
        pthread_create(&thread, NULL, udev_thread, NULL);
 
        /*
@@ -239,7 +238,6 @@ service_thread(void *data)
        /*
         * Start thread to manage /etc/hammer2/autoconn
         */
-       thread = NULL;
        pthread_create(&thread, NULL, autoconn_thread, NULL);
 
        /*
@@ -266,7 +264,6 @@ service_thread(void *data)
                }
                opt = 1;
                setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof opt);
-               thread = NULL;
                fprintf(stderr, "service_thread: accept fd %d\n", fd);
                info = malloc(sizeof(*info));
                bzero(info, sizeof(*info));
@@ -478,7 +475,6 @@ hammer2_volconf_stop(hammer2_media_config_t *conf)
                close(conf->pipefd[1]);
                conf->pipefd[1] = -1;
                pthread_join(conf->iocom_thread, NULL);
-               conf->iocom_thread = NULL;
                conf->state = H2MC_STOPPED;
                break;
        }
@@ -654,7 +650,6 @@ autoconn_thread(void *data __unused)
                                if (pipe(ac->pipefd) == 0) {
                                        ac->stopme = 0;
                                        ac->state = AUTOCONN_ACTIVE;
-                                       thread = NULL;
                                        pthread_create(&thread, NULL,
                                                       autoconn_connect_thread,
                                                       ac);
index 168f696..8bca0f9 100644 (file)
@@ -70,7 +70,7 @@ hammer2_ioctl_handle(const char *sel_path)
 void
 hammer2_demon(void *(*func)(void *), void *arg)
 {
-       pthread_t thread = NULL;
+       pthread_t thread;
        pid_t pid;
        int ttyfd;