Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed int to uint16_t for port variables #1436

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/apps/common/hiredis_libevent2.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct redisLibeventEvents {
struct event *rev, *wev;
int rev_set, wev_set;
char *ip;
int port;
uint16_t port;
char *pwd;
int db;
};
Expand Down Expand Up @@ -213,7 +213,7 @@ void send_message_to_redis(redis_context_handle rch, const char *command, const

///////////////////////// Attach /////////////////////////////////

redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, int db) {
redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, uint16_t port0, char *pwd, int db) {

struct redisLibeventEvents *e = NULL;
redisAsyncContext *ac = NULL;
Expand All @@ -225,7 +225,7 @@ redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int
strncpy(ip, "127.0.0.1", sizeof(ip));
}

int port = DEFAULT_REDIS_PORT;
uint16_t port = DEFAULT_REDIS_PORT;
if (port0 > 0) {
port = port0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/common/hiredis_libevent2.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef void *redis_context_handle;

#if !defined(TURN_NO_HIREDIS)

redis_context_handle redisLibeventAttach(struct event_base *base, char *ip, int port, char *pwd, int db);
redis_context_handle redisLibeventAttach(struct event_base *base, char *ip, uint16_t port, char *pwd, int db);

void send_message_to_redis(redis_context_handle rch, const char *command, const char *key, const char *format, ...);

Expand Down
14 changes: 7 additions & 7 deletions src/apps/relay/dbdrivers/dbd_redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct _Ryconninfo {
char *dbname;
char *password;
unsigned int connect_timeout;
unsigned int port;
uint16_t port;
};

typedef struct _Ryconninfo Ryconninfo;
Expand Down Expand Up @@ -134,9 +134,9 @@ static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
} else if (!strcmp(s, "secret")) {
co->password = strdup(seq + 1);
} else if (!strcmp(s, "port")) {
co->port = (unsigned int)atoi(seq + 1);
co->port = atoi(seq + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you need a cast to uint16_t to avoid the compiler warning about precision loss?

} else if (!strcmp(s, "p")) {
co->port = (unsigned int)atoi(seq + 1);
co->port = atoi(seq + 1);
} else if (!strcmp(s, "connect_timeout")) {
co->connect_timeout = (unsigned int)atoi(seq + 1);
} else if (!strcmp(s, "timeout")) {
Expand Down Expand Up @@ -201,7 +201,7 @@ redis_context_handle get_redis_async_connection(struct event_base *base, redis_s
redisContext *rc = NULL;

char ip[256] = "\0";
int port = DEFAULT_REDIS_PORT;
uint16_t port = DEFAULT_REDIS_PORT;
if (co->host) {
STRCPY(ip, co->host);
}
Expand All @@ -210,7 +210,7 @@ redis_context_handle get_redis_async_connection(struct event_base *base, redis_s
}

if (co->port) {
port = (int)(co->port);
port = (co->port);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parenthesis aren't needed here anymore.

}

if (co->connect_timeout) {
Expand Down Expand Up @@ -320,7 +320,7 @@ static redisContext *get_redis_connection(void) {
RyconninfoFree(co);
} else {
char ip[256] = "\0";
int port = DEFAULT_REDIS_PORT;
uint16_t port = DEFAULT_REDIS_PORT;
if (co->host) {
STRCPY(ip, co->host);
}
Expand All @@ -329,7 +329,7 @@ static redisContext *get_redis_connection(void) {
}

if (co->port) {
port = (int)(co->port);
port = (co->port);
}

if (co->connect_timeout) {
Expand Down