less compiler warnings
This commit is contained in:
+1
-1
@@ -257,7 +257,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state)
|
||||
opt->foreground = true;
|
||||
break;
|
||||
case 'p': // --port=8888
|
||||
opt->port = parseInt(arg, 10, 1, 65535, result);
|
||||
opt->port = (uint16_t)parseInt(arg, 10, 1, 65535, result);
|
||||
if (result != RESULT_OK) {
|
||||
argp_error(state, "invalid port");
|
||||
return EINVAL;
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@
|
||||
#include "result.h"
|
||||
#include "data.h"
|
||||
#include "message.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/** \file main.h */
|
||||
|
||||
@@ -46,7 +47,7 @@ struct options
|
||||
bool generateSyn; //!< enable AUTO-SYN symbol generation
|
||||
|
||||
bool foreground; //!< run in foreground
|
||||
int port; //!< port to listen for client connections [8888]
|
||||
uint16_t port; //!< port to listen for client connections [8888]
|
||||
bool localOnly; //!< listen on 127.0.0.1 interface only
|
||||
|
||||
const char* logFile; //!< log file name [/var/log/ebusd.log]
|
||||
|
||||
@@ -151,7 +151,7 @@ void Connection::run()
|
||||
}
|
||||
|
||||
|
||||
Network::Network(const bool local, const int port, WQueue<NetMessage*>* netQueue)
|
||||
Network::Network(const bool local, const uint16_t port, WQueue<NetMessage*>* netQueue)
|
||||
: m_netQueue(netQueue), m_listening(false)
|
||||
{
|
||||
if (local)
|
||||
|
||||
+1
-1
@@ -220,7 +220,7 @@ public:
|
||||
* @param port the tcp port to listening.
|
||||
* @param netQueue the remote queue for network messages.
|
||||
*/
|
||||
Network(const bool local, const int port, WQueue<NetMessage*>* netQueue);
|
||||
Network(const bool local, const uint16_t port, WQueue<NetMessage*>* netQueue);
|
||||
|
||||
/**
|
||||
* destructor.
|
||||
|
||||
@@ -67,7 +67,7 @@ Device* Device::create(const char* name, const bool checkDevice,
|
||||
}
|
||||
free(host);
|
||||
address.sin_family = AF_INET;
|
||||
address.sin_port = htons(port);
|
||||
address.sin_port = htons((uint16_t)port);
|
||||
return new NetworkDevice(name, address, logRawFunc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ bool TCPSocket::isValid()
|
||||
}
|
||||
|
||||
|
||||
TCPSocket* TCPClient::connect(const string& server, const int& port)
|
||||
TCPSocket* TCPClient::connect(const string& server, const uint16_t& port)
|
||||
{
|
||||
struct sockaddr_in address;
|
||||
int ret;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
/** \file tcpsocket.h */
|
||||
|
||||
@@ -67,7 +68,7 @@ public:
|
||||
* returns the tcp port.
|
||||
* @return the tcp port.
|
||||
*/
|
||||
int getPort() const { return m_port; }
|
||||
uint16_t getPort() const { return m_port; }
|
||||
|
||||
/**
|
||||
* returns the ip address.
|
||||
@@ -92,7 +93,7 @@ private:
|
||||
int m_sfd;
|
||||
|
||||
/** port of tcp socket */
|
||||
int m_port;
|
||||
uint16_t m_port;
|
||||
|
||||
/** ip address of tcp socket */
|
||||
string m_ip;
|
||||
@@ -119,7 +120,7 @@ public:
|
||||
* @param port the tcp port.
|
||||
* @return pointer to an opened tcp socket.
|
||||
*/
|
||||
TCPSocket* connect(const string& server, const int& port);
|
||||
TCPSocket* connect(const string& server, const uint16_t& port);
|
||||
|
||||
};
|
||||
|
||||
@@ -135,7 +136,7 @@ public:
|
||||
* @param port the tcp port.
|
||||
* @param address the ip address.
|
||||
*/
|
||||
TCPServer(const int port, const string address)
|
||||
TCPServer(const uint16_t port, const string address)
|
||||
: m_lfd(0), m_port(port), m_address(address), m_listening(false) {}
|
||||
|
||||
/**
|
||||
@@ -166,7 +167,7 @@ private:
|
||||
int m_lfd;
|
||||
|
||||
/** listening tcp port */
|
||||
int m_port;
|
||||
uint16_t m_port;
|
||||
|
||||
/** listening tcp socket ip address */
|
||||
string m_address;
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace std;
|
||||
struct options
|
||||
{
|
||||
const char* server; //!< ebusd server host (name or ip) [localhost]
|
||||
unsigned int port; //!< ebusd server port [8888]
|
||||
uint16_t port; //!< ebusd server port [8888]
|
||||
|
||||
char* const *args; //!< arguments to pass to ebusd
|
||||
unsigned int argCount; //!< number of arguments to pass to ebusd
|
||||
@@ -90,6 +90,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state)
|
||||
{
|
||||
struct options *opt = (struct options*)state->input;
|
||||
char* strEnd = NULL;
|
||||
unsigned int port;
|
||||
switch (key) {
|
||||
// Device settings:
|
||||
case 's': // --server=localhost
|
||||
@@ -100,11 +101,12 @@ error_t parse_opt(int key, char *arg, struct argp_state *state)
|
||||
opt->server = arg;
|
||||
break;
|
||||
case 'p': // --port=8888
|
||||
opt->port = (unsigned int)strtoul(arg, &strEnd, 10);
|
||||
if (strEnd == NULL || *strEnd != 0 || opt->port < 1 || opt->port > 65535) {
|
||||
port = strtoul(arg, &strEnd, 10);
|
||||
if (strEnd == NULL || *strEnd != 0 || port < 1 || port > 65535) {
|
||||
argp_error(state, "invalid port");
|
||||
return EINVAL;
|
||||
}
|
||||
opt->port = (uint16_t)port;
|
||||
break;
|
||||
case ARGP_KEY_ARGS:
|
||||
opt->args = state->argv + state->next;
|
||||
@@ -230,7 +232,7 @@ string fetchData(TCPSocket* socket, bool& listening)
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void connect(const char* host, int port, char* const *args, int argCount)
|
||||
void connect(const char* host, uint16_t port, char* const *args, int argCount)
|
||||
{
|
||||
|
||||
TCPClient* client = new TCPClient();
|
||||
|
||||
Reference in New Issue
Block a user