Skip to content

Commit

Permalink
silence STDC warnings in on windows, fix file descriptor type.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Mar 22, 2022
1 parent 180a09e commit 2ef1518
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* turn of windows warnings for _strcmp etc. */
#define _CRT_NONSTDC_NO_DEPRECATE

#include "fmacros.h"
#include "sockcompat.h"
#include <stdio.h>
Expand Down Expand Up @@ -173,7 +176,7 @@ static void send_client_tracking(redisContext *c, const char *str) {
freeReplyObject(reply);
}

static int disconnect(redisContext *c, int keep_fd) {
static redisFD disconnect(redisContext *c, int keep_fd) {
redisReply *reply;

/* Make sure we're on DB 9. */
Expand All @@ -186,9 +189,9 @@ static int disconnect(redisContext *c, int keep_fd) {

/* Free the context as well, but keep the fd if requested. */
if (keep_fd)
return redisFreeKeepFd(c);
return (int)redisFreeKeepFd(c);
redisFree(c);
return -1;
return REDIS_INVALID_FD;
}

static void do_ssl_handshake(redisContext *c) {
Expand Down Expand Up @@ -217,8 +220,8 @@ static redisContext *do_connect(struct config config) {
/* Create a dummy connection just to get an fd to inherit */
redisContext *dummy_ctx = redisConnectUnix(config.unix_sock.path);
if (dummy_ctx) {
int fd = disconnect(dummy_ctx, 1);
printf("Connecting to inherited fd %d\n", fd);
redisFD fd = disconnect(dummy_ctx, 1);
printf("Connecting to inherited fd %d\n", (int)fd);
c = redisConnectFd(fd);
}
} else {
Expand Down

0 comments on commit 2ef1518

Please sign in to comment.