diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-09-23 22:35:03 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-10-01 08:55:11 -0700 |
commit | b1b69ce8e8e4fe0f190c8bd85b537309e71055c8 (patch) | |
tree | a6480c97e61c66ea6b4dcda42345d3bf9c6209a6 /Xtrans.c | |
parent | cbdb434033da1725a69014cc6e4d89c691a6fd95 (diff) |
Convert PRMSG macro to prmsg inline function
Allows using varargs to have the correct number of arguments passed to
get rid of the many gcc warnings about variable printf format strings,
and to reduce the duplication from having 5 implementations of the
PRMSG macro depending on the debug options defined & output method used.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'Xtrans.c')
-rw-r--r-- | Xtrans.c | 128 |
1 files changed, 63 insertions, 65 deletions
@@ -132,7 +132,7 @@ void TRANS(FreeConnInfo) (XtransConnInfo ciptr) { - PRMSG (3,"FreeConnInfo(%p)\n", ciptr, 0, 0); + prmsg (3,"FreeConnInfo(%p)\n", ciptr); if (ciptr->addr) xfree (ciptr->addr); @@ -156,7 +156,7 @@ TRANS(SelectTransport) (char *protocol) char protobuf[PROTOBUFSIZE]; int i; - PRMSG (3,"SelectTransport(%s)\n", protocol, 0, 0); + prmsg (3,"SelectTransport(%s)\n", protocol); /* * Force Protocol to be lowercase as a way of doing @@ -207,7 +207,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) char hostnamebuf[256]; int _host_len; - PRMSG (3,"ParseAddress(%s)\n", address, 0, 0); + prmsg (3,"ParseAddress(%s)\n", address); /* Copy the string so it can be changed */ @@ -404,12 +404,12 @@ TRANS(Open) (int type, char *address) XtransConnInfo ciptr = NULL; Xtransport *thistrans; - PRMSG (2,"Open(%d,%s)\n", type, address, 0); + prmsg (2,"Open(%d,%s)\n", type, address); #if defined(WIN32) && defined(TCPCONN) if (TRANS(WSAStartup)()) { - PRMSG (1,"Open: WSAStartup failed\n", 0, 0, 0); + prmsg (1,"Open: WSAStartup failed\n"); return NULL; } #endif @@ -418,7 +418,7 @@ TRANS(Open) (int type, char *address) if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0) { - PRMSG (1,"Open: Unable to Parse address %s\n", address, 0, 0); + prmsg (1,"Open: Unable to Parse address %s\n", address); return NULL; } @@ -426,8 +426,8 @@ TRANS(Open) (int type, char *address) if ((thistrans = TRANS(SelectTransport) (protocol)) == NULL) { - PRMSG (1,"Open: Unable to find transport for %s\n", - protocol, 0, 0); + prmsg (1,"Open: Unable to find transport for %s\n", + protocol); xfree (protocol); xfree (host); @@ -460,14 +460,14 @@ TRANS(Open) (int type, char *address) #endif /* TRANS_SERVER */ break; default: - PRMSG (1,"Open: Unknown Open type %d\n", type, 0, 0); + prmsg (1,"Open: Unknown Open type %d\n", type); } if (ciptr == NULL) { if (!(thistrans->flags & TRANS_DISABLED)) { - PRMSG (1,"Open: transport open failed for %s/%s:%s\n", + prmsg (1,"Open: transport open failed for %s/%s:%s\n", protocol, host, port); } xfree (protocol); @@ -503,7 +503,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) char *save_port; int i; - PRMSG (2,"Reopen(%d,%d,%s)\n", trans_id, fd, port); + prmsg (2,"Reopen(%d,%d,%s)\n", trans_id, fd, port); /* Determine the transport type */ @@ -516,15 +516,15 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) if (thistrans == NULL) { - PRMSG (1,"Reopen: Unable to find transport id %d\n", - trans_id, 0, 0); + prmsg (1,"Reopen: Unable to find transport id %d\n", + trans_id); return NULL; } if ((save_port = (char *) xalloc (strlen (port) + 1)) == NULL) { - PRMSG (1,"Reopen: Unable to malloc port string\n", 0, 0, 0); + prmsg (1,"Reopen: Unable to malloc port string\n"); return NULL; } @@ -542,12 +542,12 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) ciptr = thistrans->ReopenCLTSServer(thistrans, fd, port); break; default: - PRMSG (1,"Reopen: Bad Open type %d\n", type, 0, 0); + prmsg (1,"Reopen: Bad Open type %d\n", type); } if (ciptr == NULL) { - PRMSG (1,"Reopen: transport open failed\n", 0, 0, 0); + prmsg (1,"Reopen: transport open failed\n"); return NULL; } @@ -573,7 +573,7 @@ XtransConnInfo TRANS(OpenCOTSClient) (char *address) { - PRMSG (2,"OpenCOTSClient(%s)\n", address, 0, 0); + prmsg (2,"OpenCOTSClient(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_COTS_CLIENT, address); } @@ -586,7 +586,7 @@ XtransConnInfo TRANS(OpenCOTSServer) (char *address) { - PRMSG (2,"OpenCOTSServer(%s)\n", address, 0, 0); + prmsg (2,"OpenCOTSServer(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_COTS_SERVER, address); } @@ -599,7 +599,7 @@ XtransConnInfo TRANS(OpenCLTSClient) (char *address) { - PRMSG (2,"OpenCLTSClient(%s)\n", address, 0, 0); + prmsg (2,"OpenCLTSClient(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_CLTS_CLIENT, address); } @@ -612,7 +612,7 @@ XtransConnInfo TRANS(OpenCLTSServer) (char *address) { - PRMSG (2,"OpenCLTSServer(%s)\n", address, 0, 0); + prmsg (2,"OpenCLTSServer(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_CLTS_SERVER, address); } @@ -625,7 +625,7 @@ XtransConnInfo TRANS(ReopenCOTSServer) (int trans_id, int fd, char *port) { - PRMSG (2,"ReopenCOTSServer(%d, %d, %s)\n", trans_id, fd, port); + prmsg (2,"ReopenCOTSServer(%d, %d, %s)\n", trans_id, fd, port); return TRANS(Reopen) (XTRANS_OPEN_COTS_SERVER, trans_id, fd, port); } @@ -633,7 +633,7 @@ XtransConnInfo TRANS(ReopenCLTSServer) (int trans_id, int fd, char *port) { - PRMSG (2,"ReopenCLTSServer(%d, %d, %s)\n", trans_id, fd, port); + prmsg (2,"ReopenCLTSServer(%d, %d, %s)\n", trans_id, fd, port); return TRANS(Reopen) (XTRANS_OPEN_CLTS_SERVER, trans_id, fd, port); } @@ -673,7 +673,7 @@ TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg) int fd = ciptr->fd; int ret = 0; - PRMSG (2,"SetOption(%d,%d,%d)\n", fd, option, arg); + prmsg (2,"SetOption(%d,%d,%d)\n", fd, option, arg); /* * For now, all transport type use the same stuff for setting options. @@ -767,8 +767,8 @@ TRANS(NoListen) (char * protocol) if ((trans = TRANS(SelectTransport)(protocol)) == NULL) { - PRMSG (1,"TransNoListen: unable to find transport: %s\n", - protocol, 0, 0); + prmsg (1,"TransNoListen: unable to find transport: %s\n", + protocol); return -1; } @@ -801,7 +801,7 @@ TRANS(Accept) (XtransConnInfo ciptr, int *status) { XtransConnInfo newciptr; - PRMSG (2,"Accept(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"Accept(%d)\n", ciptr->fd); newciptr = ciptr->transptr->Accept (ciptr, status); @@ -825,12 +825,12 @@ TRANS(Connect) (XtransConnInfo ciptr, char *address) char *port; int ret; - PRMSG (2,"Connect(%d,%s)\n", ciptr->fd, address, 0); + prmsg (2,"Connect(%d,%s)\n", ciptr->fd, address); if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0) { - PRMSG (1,"Connect: Unable to Parse address %s\n", - address, 0, 0); + prmsg (1,"Connect: Unable to Parse address %s\n", + address); return -1; } @@ -840,8 +840,8 @@ TRANS(Connect) (XtransConnInfo ciptr, char *address) if (!port || !*port) { - PRMSG (1,"Connect: Missing port specification in %s\n", - address, 0, 0); + prmsg (1,"Connect: Missing port specification in %s\n", + address); if (protocol) xfree (protocol); if (host) xfree (host); return -1; @@ -907,7 +907,7 @@ TRANS(Close) (XtransConnInfo ciptr) { int ret; - PRMSG (2,"Close(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"Close(%d)\n", ciptr->fd); ret = ciptr->transptr->Close (ciptr); @@ -922,7 +922,7 @@ TRANS(CloseForCloning) (XtransConnInfo ciptr) { int ret; - PRMSG (2,"CloseForCloning(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"CloseForCloning(%d)\n", ciptr->fd); ret = ciptr->transptr->CloseForCloning (ciptr); @@ -944,14 +944,14 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, Xtransaddr **addrp) { - PRMSG (2,"GetMyAddr(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"GetMyAddr(%d)\n", ciptr->fd); *familyp = ciptr->family; *addrlenp = ciptr->addrlen; if ((*addrp = (Xtransaddr *) xalloc (ciptr->addrlen)) == NULL) { - PRMSG (1,"GetMyAddr: malloc failed\n", 0, 0, 0); + prmsg (1,"GetMyAddr: malloc failed\n"); return -1; } memcpy(*addrp, ciptr->addr, ciptr->addrlen); @@ -964,14 +964,14 @@ TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, Xtransaddr **addrp) { - PRMSG (2,"GetPeerAddr(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"GetPeerAddr(%d)\n", ciptr->fd); *familyp = ciptr->family; *addrlenp = ciptr->peeraddrlen; if ((*addrp = (Xtransaddr *) xalloc (ciptr->peeraddrlen)) == NULL) { - PRMSG (1,"GetPeerAddr: malloc failed\n", 0, 0, 0); + prmsg (1,"GetPeerAddr: malloc failed\n"); return -1; } memcpy(*addrp, ciptr->peeraddr, ciptr->peeraddrlen); @@ -1040,8 +1040,8 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, #if defined(IPv6) && defined(AF_INET6) int ipv6_succ = 0; #endif - PRMSG (2,"MakeAllCOTSServerListeners(%s,%p)\n", - port ? port : "NULL", ciptrs_ret, 0); + prmsg (2,"MakeAllCOTSServerListeners(%s,%p)\n", + port ? port : "NULL", ciptrs_ret); *count_ret = 0; @@ -1067,17 +1067,17 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, snprintf(buffer, sizeof(buffer), "%s/:%s", trans->TransName, port ? port : ""); - PRMSG (5,"MakeAllCOTSServerListeners: opening %s\n", - buffer, 0, 0); + prmsg (5,"MakeAllCOTSServerListeners: opening %s\n", + buffer); if ((ciptr = TRANS(OpenCOTSServer(buffer))) == NULL) { if (trans->flags & TRANS_DISABLED) continue; - PRMSG (1, + prmsg (1, "MakeAllCOTSServerListeners: failed to open listener for %s\n", - trans->TransName, 0, 0); + trans->TransName); continue; } #if defined(IPv6) && defined(AF_INET6) @@ -1096,9 +1096,8 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, * running at this address, and this function should fail. */ - PRMSG (1, - "MakeAllCOTSServerListeners: server already running\n", - 0, 0, 0); + prmsg (1, + "MakeAllCOTSServerListeners: server already running\n"); for (j = 0; j < *count_ret; j++) TRANS(Close) (temp_ciptrs[j]); @@ -1110,9 +1109,9 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, } else { - PRMSG (1, + prmsg (1, "MakeAllCOTSServerListeners: failed to create listener for %s\n", - trans->TransName, 0, 0); + trans->TransName); continue; } @@ -1123,9 +1122,9 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, ipv6_succ = 1; #endif - PRMSG (5, + prmsg (5, "MakeAllCOTSServerListeners: opened listener for %s, %d\n", - trans->TransName, ciptr->fd, 0); + trans->TransName, ciptr->fd); temp_ciptrs[*count_ret] = ciptr; (*count_ret)++; @@ -1133,7 +1132,7 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, *partial = (*count_ret < complete_network_count()); - PRMSG (5, + prmsg (5, "MakeAllCOTSServerListeners: partial=%d, actual=%d, complete=%d \n", *partial, *count_ret, complete_network_count()); @@ -1165,8 +1164,8 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, XtransConnInfo ciptr, temp_ciptrs[NUMTRANS]; int status, i, j; - PRMSG (2,"MakeAllCLTSServerListeners(%s,%p)\n", - port ? port : "NULL", ciptrs_ret, 0); + prmsg (2,"MakeAllCLTSServerListeners(%s,%p)\n", + port ? port : "NULL", ciptrs_ret); *count_ret = 0; @@ -1180,14 +1179,14 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, snprintf(buffer, sizeof(buffer), "%s/:%s", trans->TransName, port ? port : ""); - PRMSG (5,"MakeAllCLTSServerListeners: opening %s\n", - buffer, 0, 0); + prmsg (5,"MakeAllCLTSServerListeners: opening %s\n", + buffer); if ((ciptr = TRANS(OpenCLTSServer (buffer))) == NULL) { - PRMSG (1, + prmsg (1, "MakeAllCLTSServerListeners: failed to open listener for %s\n", - trans->TransName, 0, 0); + trans->TransName); continue; } @@ -1201,9 +1200,8 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, * running at this address, and this function should fail. */ - PRMSG (1, - "MakeAllCLTSServerListeners: server already running\n", - 0, 0, 0); + prmsg (1, + "MakeAllCLTSServerListeners: server already running\n"); for (j = 0; j < *count_ret; j++) TRANS(Close) (temp_ciptrs[j]); @@ -1215,24 +1213,24 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, } else { - PRMSG (1, + prmsg (1, "MakeAllCLTSServerListeners: failed to create listener for %s\n", - trans->TransName, 0, 0); + trans->TransName); continue; } } - PRMSG (5, + prmsg (5, "MakeAllCLTSServerListeners: opened listener for %s, %d\n", - trans->TransName, ciptr->fd, 0); + trans->TransName, ciptr->fd); temp_ciptrs[*count_ret] = ciptr; (*count_ret)++; } *partial = (*count_ret < complete_network_count()); - PRMSG (5, + prmsg (5, "MakeAllCLTSServerListeners: partial=%d, actual=%d, complete=%d \n", *partial, *count_ret, complete_network_count()); |