Correct the use of pthread_create() in several places.
authorAndrej Kacian <ticho@claws-mail.org>
Fri, 7 Jul 2017 10:49:22 +0000 (12:49 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Fri, 7 Jul 2017 10:49:22 +0000 (12:49 +0200)
The second argument should be a pointer to pthread_attr_t,
not a numeric constant. Joinable detachstate is also the
default, we don't need to explicitly set it. Lastly, use
"NULL" for null pthread_attr_t pointer, not "0" (this is
just a cosmetic/consistency thing, but still).

src/common/ssl.c
src/gtk/w32_filesel.c
src/matcher.c
src/plugins/bogofilter/bogofilter.c
src/plugins/bsfilter/bsfilter.c
src/plugins/libravatar/libravatar_image.c
src/plugins/pgpcore/pgp_viewer.c
src/plugins/pgpcore/sgpgme.c
src/plugins/rssyl/parse822.c
src/plugins/rssyl/rssyl_update_feed.c
src/plugins/vcalendar/vcal_folder.c

index 7a34391..a143820 100644 (file)
@@ -292,7 +292,6 @@ static gint SSL_connect_nb(gnutls_session_t ssl)
 #ifdef USE_PTHREAD
        thread_data *td = g_new0(thread_data, 1);
        pthread_t pt;
-       pthread_attr_t pta;
        void *res = NULL;
        time_t start_time = time(NULL);
        gboolean killed = FALSE;
@@ -303,9 +302,7 @@ static gint SSL_connect_nb(gnutls_session_t ssl)
        /* try to create a thread to initialize the SSL connection,
         * fallback to blocking method in case of problem 
         */
-       if (pthread_attr_init(&pta) != 0 ||
-           pthread_attr_setdetachstate(&pta, PTHREAD_CREATE_JOINABLE) != 0 ||
-           pthread_create(&pt, &pta, SSL_connect_thread, td) != 0) {
+       if (pthread_create(&pt, NULL, SSL_connect_thread, td) != 0) {
                do {
                        result = gnutls_handshake(td->ssl);
                } while (result == GNUTLS_E_AGAIN || result == GNUTLS_E_INTERRUPTED);
index f0db011..1aa6902 100644 (file)
@@ -186,7 +186,7 @@ static const gboolean _file_open_dialog(const gchar *path, const gchar *title,
        ctx->done = FALSE;
 
 #ifdef USE_PTHREAD
-       if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE, threaded_GetOpenFileName,
+       if (pthread_create(&pt, NULL, threaded_GetOpenFileName,
                                (void *)ctx) != 0) {
                debug_print("Couldn't run in a thread, continuing unthreaded.\n");
                threaded_GetOpenFileName(ctx);
@@ -393,7 +393,7 @@ gchar *filesel_select_file_save(const gchar *title, const gchar *path)
        ctx->done = FALSE;
 
 #ifdef USE_PTHREAD
-       if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE, threaded_GetSaveFileName,
+       if (pthread_create(&pt, NULL, threaded_GetSaveFileName,
                                (void *)ctx) != 0) {
                debug_print("Couldn't run in a thread, continuing unthreaded.\n");
                threaded_GetSaveFileName(ctx);
@@ -495,7 +495,7 @@ gchar *filesel_select_file_open_folder(const gchar *title, const gchar *path)
        ctx->done = FALSE;
 
 #ifdef USE_PTHREAD
-       if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE, threaded_SHBrowseForFolder,
+       if (pthread_create(&pt, NULL, threaded_SHBrowseForFolder,
                                (void *)ctx) != 0) {
                debug_print("Couldn't run in a thread, continuing unthreaded.\n");
                threaded_SHBrowseForFolder(ctx);
index 2756677..40ed4ca 100644 (file)
@@ -691,7 +691,6 @@ static gboolean matcherprop_match_test(const MatcherProp *prop,
        gint retval;
 #ifdef USE_PTHREAD
        pthread_t pt;
-       pthread_attr_t pta;
        thread_data *td = g_new0(thread_data, 1);
        void *res = NULL;
        time_t start_time = time(NULL);
@@ -725,9 +724,7 @@ static gboolean matcherprop_match_test(const MatcherProp *prop,
 
        td->cmd = cmd;
        td->done = FALSE;
-       if (pthread_attr_init(&pta) != 0 ||
-           pthread_attr_setdetachstate(&pta, PTHREAD_CREATE_JOINABLE) != 0 ||
-           pthread_create(&pt, &pta, matcher_test_thread, td) != 0)
+       if (pthread_create(&pt, NULL, matcher_test_thread, td) != 0)
                retval = system(cmd);
        else {
                debug_print("waiting for test thread\n");
index 75940df..07a764b 100644 (file)
@@ -390,7 +390,7 @@ static void bogofilter_start_thread(void)
        filter_th_done = FALSE;
        if (filter_th != 0 || 1)
                return;
-       if (pthread_create(&filter_th, 0, 
+       if (pthread_create(&filter_th, NULL,
                        bogofilter_filtering_thread, 
                        NULL) != 0) {
                filter_th = 0;
index 07c55a2..127e677 100644 (file)
@@ -215,7 +215,7 @@ static void bsfilter_start_thread(void)
        filter_th_done = FALSE;
        if (filter_th_started != 0)
                return;
-       if (pthread_create(&filter_th, 0
+       if (pthread_create(&filter_th, NULL
                        bsfilter_filtering_thread, 
                        NULL) != 0) {
                filter_th_started = 0;
index 30c9e37..02c7e4b 100644 (file)
@@ -145,7 +145,7 @@ GdkPixbuf *libravatar_image_fetch(AvatarImageFetch *ctx)
        g_return_val_if_fail(ctx != NULL, NULL);
 
 #ifdef USE_PTHREAD
-       if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE, get_image_thread, (void *)ctx) != 0) {
+       if (pthread_create(&pt, NULL, get_image_thread, (void *)ctx) != 0) {
                debug_print("synchronous image fetching (couldn't create thread)\n");
                get_image_thread(ctx);
        } else {
index 0142760..99b6206 100644 (file)
@@ -245,7 +245,7 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
                        ctx->exitcode = STILL_ACTIVE;
                        ctx->cmd = cmd;
 
-                       if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE,
+                       if (pthread_create(&pt, NULL,
                                                _import_threaded, (void *)ctx) != 0) {
                                debug_print("Couldn't create thread, continuing unthreaded.\n");
                                _import_threaded(ctx);
index db9b354..2290526 100644 (file)
@@ -1049,7 +1049,7 @@ again:
                        ectx->exitcode = STILL_ACTIVE;
                        ectx->cmd = cmd;
 
-                       if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE,
+                       if (pthread_create(&pt, NULL,
                                                _export_threaded, (void *)ectx) != 0) {
                                debug_print("Couldn't create thread, continuing unthreaded.\n");
                                _export_threaded(ctx);
index 2197542..e45c9c9 100644 (file)
@@ -334,7 +334,7 @@ void rssyl_folder_read_existing(RFolderItem *ritem)
        ctx->ritem = ritem;
        ctx->ready = FALSE;
 
-       if( pthread_create(&pt, PTHREAD_CREATE_JOINABLE, rssyl_read_existing_thr,
+       if( pthread_create(&pt, NULL, rssyl_read_existing_thr,
                                (void *)ctx) != 0 ) {
                /* Couldn't create thread, let's continue non-threaded. */
                rssyl_folder_read_existing_real(ritem);
index e74045c..6ecfeb3 100644 (file)
@@ -70,7 +70,7 @@ void rssyl_fetch_feed(RFetchCtx *ctx, RSSylVerboseFlags verbose)
        g_return_if_fail(ctx != NULL);
 
 #ifdef USE_PTHREAD
-       if( pthread_create(&pt, PTHREAD_CREATE_JOINABLE, rssyl_fetch_feed_thr,
+       if( pthread_create(&pt, NULL, rssyl_fetch_feed_thr,
                                (void *)ctx) != 0 ) {
                /* Bummer, couldn't create thread. Continue non-threaded. */
                rssyl_fetch_feed_thr(ctx);
index 97e7ded..985534c 100644 (file)
@@ -1647,7 +1647,6 @@ gchar *vcal_curl_read(const char *url, const gchar *label, gboolean verbose,
        thread_data *td;
 #ifdef USE_PTHREAD
        pthread_t pt;
-       pthread_attr_t pta;
 #endif
        void *res;
        gchar *error = NULL;
@@ -1662,10 +1661,7 @@ gchar *vcal_curl_read(const char *url, const gchar *label, gboolean verbose,
        STATUSBAR_PUSH(mainwindow_get_mainwindow(), label);
 
 #ifdef USE_PTHREAD
-       if (pthread_attr_init(&pta) != 0 ||
-           pthread_attr_setdetachstate(&pta, PTHREAD_CREATE_JOINABLE) != 0 ||
-           pthread_create(&pt, &pta, 
-                       url_read_thread, td) != 0) {
+       if (pthread_create(&pt, NULL, url_read_thread, td) != 0) {
                url_read_thread(td);    
        }
        while (!td->done)  {