Skip to content
Snippets Groups Projects
Commit d1c8606c authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Log an error if calls to send() don't return the expected value

This addresses GCC warnings about not using the return value of send().
parent 08ab80e5
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
Pipeline #6460 failed
...@@ -957,6 +957,13 @@ char* chr(BYTE ch, char* str, size_t size) ...@@ -957,6 +957,13 @@ char* chr(BYTE ch, char* str, size_t size)
return str; return str;
} }
void sendbuf(SOCKET sock, void* buf, int len)
{
int wr = sendsocket(sock, buf, len);
if (wr != len)
lprintf(LOG_ERR, "!send returned %d instead of %d", wr, len);
}
/****************************************************************************/ /****************************************************************************/
/****************************************************************************/ /****************************************************************************/
void input_thread(void* arg) void input_thread(void* arg)
...@@ -973,8 +980,8 @@ void input_thread(void* arg) ...@@ -973,8 +980,8 @@ void input_thread(void* arg)
if(com_debug) if(com_debug)
lprintf(LOG_DEBUG, "Received char from COM port (%s): %s", com_dev, chr(ch, dbg, sizeof(dbg))); lprintf(LOG_DEBUG, "Received char from COM port (%s): %s", com_dev, chr(ch, dbg, sizeof(dbg)));
if(telnet && ch==TELNET_IAC) if(telnet && ch==TELNET_IAC)
sendsocket(sock, &ch, sizeof(ch)); /* escape Telnet IAC char (255) when in telnet mode */ sendbuf(sock, &ch, sizeof(ch)); /* escape Telnet IAC char (255) when in telnet mode */
sendsocket(sock, &ch, sizeof(ch)); sendbuf(sock, &ch, sizeof(ch));
bytes_received++; bytes_received++;
} }
lprintf(LOG_DEBUG,"Input thread terminated"); lprintf(LOG_DEBUG,"Input thread terminated");
...@@ -1061,7 +1068,7 @@ void ident_server_thread(void* arg) ...@@ -1061,7 +1068,7 @@ void ident_server_thread(void* arg)
/* example response: "40931,23:USERID:UNIX:cyan" */ /* example response: "40931,23:USERID:UNIX:cyan" */
SAFEPRINTF4(response,"%s:%s:%s %s\r\n" SAFEPRINTF4(response,"%s:%s:%s %s\r\n"
,request, ident_response, cid_number, cid_name); ,request, ident_response, cid_number, cid_name);
sendsocket(client_socket,response,strlen(response)); sendbuf(client_socket,response,strlen(response));
} else } else
lprintf(LOG_DEBUG,"ident recv=%d %d", rd, ERROR_VALUE); lprintf(LOG_DEBUG,"ident recv=%d %d", rd, ERROR_VALUE);
} }
...@@ -1083,13 +1090,13 @@ static void send_telnet_cmd(uchar cmd, uchar opt) ...@@ -1083,13 +1090,13 @@ static void send_telnet_cmd(uchar cmd, uchar opt)
lprintf(LOG_INFO,"TX Telnet command: %s" lprintf(LOG_INFO,"TX Telnet command: %s"
,telnet_cmd_desc(cmd)); ,telnet_cmd_desc(cmd));
sprintf(buf,"%c%c",TELNET_IAC,cmd); sprintf(buf,"%c%c",TELNET_IAC,cmd);
sendsocket(sock,buf,2); sendbuf(sock,buf,2);
} else { } else {
if(debug_telnet) if(debug_telnet)
lprintf(LOG_INFO,"TX Telnet command: %s %s" lprintf(LOG_INFO,"TX Telnet command: %s %s"
,telnet_cmd_desc(cmd), telnet_opt_desc(opt)); ,telnet_cmd_desc(cmd), telnet_opt_desc(opt));
sprintf(buf,"%c%c%c",TELNET_IAC,cmd,opt); sprintf(buf,"%c%c%c",TELNET_IAC,cmd,opt);
sendsocket(sock,buf,3); sendbuf(sock,buf,3);
} }
} }
...@@ -1164,7 +1171,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen) ...@@ -1164,7 +1171,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen)
,TELNET_IAC,TELNET_SE); ,TELNET_IAC,TELNET_SE);
if(debug_telnet) if(debug_telnet)
lprintf(LOG_INFO,"TX Telnet command: Terminal Type is %s", termtype); lprintf(LOG_INFO,"TX Telnet command: Terminal Type is %s", termtype);
sendsocket(sock,buf,len); sendbuf(sock,buf,len);
/* request_telnet_opt(TELNET_WILL, TELNET_TERM_SPEED); */ /* request_telnet_opt(TELNET_WILL, TELNET_TERM_SPEED); */
} else if(option==TELNET_TERM_SPEED && telnet_cmd[3]==TELNET_TERM_SEND) { } else if(option==TELNET_TERM_SPEED && telnet_cmd[3]==TELNET_TERM_SEND) {
char buf[sizeof(termspeed) + 32]; char buf[sizeof(termspeed) + 32];
...@@ -1175,7 +1182,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen) ...@@ -1175,7 +1182,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen)
,TELNET_IAC,TELNET_SE); ,TELNET_IAC,TELNET_SE);
if(debug_telnet) if(debug_telnet)
lprintf(LOG_INFO,"TX Telnet command: Terminal Speed is %s", termspeed); lprintf(LOG_INFO,"TX Telnet command: Terminal Speed is %s", termspeed);
sendsocket(sock,buf,len); sendbuf(sock,buf,len);
} }
telnet_cmdlen=0; telnet_cmdlen=0;
...@@ -1211,7 +1218,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen) ...@@ -1211,7 +1218,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen)
,TELNET_IAC,TELNET_SE); ,TELNET_IAC,TELNET_SE);
if(debug_telnet) if(debug_telnet)
lprintf(LOG_INFO,"TX Telnet command: Location is %s %s", cid_number, cid_name); lprintf(LOG_INFO,"TX Telnet command: Location is %s %s", cid_number, cid_name);
sendsocket(sock,buf,len); sendbuf(sock,buf,len);
} else } else
send_telnet_cmd(telnet_opt_ack(command),option); send_telnet_cmd(telnet_opt_ack(command),option);
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment