Fix compiler warnings for platforms where size of long is different than size of pointer.

This commit is contained in:
wb2osz 2019-11-30 20:20:13 -05:00
parent ff9eca682e
commit d5cec4dc84
12 changed files with 45 additions and 41 deletions

View File

@ -2510,7 +2510,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
old_tree = NULL; old_tree = NULL;
if (elem->token.type == SUBEXP) if (elem->token.type == SUBEXP)
postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); postorder (elem, mark_opt_subexp, (void *) (ptrdiff_t) elem->token.opr.idx);
tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT));
if (BE (tree == NULL, 0)) if (BE (tree == NULL, 0))
@ -3725,7 +3725,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
static reg_errcode_t static reg_errcode_t
mark_opt_subexp (void *extra, bin_tree_t *node) mark_opt_subexp (void *extra, bin_tree_t *node)
{ {
int idx = (int) (long) extra; int idx = (int) (ptrdiff_t) extra;
if (node->token.type == SUBEXP && node->token.opr.idx == idx) if (node->token.type == SUBEXP && node->token.opr.idx == idx)
node->token.opt_subexp = 1; node->token.opt_subexp = 1;

View File

@ -283,10 +283,10 @@ int main (int argc, char *argv[])
#if __WIN32__ #if __WIN32__
if (isdigit(port[j][0])) { if (isdigit(port[j][0])) {
client_th[j] = (HANDLE)_beginthreadex (NULL, 0, client_thread_net, (void *)j, 0, NULL); client_th[j] = (HANDLE)_beginthreadex (NULL, 0, client_thread_net, (void *)(ptrdiff_t)j, 0, NULL);
} }
else { else {
client_th[j] = (HANDLE)_beginthreadex (NULL, 0, client_thread_serial, (void *)j, 0, NULL); client_th[j] = (HANDLE)_beginthreadex (NULL, 0, client_thread_serial, (void *)(ptrdiff_t)j, 0, NULL);
} }
if (client_th[j] == NULL) { if (client_th[j] == NULL) {
printf ("Internal error: Could not create client thread %d.\n", j); printf ("Internal error: Could not create client thread %d.\n", j);
@ -294,10 +294,10 @@ int main (int argc, char *argv[])
} }
#else #else
if (isdigit(port[j][0])) { if (isdigit(port[j][0])) {
e = pthread_create (&client_tid[j], NULL, client_thread_net, (void *)(long)j); e = pthread_create (&client_tid[j], NULL, client_thread_net, (void *)(ptrdiff_t)j);
} }
else { else {
e = pthread_create (&client_tid[j], NULL, client_thread_serial, (void *)(long)j); e = pthread_create (&client_tid[j], NULL, client_thread_serial, (void *)(ptrdiff_t)j);
} }
if (e != 0) { if (e != 0) {
perror("Internal error: Could not create client thread."); perror("Internal error: Could not create client thread.");
@ -394,7 +394,7 @@ static void * client_thread_net (void *arg)
int use_chan = -1; int use_chan = -1;
my_index = (int)(long)arg; my_index = (int)(ptrdiff_t)arg;
#if DEBUGx #if DEBUGx
printf ("DEBUG: client_thread_net %d start, port = '%s'\n", my_index, port[my_index]); printf ("DEBUG: client_thread_net %d start, port = '%s'\n", my_index, port[my_index]);
@ -664,7 +664,7 @@ static unsigned __stdcall client_thread_serial (void *arg)
static void * client_thread_serial (void *arg) static void * client_thread_serial (void *arg)
#endif #endif
{ {
int my_index = (int)(long)arg; int my_index = (int)(ptrdiff_t)arg;
#if __WIN32__ #if __WIN32__

View File

@ -383,7 +383,7 @@ void beacon_init (struct audio_s *pmodem, struct misc_config_s *pconfig, struct
#else #else
int e; int e;
e = pthread_create (&beacon_tid, NULL, beacon_thread, (void *)0); e = pthread_create (&beacon_tid, NULL, beacon_thread, NULL);
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
perror("Could not create beacon thread"); perror("Could not create beacon thread");

View File

@ -193,7 +193,7 @@ int dwgpsd_init (struct misc_config_s *pconfig, int debug)
gps_stream(&gpsdata, WATCH_ENABLE | WATCH_JSON, NULL); gps_stream(&gpsdata, WATCH_ENABLE | WATCH_JSON, NULL);
e = pthread_create (&read_gps_tid, NULL, read_gpsd_thread, (void *)(long)arg); e = pthread_create (&read_gps_tid, NULL, read_gpsd_thread, (void *)(ptrdiff_t)arg);
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
perror("Could not create GPS reader thread"); perror("Could not create GPS reader thread");

View File

@ -151,7 +151,7 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug)
if (s_gpsnmea_port_fd != MYFDERROR) { if (s_gpsnmea_port_fd != MYFDERROR) {
#if __WIN32__ #if __WIN32__
read_gps_th = (HANDLE)_beginthreadex (NULL, 0, read_gpsnmea_thread, (void*)(long)s_gpsnmea_port_fd, 0, NULL); read_gps_th = (HANDLE)_beginthreadex (NULL, 0, read_gpsnmea_thread, (void*)(ptrdiff_t)s_gpsnmea_port_fd, 0, NULL);
if (read_gps_th == NULL) { if (read_gps_th == NULL) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Could not create GPS NMEA listening thread.\n"); dw_printf ("Could not create GPS NMEA listening thread.\n");
@ -159,7 +159,7 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug)
} }
#else #else
int e; int e;
e = pthread_create (&read_gps_tid, NULL, read_gpsnmea_thread, (void*)(long)s_gpsnmea_port_fd); e = pthread_create (&read_gps_tid, NULL, read_gpsnmea_thread, (void*)(ptrdiff_t)s_gpsnmea_port_fd);
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
perror("Could not create GPS NMEA listening thread."); perror("Could not create GPS NMEA listening thread.");
@ -216,7 +216,7 @@ static unsigned __stdcall read_gpsnmea_thread (void *arg)
static void * read_gpsnmea_thread (void *arg) static void * read_gpsnmea_thread (void *arg)
#endif #endif
{ {
MYFDTYPE fd = (MYFDTYPE)(long)arg; MYFDTYPE fd = (MYFDTYPE)(ptrdiff_t)arg;
// Maximum length of message from GPS receiver is 82 according to some people. // Maximum length of message from GPS receiver is 82 according to some people.
// Make buffer considerably larger to be safe. // Make buffer considerably larger to be safe.
@ -230,7 +230,7 @@ static void * read_gpsnmea_thread (void *arg)
if (s_debug >= 2) { if (s_debug >= 2) {
text_color_set(DW_COLOR_DEBUG); text_color_set(DW_COLOR_DEBUG);
dw_printf ("read_gpsnmea_thread (%d)\n", (int)(long)arg); dw_printf ("read_gpsnmea_thread (%d)\n", (int)(ptrdiff_t)arg);
} }
dwgps_clear (&info); dwgps_clear (&info);

View File

@ -466,7 +466,7 @@ void igate_init (struct audio_s *p_audio_config, struct igate_config_s *p_igate_
return; return;
} }
#else #else
e = pthread_create (&connect_listen_tid, NULL, connnect_thread, (void *)NULL); e = pthread_create (&connect_listen_tid, NULL, connnect_thread, NULL);
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
perror("Internal error: Could not create IGate connection thread"); perror("Internal error: Could not create IGate connection thread");

View File

@ -231,14 +231,14 @@ void kissnet_init (struct misc_config_s *mc)
* This waits for a client to connect and sets client_sock[n]. * This waits for a client to connect and sets client_sock[n].
*/ */
#if __WIN32__ #if __WIN32__
connect_listen_th = (HANDLE)_beginthreadex (NULL, 0, connect_listen_thread, (void *)kiss_port, 0, NULL); connect_listen_th = (HANDLE)_beginthreadex (NULL, 0, connect_listen_thread, (void *)(ptrdiff_t)kiss_port, 0, NULL);
if (connect_listen_th == NULL) { if (connect_listen_th == NULL) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Could not create KISS socket connect listening thread\n"); dw_printf ("Could not create KISS socket connect listening thread\n");
return; return;
} }
#else #else
e = pthread_create (&connect_listen_tid, NULL, connect_listen_thread, (void *)(long)kiss_port); e = pthread_create (&connect_listen_tid, NULL, connect_listen_thread, (void *)(ptrdiff_t)kiss_port);
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
perror("Could not create KISS socket connect listening thread"); perror("Could not create KISS socket connect listening thread");
@ -254,14 +254,14 @@ void kissnet_init (struct misc_config_s *mc)
for (client = 0; client < MAX_NET_CLIENTS; client++) { for (client = 0; client < MAX_NET_CLIENTS; client++) {
#if __WIN32__ #if __WIN32__
cmd_listen_th[client] = (HANDLE)_beginthreadex (NULL, 0, kissnet_listen_thread, (void*)client, 0, NULL); cmd_listen_th[client] = (HANDLE)_beginthreadex (NULL, 0, kissnet_listen_thread, (void*)(ptrdiff_t)client, 0, NULL);
if (cmd_listen_th[client] == NULL) { if (cmd_listen_th[client] == NULL) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Could not create KISS command listening thread for client %d\n", client); dw_printf ("Could not create KISS command listening thread for client %d\n", client);
return; return;
} }
#else #else
e = pthread_create (&(cmd_listen_tid[client]), NULL, kissnet_listen_thread, (void *)(long)client); e = pthread_create (&(cmd_listen_tid[client]), NULL, kissnet_listen_thread, (void *)(ptrdiff_t)client);
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Could not create KISS command listening thread for client %d\n", client); dw_printf ("Could not create KISS command listening thread for client %d\n", client);
@ -305,10 +305,10 @@ static THREAD_F connect_listen_thread (void *arg)
SOCKET listen_sock; SOCKET listen_sock;
WSADATA wsadata; WSADATA wsadata;
snprintf (kiss_port_str, sizeof(kiss_port_str), "%d", (int)(long)arg); snprintf (kiss_port_str, sizeof(kiss_port_str), "%d", (int)(ptrdiff_t)arg);
#if DEBUG #if DEBUG
text_color_set(DW_COLOR_DEBUG); text_color_set(DW_COLOR_DEBUG);
dw_printf ("DEBUG: kissnet port = %d = '%s'\n", (int)(long)arg, kiss_port_str); dw_printf ("DEBUG: kissnet port = %d = '%s'\n", (int)(ptrdiff_t)arg, kiss_port_str);
#endif #endif
err = WSAStartup (MAKEWORD(2,2), &wsadata); err = WSAStartup (MAKEWORD(2,2), &wsadata);
if (err != 0) { if (err != 0) {
@ -425,7 +425,7 @@ static THREAD_F connect_listen_thread (void *arg)
struct sockaddr_in sockaddr; /* Internet socket address stuct */ struct sockaddr_in sockaddr; /* Internet socket address stuct */
socklen_t sockaddr_size = sizeof(struct sockaddr_in); socklen_t sockaddr_size = sizeof(struct sockaddr_in);
int kiss_port = (int)(long)arg; int kiss_port = (int)(ptrdiff_t)arg;
int listen_sock; int listen_sock;
int bcopt = 1; int bcopt = 1;
@ -808,7 +808,7 @@ static THREAD_F kissnet_listen_thread (void *arg)
unsigned char ch; unsigned char ch;
int client = (int)(long)arg; int client = (int)(ptrdiff_t)arg;
#if DEBUG #if DEBUG
text_color_set(DW_COLOR_DEBUG); text_color_set(DW_COLOR_DEBUG);

View File

@ -285,7 +285,7 @@ int main (int argc, char *argv[])
#if __WIN32__ #if __WIN32__
if (using_tcp) { if (using_tcp) {
tnc_th = (HANDLE)_beginthreadex (NULL, 0, tnc_listen_net, (void *)99, 0, NULL); tnc_th = (HANDLE)_beginthreadex (NULL, 0, tnc_listen_net, (void *)(ptrdiff_t)99, 0, NULL);
} }
else { else {
tnc_th = (HANDLE)_beginthreadex (NULL, 0, tnc_listen_serial, (void *)99, 0, NULL); tnc_th = (HANDLE)_beginthreadex (NULL, 0, tnc_listen_serial, (void *)99, 0, NULL);
@ -296,10 +296,10 @@ int main (int argc, char *argv[])
} }
#else #else
if (using_tcp) { if (using_tcp) {
e = pthread_create (&tnc_tid, NULL, tnc_listen_net, (void *)(long)99); e = pthread_create (&tnc_tid, NULL, tnc_listen_net, (void *)(ptrdiff_t)99);
} }
else { else {
e = pthread_create (&tnc_tid, NULL, tnc_listen_serial, (void *)(long)99); e = pthread_create (&tnc_tid, NULL, tnc_listen_serial, (void *)(ptrdiff_t)99);
} }
if (e != 0) { if (e != 0) {
perror("Internal error: Could not create TNC listen thread."); perror("Internal error: Could not create TNC listen thread.");

View File

@ -51,6 +51,10 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#if __WIN32__
#include <direct.h> // for _mkdir()
#endif
#include "ax25_pad.h" #include "ax25_pad.h"
#include "textcolor.h" #include "textcolor.h"
#include "decode_aprs.h" #include "decode_aprs.h"

View File

@ -160,7 +160,7 @@ void recv_init (struct audio_s *pa)
#endif #endif
#if __WIN32__ #if __WIN32__
xmit_th[a] = (HANDLE)_beginthreadex (NULL, 0, recv_adev_thread, (void*)(long)a, 0, NULL); xmit_th[a] = (HANDLE)_beginthreadex (NULL, 0, recv_adev_thread, (void*)(ptrdiff_t)a, 0, NULL);
if (xmit_th[a] == NULL) { if (xmit_th[a] == NULL) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("FATAL: Could not create audio receive thread for device %d.\n", a); dw_printf ("FATAL: Could not create audio receive thread for device %d.\n", a);
@ -168,7 +168,7 @@ void recv_init (struct audio_s *pa)
} }
#else #else
int e; int e;
e = pthread_create (&xmit_tid[a], NULL, recv_adev_thread, (void *)(long)a); e = pthread_create (&xmit_tid[a], NULL, recv_adev_thread, (void *)(ptrdiff_t)a);
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
@ -203,7 +203,7 @@ static unsigned __stdcall recv_adev_thread (void *arg)
static void * recv_adev_thread (void *arg) static void * recv_adev_thread (void *arg)
#endif #endif
{ {
int a = (int)(long)arg; // audio device number. int a = (int)(ptrdiff_t)arg; // audio device number.
int eof; int eof;
/* This audio device can have one (mono) or two (stereo) channels. */ /* This audio device can have one (mono) or two (stereo) channels. */

View File

@ -461,14 +461,14 @@ void server_init (struct audio_s *audio_config_p, struct misc_config_s *mc)
* This waits for a client to connect and sets an available client_sock[n]. * This waits for a client to connect and sets an available client_sock[n].
*/ */
#if __WIN32__ #if __WIN32__
connect_listen_th = (HANDLE)_beginthreadex (NULL, 0, connect_listen_thread, (void *)(unsigned int)server_port, 0, NULL); connect_listen_th = (HANDLE)_beginthreadex (NULL, 0, connect_listen_thread, (void *)(ptrdiff_t)server_port, 0, NULL);
if (connect_listen_th == NULL) { if (connect_listen_th == NULL) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Could not create AGW connect listening thread\n"); dw_printf ("Could not create AGW connect listening thread\n");
return; return;
} }
#else #else
e = pthread_create (&connect_listen_tid, NULL, connect_listen_thread, (void *)(long)server_port); e = pthread_create (&connect_listen_tid, NULL, connect_listen_thread, (void *)(ptrdiff_t)server_port);
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
perror("Could not create AGW connect listening thread"); perror("Could not create AGW connect listening thread");
@ -484,14 +484,14 @@ void server_init (struct audio_s *audio_config_p, struct misc_config_s *mc)
for (client = 0; client < MAX_NET_CLIENTS; client++) { for (client = 0; client < MAX_NET_CLIENTS; client++) {
#if __WIN32__ #if __WIN32__
cmd_listen_th[client] = (HANDLE)_beginthreadex (NULL, 0, cmd_listen_thread, (void*)client, 0, NULL); cmd_listen_th[client] = (HANDLE)_beginthreadex (NULL, 0, cmd_listen_thread, (void*)(ptrdiff_t)client, 0, NULL);
if (cmd_listen_th[client] == NULL) { if (cmd_listen_th[client] == NULL) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Could not create AGW command listening thread for client %d\n", client); dw_printf ("Could not create AGW command listening thread for client %d\n", client);
return; return;
} }
#else #else
e = pthread_create (&cmd_listen_tid[client], NULL, cmd_listen_thread, (void *)(long)client); e = pthread_create (&cmd_listen_tid[client], NULL, cmd_listen_thread, (void *)(ptrdiff_t)client);
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Could not create AGW command listening thread for client %d\n", client); dw_printf ("Could not create AGW command listening thread for client %d\n", client);
@ -535,10 +535,10 @@ static THREAD_F connect_listen_thread (void *arg)
SOCKET listen_sock; SOCKET listen_sock;
WSADATA wsadata; WSADATA wsadata;
snprintf (server_port_str, sizeof(server_port_str), "%d", (int)(long)arg); snprintf (server_port_str, sizeof(server_port_str), "%d", (int)(ptrdiff_t)arg);
#if DEBUG #if DEBUG
text_color_set(DW_COLOR_DEBUG); text_color_set(DW_COLOR_DEBUG);
dw_printf ("DEBUG: serverport = %d = '%s'\n", (int)(long)arg, server_port_str); dw_printf ("DEBUG: serverport = %d = '%s'\n", (int)(ptrdiff_t)arg, server_port_str);
#endif #endif
err = WSAStartup (MAKEWORD(2,2), &wsadata); err = WSAStartup (MAKEWORD(2,2), &wsadata);
if (err != 0) { if (err != 0) {
@ -658,7 +658,7 @@ static THREAD_F connect_listen_thread (void *arg)
struct sockaddr_in sockaddr; /* Internet socket address stuct */ struct sockaddr_in sockaddr; /* Internet socket address stuct */
socklen_t sockaddr_size = sizeof(struct sockaddr_in); socklen_t sockaddr_size = sizeof(struct sockaddr_in);
int server_port = (int)(long)arg; int server_port = (int)(ptrdiff_t)arg;
int listen_sock; int listen_sock;
int bcopt = 1; int bcopt = 1;
@ -1265,7 +1265,7 @@ static THREAD_F cmd_listen_thread (void *arg)
/* Maximum for 'D': Info part length + 1 */ /* Maximum for 'D': Info part length + 1 */
} cmd; } cmd;
int client = (int)(long)arg; int client = (int)(ptrdiff_t)arg;
assert (client >= 0 && client < MAX_NET_CLIENTS); assert (client >= 0 && client < MAX_NET_CLIENTS);

View File

@ -279,7 +279,7 @@ void xmit_init (struct audio_s *p_modem, int debug_xmit_packet)
if (p_modem->achan[j].medium == MEDIUM_RADIO) { if (p_modem->achan[j].medium == MEDIUM_RADIO) {
#if __WIN32__ #if __WIN32__
xmit_th[j] = (HANDLE)_beginthreadex (NULL, 0, xmit_thread, (void*)(long)j, 0, NULL); xmit_th[j] = (HANDLE)_beginthreadex (NULL, 0, xmit_thread, (void*)(ptrdiff_t)j, 0, NULL);
if (xmit_th[j] == NULL) { if (xmit_th[j] == NULL) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Could not create xmit thread %d\n", j); dw_printf ("Could not create xmit thread %d\n", j);
@ -310,10 +310,10 @@ void xmit_init (struct audio_s *p_modem, int debug_xmit_packet)
perror("pthread_attr_setschedparam"); perror("pthread_attr_setschedparam");
} }
e = pthread_create (&(xmit_tid[j]), &attr, xmit_thread, (void *)(long)j); e = pthread_create (&(xmit_tid[j]), &attr, xmit_thread, (void *)(ptrdiff_t)j);
pthread_attr_destroy (&attr); pthread_attr_destroy (&attr);
#else #else
e = pthread_create (&(xmit_tid[j]), NULL, xmit_thread, (void *)(long)j); e = pthread_create (&(xmit_tid[j]), NULL, xmit_thread, (void *)(ptrdiff_t)j);
#endif #endif
if (e != 0) { if (e != 0) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
@ -510,7 +510,7 @@ static unsigned __stdcall xmit_thread (void *arg)
static void * xmit_thread (void *arg) static void * xmit_thread (void *arg)
#endif #endif
{ {
int chan = (int)(long)arg; // channel number. int chan = (int)(ptrdiff_t)arg; // channel number.
packet_t pp; packet_t pp;
int prio; int prio;
int ok; int ok;