Skip to content

Commit

Permalink
C90-style declarations, BSD compatm, and TLS-specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Jan 9, 2025
1 parent f6e8ddf commit a8d6e3e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions include/redisx-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ int rClusterRefresh(RedisCluster *cluster);
uint16_t rCalcHash(const char *key);

// in redisx-tls.c ------------------------>
#if WITH_TLS
void rClearTLSConfig(TLSConfig *tls);
#endif

// in resp.c ------------------------------>
int redisxAppendRESP(RESP *resp, RESP *part);
Expand Down
2 changes: 1 addition & 1 deletion src/redisx-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ RedisClient *redisxGetClient(Redis *redis, enum redisx_channel channel) {

p = (RedisPrivate *) redis->priv;
if(channel < 0 || channel >= REDISX_CHANNELS) {
x_error(0, ECHRNG, fn, "channel %d is our of range", channel);
x_error(0, EINVAL, fn, "channel %d is our of range", channel);
return NULL;
}
return &p->clients[channel];
Expand Down
3 changes: 2 additions & 1 deletion src/redisx-cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@ static void rClusterSetShardsAsync(RedisCluster *cluster, RedisShard *shard, int
static void *ClusterRefreshThread(void *pCluster) {
RedisCluster *cluster = (RedisCluster *) pCluster;
ClusterPrivate *p = (ClusterPrivate *) cluster->priv;
int i;

for(int i = 0; i < p->n_shards; i++) {
for(i = 0; i < p->n_shards; i++) {
const RedisShard *s = &p->shard[i];
int m;

Expand Down
3 changes: 2 additions & 1 deletion src/redisx-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
#include <errno.h>
#include <pthread.h>
#include <sys/utsname.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#if __Lynx__
# include <socket.h>
# include <time.h>
#else
#include <sys/time.h>
# include <netinet/ip.h>
# include <sys/socket.h>
# include <fnmatch.h>
Expand Down
2 changes: 1 addition & 1 deletion src/redisx-sentinel.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int rConfirmMasterRole(Redis *redis) {

if(reply->n < 1) {
redisxDestroyRESP(reply);
return x_error(X_FAILURE, EBADE, fn, "Got empty array response");
return x_error(X_FAILURE, EBADMSG, fn, "Got empty array response");
}

component = (RESP **) reply->value;
Expand Down
2 changes: 2 additions & 0 deletions src/redisx-tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

static int initialized = FALSE;

#if WITH_TLS
/**
* Clear TLS configuration settings, freeing resources used.
*
Expand Down Expand Up @@ -61,6 +62,7 @@ void rDestroyClientTLS(ClientPrivate *cp) {
cp->ctx = NULL;
}
}
#endif

/**
* Loads parameters from a file for DH-based ciphers.
Expand Down
8 changes: 6 additions & 2 deletions src/redisx.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ int redisxCheckValid(const Redis *redis) {
*
*/
int rConfigLock(Redis *redis) {
RedisPrivate *p;
prop_error("rConfigLock", redisxCheckValid(redis));
RedisPrivate *p = (RedisPrivate *) redis->priv;
p = (RedisPrivate *) redis->priv;
pthread_mutex_lock(&p->configLock);
return X_SUCCESS;
}
Expand All @@ -74,8 +75,9 @@ int rConfigLock(Redis *redis) {
*
*/
int rConfigUnlock(Redis *redis) {
RedisPrivate *p;
prop_error("rConfigUnlock", redisxCheckValid(redis));
RedisPrivate *p = (RedisPrivate *) redis->priv;
p = (RedisPrivate *) redis->priv;
pthread_mutex_unlock(&p->configLock);
return X_SUCCESS;
}
Expand Down Expand Up @@ -612,7 +614,9 @@ void rClearConfig(RedisConfig *config) {
rClearHooks(config->firstConnectCall);
rClearHooks(config->firstCleanupCall);

#if WITH_TLS
rClearTLSConfig(&config->tls);
#endif

memset(config, 0, sizeof(*config));
}
Expand Down

0 comments on commit a8d6e3e

Please sign in to comment.