Skip to content

Commit

Permalink
Fix Hiredis warnings
Browse files Browse the repository at this point in the history
The original Hiredis source files cause a few warnings when imported
into the Webdis code base. This commit is a combination of changes from
two previous commits that were applied to the Hiredis source files
during the last dependency upgrade.

1. From 05f168f: avoid _POSIX_C_SOURCE warnings in hiredis
2. From fc67109: Add back __UNUSED_FUNCTION__ in dict.c
  • Loading branch information
nicolasff committed Aug 26, 2023
1 parent 34859f3 commit 7d7d3f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/hiredis/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
#include <limits.h>
#include "dict.h"

#ifdef __GNUC__
#define __UNUSED_FUNCTION__ __attribute__ ((unused))
#else
#define __UNUSED_FUNCTION__
#endif

/* -------------------------- private prototypes ---------------------------- */

static int _dictExpandIfNeeded(dict *ht);
Expand All @@ -51,6 +57,7 @@ static int _dictInit(dict *ht, dictType *type, void *privDataPtr);

/* Generic hash function (a popular one from Bernstein).
* I tested a few and this was the best. */
__UNUSED_FUNCTION__
static unsigned int dictGenHashFunction(const unsigned char *buf, int len) {
unsigned int hash = 5381;

Expand All @@ -71,6 +78,7 @@ static void _dictReset(dict *ht) {
}

/* Create a new hash table */
__UNUSED_FUNCTION__
static dict *dictCreate(dictType *type, void *privDataPtr) {
dict *ht = hi_malloc(sizeof(*ht));
if (ht == NULL)
Expand Down Expand Up @@ -166,6 +174,7 @@ static int dictAdd(dict *ht, void *key, void *val) {
* Return 1 if the key was added from scratch, 0 if there was already an
* element with such key and dictReplace() just performed a value update
* operation. */
__UNUSED_FUNCTION__
static int dictReplace(dict *ht, void *key, void *val) {
dictEntry *entry, auxentry;

Expand All @@ -191,6 +200,7 @@ static int dictReplace(dict *ht, void *key, void *val) {
}

/* Search and remove an element */
__UNUSED_FUNCTION__
static int dictDelete(dict *ht, const void *key) {
unsigned int h;
dictEntry *de, *prevde;
Expand Down Expand Up @@ -247,6 +257,7 @@ static int _dictClear(dict *ht) {
}

/* Clear & Release the hash table */
__UNUSED_FUNCTION__
static void dictRelease(dict *ht) {
_dictClear(ht);
hi_free(ht);
Expand All @@ -267,13 +278,15 @@ static dictEntry *dictFind(dict *ht, const void *key) {
return NULL;
}

__UNUSED_FUNCTION__
static void dictInitIterator(dictIterator *iter, dict *ht) {
iter->ht = ht;
iter->index = -1;
iter->entry = NULL;
iter->nextEntry = NULL;
}

__UNUSED_FUNCTION__
static dictEntry *dictNext(dictIterator *iter) {
while (1) {
if (iter->entry == NULL) {
Expand Down
2 changes: 2 additions & 0 deletions src/hiredis/fmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

#ifndef _AIX
#define _XOPEN_SOURCE 600
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#endif
#endif

#if defined(__APPLE__) && defined(__MACH__)
/* Enable TCP_KEEPALIVE */
Expand Down

0 comments on commit 7d7d3f7

Please sign in to comment.