summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2018-11-22 18:51:19 +0200
committerToomas Soome <tsoome@me.com>2020-02-21 17:45:19 +0200
commit48d1bcbbf436904298ce3191590b67834ac47dea (patch)
tree633411f0e428ee7748d2bcf00e4f7b9db1768c1d
parent3b436d06bb95fd180ef7416b2b1b9972e2f2a513 (diff)
downloadillumos-joyent-48d1bcbbf436904298ce3191590b67834ac47dea.tar.gz
11981 libslp: cast between incompatible function types
Reviewed by: Matthias Scheler <mscheler@tintri.com> Reviewed by: Andy Stormont <astormont@racktopsystems.com> Approved by: Robert Mustacchi <rm@fingolfin.org>
-rw-r--r--usr/src/lib/libslp/clib/SLPFindAttrs.c5
-rw-r--r--usr/src/lib/libslp/clib/SLPFindSrvTypes.c6
-rw-r--r--usr/src/lib/libslp/clib/SLPFindSrvs.c5
-rw-r--r--usr/src/lib/libslp/clib/SLPReg.c10
-rw-r--r--usr/src/lib/libslp/clib/SLPUtils.c11
-rw-r--r--usr/src/lib/libslp/clib/slp_da_cache.c23
-rw-r--r--usr/src/lib/libslp/clib/slp_ipc.c15
-rw-r--r--usr/src/lib/libslp/clib/slp_net.c39
-rw-r--r--usr/src/lib/libslp/clib/slp_ua_common.c58
9 files changed, 84 insertions, 88 deletions
diff --git a/usr/src/lib/libslp/clib/SLPFindAttrs.c b/usr/src/lib/libslp/clib/SLPFindAttrs.c
index 799855d8bd..e7f30eced7 100644
--- a/usr/src/lib/libslp/clib/SLPFindAttrs.c
+++ b/usr/src/lib/libslp/clib/SLPFindAttrs.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdlib.h>
#include <syslog.h>
#include <slp-internal.h>
@@ -93,8 +91,7 @@ SLPError SLPFindAttrs(SLPHandle hSLP, const char *pcURL, const char *pcScope,
if (err == SLP_OK)
err = slp_ua_common(hSLP, pcScope,
- (SLPGenericAppCB *) callback, pvUser,
- unpack_cb);
+ (SLPGenericAppCB *)(uintptr_t)callback, pvUser, unpack_cb);
if (err != SLP_OK)
slp_end_call(hSLP);
diff --git a/usr/src/lib/libslp/clib/SLPFindSrvTypes.c b/usr/src/lib/libslp/clib/SLPFindSrvTypes.c
index 2995132b56..b3ff50eb94 100644
--- a/usr/src/lib/libslp/clib/SLPFindSrvTypes.c
+++ b/usr/src/lib/libslp/clib/SLPFindSrvTypes.c
@@ -24,8 +24,6 @@
* All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <syslog.h>
#include <slp-internal.h>
@@ -60,8 +58,8 @@ SLPError SLPFindSrvTypes(SLPHandle hSLP, const char *pcNamingAuthority,
if (err == SLP_OK)
err = slp_ua_common(hSLP, pcScopeList,
- (SLPGenericAppCB *) callback, pvUser,
- (SLPMsgReplyCB *) UnpackSrvTypesReply);
+ (SLPGenericAppCB *)(uintptr_t)callback, pvUser,
+ (SLPMsgReplyCB *) UnpackSrvTypesReply);
if (err != SLP_OK)
slp_end_call(hSLP);
diff --git a/usr/src/lib/libslp/clib/SLPFindSrvs.c b/usr/src/lib/libslp/clib/SLPFindSrvs.c
index 0038c44c21..31885f8d25 100644
--- a/usr/src/lib/libslp/clib/SLPFindSrvs.c
+++ b/usr/src/lib/libslp/clib/SLPFindSrvs.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
@@ -95,8 +93,7 @@ SLPError SLPFindSrvs(SLPHandle hSLP, const char *pcServiceType,
if (err == SLP_OK)
err = slp_ua_common(hSLP, pcScope,
- (SLPGenericAppCB *) callback, pvUser,
- unpack_cb);
+ (SLPGenericAppCB *)(uintptr_t)callback, pvUser, unpack_cb);
if (err != SLP_OK)
slp_end_call(hSLP);
diff --git a/usr/src/lib/libslp/clib/SLPReg.c b/usr/src/lib/libslp/clib/SLPReg.c
index fafe813c74..955c5983eb 100644
--- a/usr/src/lib/libslp/clib/SLPReg.c
+++ b/usr/src/lib/libslp/clib/SLPReg.c
@@ -118,7 +118,7 @@ static SLPError enqueue_reg(slp_handle_impl_t *, struct reg_msg *,
void *, SLPRegReport *);
static SLPError reg_impl(slp_handle_impl_t *, struct reg_msg *,
void *, SLPRegReport *);
-static void reg_thread();
+static void *reg_thread(void *);
static SLPError start_reg_thr();
static SLPError reg_common(slp_handle_impl_t *, struct reg_msg *,
void *, SLPRegReport *);
@@ -563,7 +563,7 @@ static SLPError start_reg_thr() {
/* start the reg thread */
if ((terr = thr_create(
- 0, 0, (void *(*)(void *)) reg_thread,
+ 0, 0, reg_thread,
NULL, 0, NULL)) != 0) {
slp_err(LOG_CRIT, 0, "start_reg_thr",
"could not start thread: %s",
@@ -586,7 +586,9 @@ start_done:
* To conserve resources,
* if there are no more registrations to refresh, it will exit.
*/
-static void reg_thread() {
+static void *
+reg_thread(void *arg __unused)
+{
timestruc_t timeout;
timeout.tv_nsec = 0;
@@ -596,7 +598,7 @@ static void reg_thread() {
/* get the next message from the queue */
timeout.tv_sec =
- next_wake_time ? next_wake_time : time(NULL) + 5;
+ next_wake_time ? next_wake_time : time(NULL) + 5;
rmsg = slp_dequeue_timed(reg_q, &timeout, &etimed);
if (!rmsg && etimed == SLP_TRUE) {
/* timed out */
diff --git a/usr/src/lib/libslp/clib/SLPUtils.c b/usr/src/lib/libslp/clib/SLPUtils.c
index af364492b3..ffce4111e1 100644
--- a/usr/src/lib/libslp/clib/SLPUtils.c
+++ b/usr/src/lib/libslp/clib/SLPUtils.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Public utilities and convenience calls (from the API spec):
* SLPFindScopes (queries for all known scopes)
@@ -253,11 +251,12 @@ static SLPError SAAdvert_for_scopes(SLPHandle hSLP, void **stree) {
err = slp_packSrvRqst("service:service-agent", predicate, hp);
- if (err == SLP_OK)
+ if (err == SLP_OK) {
err = slp_ua_common(hSLP, "",
- (SLPGenericAppCB *)saadvert_callback,
- stree,
- (SLPMsgReplyCB *)unpackSAAdvert_scope);
+ (SLPGenericAppCB *)(uintptr_t)saadvert_callback,
+ stree,
+ (SLPMsgReplyCB *)unpackSAAdvert_scope);
+ }
if (type_hint) {
free(predicate);
diff --git a/usr/src/lib/libslp/clib/slp_da_cache.c b/usr/src/lib/libslp/clib/slp_da_cache.c
index a38fb45501..92c05a6420 100644
--- a/usr/src/lib/libslp/clib/slp_da_cache.c
+++ b/usr/src/lib/libslp/clib/slp_da_cache.c
@@ -74,7 +74,7 @@ static int cache_called;
static cond_t cache_called_cond;
static mutex_t cache_called_lock = DEFAULTMUTEX;
static SLPError start_cache_thr();
-static void cache_thr();
+static void *cache_thr(void *);
/* The cache and cache synchronization */
static void *da_cache;
@@ -90,7 +90,7 @@ typedef struct cache_entry cache_entry_t;
/* cache management and searching */
static int compare_entries(const void *, const void *);
-static void free_cache_entry(void *, VISIT);
+static void free_cache_entry(void *, VISIT, int, void *);
/*
* Searches the cache for the reply to 'query'. Returns the reply if
@@ -200,7 +200,9 @@ static int compare_entries(const void *x1, const void *x2) {
return (strcasecmp(e1->query, e2->query));
}
-static void free_cache_entry(void *node, VISIT order) {
+static void
+free_cache_entry(void *node, VISIT order, int arg __unused, void *arg1 __unused)
+{
if (order == endorder || order == leaf) {
cache_entry_t *ce = *(cache_entry_t **)node;
@@ -223,9 +225,7 @@ static SLPError start_cache_thr() {
(void) cond_init(&cache_called_cond, 0, NULL);
- if ((terr = thr_create(
- 0, 0, (void *(*)(void *)) cache_thr,
- NULL, 0, NULL)) != 0) {
+ if ((terr = thr_create(0, 0, cache_thr, NULL, 0, NULL)) != 0) {
slp_err(LOG_CRIT, 0, "start_cache_thr",
"could not start thread: %s", strerror(terr));
err = SLP_INTERNAL_SYSTEM_ERROR;
@@ -238,7 +238,9 @@ start_done:
return (err);
}
-static void cache_thr() {
+static void *
+cache_thr(void *arg __unused)
+{
timestruc_t timeout;
timeout.tv_nsec = 0;
@@ -250,15 +252,13 @@ static void cache_thr() {
timeout.tv_sec = IDLE_TIMEOUT;
err = cond_reltimedwait(&cache_called_cond,
- &cache_called_lock, &timeout);
+ &cache_called_lock, &timeout);
if (err == ETIME) {
(void) mutex_lock(&cache_lock);
/* free cache */
if (da_cache) {
- slp_twalk(da_cache,
- (void (*)(void *, VISIT, int, void *))free_cache_entry,
- 0, NULL);
+ slp_twalk(da_cache, free_cache_entry, 0, NULL);
}
da_cache = NULL;
(void) mutex_unlock(&cache_lock);
@@ -269,4 +269,5 @@ static void cache_thr() {
cache_called = 0;
}
}
+ return (NULL);
}
diff --git a/usr/src/lib/libslp/clib/slp_ipc.c b/usr/src/lib/libslp/clib/slp_ipc.c
index 9449c8ecf6..113200e54f 100644
--- a/usr/src/lib/libslp/clib/slp_ipc.c
+++ b/usr/src/lib/libslp/clib/slp_ipc.c
@@ -58,7 +58,7 @@ static struct sockaddr_in *local_sin; /* slpd addr, set on first use */
static SLPError open_ipc();
static void close_ipc();
static void get_localhost_sin();
-static void ipc_manage_thr();
+static void *ipc_manage_thr(void *);
/*
* Locking should be handled by the caller
@@ -115,10 +115,8 @@ static SLPError open_ipc() {
/* We now know slpd is reachable; start the management thread */
if (!ipc_thr_running) {
- if ((terr = thr_create(
- 0, 0,
- (void *(*)(void *)) ipc_manage_thr,
- NULL, 0, NULL)) != 0) {
+ if ((terr = thr_create(0, 0, ipc_manage_thr,
+ NULL, 0, NULL)) != 0) {
slp_err(LOG_CRIT, 0, "slp_open_ipc",
"could not start thread: %s",
strerror(terr));
@@ -289,7 +287,9 @@ done:
* and continues waiting for the next IPC call. After the FD has expired,
* the thread closes IPC and shuts itself down.
*/
-static void ipc_manage_thr() {
+static void *
+ipc_manage_thr(void *arg __unused)
+{
timestruc_t timeout;
timeout.tv_nsec = 0;
@@ -301,7 +301,7 @@ static void ipc_manage_thr() {
timeout.tv_sec = IPC_FD_LIFETIME;
err = cond_reltimedwait(&ipc_wait_var, &ipc_wait_lock,
- &timeout);
+ &timeout);
if (err == ETIME) {
/* shutdown */
@@ -314,4 +314,5 @@ static void ipc_manage_thr() {
ipc_used = 0;
}
}
+ return (NULL);
}
diff --git a/usr/src/lib/libslp/clib/slp_net.c b/usr/src/lib/libslp/clib/slp_net.c
index 2a1fc64472..3a15b3412e 100644
--- a/usr/src/lib/libslp/clib/slp_net.c
+++ b/usr/src/lib/libslp/clib/slp_net.c
@@ -83,7 +83,7 @@ struct bc_ifs {
* Private utility routines
*/
static SLPError start_tcp_thr();
-static void tcp_thread();
+static void *tcp_thread(void *);
static SLPError make_header(slp_handle_impl_t *, char *, const char *);
static void udp_make_msghdr(struct sockaddr_in *, struct iovec *, int,
struct msghdr *);
@@ -401,7 +401,9 @@ void slp_mc_send(slp_handle_impl_t *hp, const char *scopes) {
/*
* Starts the tcp_thread and allocates any necessary resources.
*/
-static SLPError start_tcp_thr() {
+static SLPError
+start_tcp_thr(void)
+{
SLPError err;
int terr;
@@ -419,12 +421,11 @@ static SLPError start_tcp_thr() {
}
/* start the tcp thread */
- if ((terr = thr_create(0, 0, (void *(*)(void *)) tcp_thread,
- NULL, 0, NULL)) != 0) {
- slp_err(LOG_CRIT, 0, "start_tcp_thr",
+ if ((terr = thr_create(0, 0, tcp_thread, NULL, 0, NULL)) != 0) {
+ slp_err(LOG_CRIT, 0, "start_tcp_thr",
"could not start thread: %s", strerror(terr));
- (void) mutex_unlock(&start_lock);
- return (SLP_INTERNAL_SYSTEM_ERROR);
+ (void) mutex_unlock(&start_lock);
+ return (SLP_INTERNAL_SYSTEM_ERROR);
}
tcp_thr_running = SLP_TRUE;
@@ -452,7 +453,9 @@ static void end_tcp_thr() {
* on 'tcp_q' for new messages. If no message appear after 30 seconds,
* this thread cleans up resources and shuts itself down.
*/
-static void tcp_thread() {
+static void *
+tcp_thread(void *arg __unused)
+{
struct tcp_rqst *rqst;
char *reply, header[SLP_DEFAULT_SENDMTU];
timestruc_t to[1];
@@ -497,9 +500,8 @@ static void tcp_thread() {
slp_set_xid(header, xid);
/* walk targets list until we either succeed or run out of targets */
- for (ctarg = targets;
- ctarg && !hp->cancel;
- ctarg = slp_next_failover(ctarg)) {
+ for (ctarg = targets; ctarg && !hp->cancel;
+ ctarg = slp_next_failover(ctarg)) {
sin = (struct sockaddr_in *)slp_get_target_sin(ctarg);
@@ -507,18 +509,18 @@ static void tcp_thread() {
if ((tcp_sockfd = socket(AF_INET, SOCK_STREAM, 0))
< 0) {
slp_err(LOG_CRIT, 0, "tcp_thread",
- "could not create socket: %s",
- strerror(errno));
+ "could not create socket: %s",
+ strerror(errno));
ctarg = NULL;
break;
}
/* connect to target */
if (connect(tcp_sockfd, (struct sockaddr *)sin,
- sizeof (*sin)) < 0) {
+ sizeof (*sin)) < 0) {
slp_err(LOG_INFO, 0, "tcp_thread",
- "could not connect, error = %s",
- strerror(errno));
+ "could not connect, error = %s",
+ strerror(errno));
goto failed;
}
@@ -526,8 +528,8 @@ static void tcp_thread() {
if (writev(tcp_sockfd, hp->msg.iov, hp->msg.iovlen)
== -1) {
slp_err(LOG_INFO, 0, "tcp_thread",
- "could not send, error = %s",
- strerror(errno));
+ "could not send, error = %s",
+ strerror(errno));
goto failed;
}
@@ -563,6 +565,7 @@ transaction_complete:
if (free_target)
slp_free_target(targets);
}
+ return (NULL);
}
/*
diff --git a/usr/src/lib/libslp/clib/slp_ua_common.c b/usr/src/lib/libslp/clib/slp_ua_common.c
index 93d0fe8d9d..3c542feb85 100644
--- a/usr/src/lib/libslp/clib/slp_ua_common.c
+++ b/usr/src/lib/libslp/clib/slp_ua_common.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
@@ -43,13 +41,13 @@ struct thr_call_args {
slp_target_list_t *targets;
};
-static SLPError consumer(void *);
-static void slp_call(void *);
+static void *consumer(void *);
+static void *slp_call(void *);
static SLPError check_message_fit(slp_handle_impl_t *, slp_target_list_t *);
SLPError slp_ua_common(SLPHandle hSLP, const char *scopes,
- SLPGenericAppCB cb, void *cookie,
- SLPMsgReplyCB msg_cb) {
+ SLPGenericAppCB cb, void *cookie, SLPMsgReplyCB msg_cb)
+{
slp_handle_impl_t *hp;
slp_target_list_t *targets;
struct thr_call_args *args;
@@ -88,10 +86,9 @@ SLPError slp_ua_common(SLPHandle hSLP, const char *scopes,
hp->q = q;
/* kick off the producer thread */
- if ((terr = thr_create(
- NULL, 0, (void *(*)(void *)) slp_call, args, 0, &tid)) != 0) {
+ if ((terr = thr_create(NULL, 0, slp_call, args, 0, &tid)) != 0) {
slp_err(LOG_CRIT, 0, "ua_common", "could not start thread: %s",
- strerror(terr));
+ strerror(terr));
err = SLP_INTERNAL_SYSTEM_ERROR;
goto error;
}
@@ -99,12 +96,11 @@ SLPError slp_ua_common(SLPHandle hSLP, const char *scopes,
if (hp->async) {
/* kick off the consumer thread */
- if ((terr = thr_create(
- NULL, 0, (void *(*)(void *))consumer,
- args, 0, NULL)) != 0) {
+ if ((terr = thr_create(NULL, 0, consumer,
+ args, 0, NULL)) != 0) {
slp_err(LOG_CRIT, 0, "ua_common",
- "could not start thread: %s",
- strerror(terr));
+ "could not start thread: %s",
+ strerror(terr));
err = SLP_INTERNAL_SYSTEM_ERROR;
/* cleanup producer thread, if necessary */
hp->cancel = 1;
@@ -115,13 +111,15 @@ SLPError slp_ua_common(SLPHandle hSLP, const char *scopes,
return (SLP_OK);
}
/* else sync */
- return (consumer(args));
+ return ((SLPError)consumer(args));
error:
free(args);
return (err);
}
-static SLPError consumer(void *ap) {
+static void *
+consumer(void *ap)
+{
slp_handle_impl_t *hp;
char *reply;
void *collator;
@@ -138,19 +136,19 @@ static SLPError consumer(void *ap) {
reply = slp_dequeue(hp->q);
/* reply == NULL if no more available or SLPClosed */
cont = args->msg_cb(hp, reply, args->cb, args->cookie,
- &collator, &numResults);
+ &collator, &numResults);
if (reply) {
- free(reply);
+ free(reply);
} else {
- break;
+ break;
}
if (!cont) {
- /* cb doesn't want any more; invoke last call */
- args->msg_cb(hp, NULL, args->cb, args->cookie,
- &collator, &numResults);
- break;
+ /* cb doesn't want any more; invoke last call */
+ args->msg_cb(hp, NULL, args->cb, args->cookie,
+ &collator, &numResults);
+ break;
}
}
/* cleanup */
@@ -164,13 +162,15 @@ static SLPError consumer(void *ap) {
free(args);
slp_end_call(hp);
- return (SLP_OK);
+ return ((void *)SLP_OK);
}
/*
* This is the producer thread
*/
-static void slp_call(void *ap) {
+static void *
+slp_call(void *ap)
+{
struct thr_call_args *args = (struct thr_call_args *)ap;
slp_target_t *t;
const char *uc_scopes, *mc_scopes;
@@ -193,16 +193,14 @@ static void slp_call(void *ap) {
if (len > mtu)
use_tcp = SLP_TRUE;
- for (
- t = slp_next_uc_target(args->targets);
- t;
- t = slp_next_uc_target(args->targets)) {
+ for (t = slp_next_uc_target(args->targets); t != NULL;
+ t = slp_next_uc_target(args->targets)) {
if (args->hp->cancel)
break;
if (use_tcp)
slp_uc_tcp_send(args->hp, t, uc_scopes,
- SLP_FALSE, 0);
+ SLP_FALSE, 0);
else
slp_uc_udp_send(args->hp, t, uc_scopes);
}