talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 99f705739502ca022401a95b776855eff551ce94
parent 1cad06a23cfcb44164e481ad998f33b74c244a95
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Fri,  7 Jul 2017 12:49:22 +0200

Correct the use of pthread_create() in several places.

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).

Diffstat:
Msrc/common/ssl.c | 5+----
Msrc/gtk/w32_filesel.c | 6+++---
Msrc/matcher.c | 5+----
Msrc/plugins/bogofilter/bogofilter.c | 2+-
Msrc/plugins/bsfilter/bsfilter.c | 2+-
Msrc/plugins/libravatar/libravatar_image.c | 2+-
Msrc/plugins/pgpcore/pgp_viewer.c | 2+-
Msrc/plugins/pgpcore/sgpgme.c | 2+-
Msrc/plugins/rssyl/parse822.c | 2+-
Msrc/plugins/rssyl/rssyl_update_feed.c | 2+-
Msrc/plugins/vcalendar/vcal_folder.c | 6+-----
11 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/src/common/ssl.c b/src/common/ssl.c @@ -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); diff --git a/src/gtk/w32_filesel.c b/src/gtk/w32_filesel.c @@ -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); diff --git a/src/matcher.c b/src/matcher.c @@ -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"); diff --git a/src/plugins/bogofilter/bogofilter.c b/src/plugins/bogofilter/bogofilter.c @@ -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; diff --git a/src/plugins/bsfilter/bsfilter.c b/src/plugins/bsfilter/bsfilter.c @@ -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; diff --git a/src/plugins/libravatar/libravatar_image.c b/src/plugins/libravatar/libravatar_image.c @@ -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 { diff --git a/src/plugins/pgpcore/pgp_viewer.c b/src/plugins/pgpcore/pgp_viewer.c @@ -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); diff --git a/src/plugins/pgpcore/sgpgme.c b/src/plugins/pgpcore/sgpgme.c @@ -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); diff --git a/src/plugins/rssyl/parse822.c b/src/plugins/rssyl/parse822.c @@ -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); diff --git a/src/plugins/rssyl/rssyl_update_feed.c b/src/plugins/rssyl/rssyl_update_feed.c @@ -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); diff --git a/src/plugins/vcalendar/vcal_folder.c b/src/plugins/vcalendar/vcal_folder.c @@ -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) {