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 7a34391f0f7588bc4931cee42ff6987b530cdd89..a1438207be20e577fa6e354cb4dd288e187575ee 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 f0db011926b5f892eb2d46b16e5915e2f0658e6b..1aa690265c98aab933d3e80dec89483958f0789a 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 27566774c8090790dcfca8dfbf4fc7ec32a1eeb7..40ed4ca5c7996c7d0616b6ce5af1993f01f144b3 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 75940df165a960ca3e72aa6f6c352a9c7dd60e6c..07a764b370d4b58670b9fc04416ca40e5b850b29 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 07c55a22b98eab0b0dc633f2b5ffe66166526aa6..127e677cc79bc78f3a195122826a48128fd37b1c 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 30c9e374c8e1e46049d174f9437ccd5ce411ee12..02c7e4b342f53c87287c1e659b315c85d8b4d674 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 01427609d9c6c4f97695ef72f404f09d8491a0ef..99b6206cc59d6ea4ff731062cb252b6a8398f805 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 db9b354aaf3d1f95452080fef1fd0ce681cafd2c..2290526a7541e5cd4b0faf03eaa8b39a7a09a0df 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 21975428fb2f894a889cc9271a38adf3f1f6b5b1..e45c9c9476e003a2ecde6cf8da636c24395a612f 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 e74045c99e650ae970cf246b9d1709b2f90b1f0e..6ecfeb37377440bf3ab1c195a08de8a8ff9ff556 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 97e7ded8de2b6d545a14a8a4362ce9ba04d0e4ec..985534c251c87dc1db7f67811aa6ae0829e9003a 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)  {