Skip to content

Commit

Permalink
Fixing formatting issues as per Clang-format output
Browse files Browse the repository at this point in the history
Signed-off-by: Parth Patel <[email protected]>
  • Loading branch information
parthpatel committed Nov 11, 2024
1 parent 0941aec commit a92d636
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
6 changes: 3 additions & 3 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,11 @@ void debugCommand(client *c) {
}
} else if (!strcasecmp(c->argv[1]->ptr, "sleep") && c->argc == 3) {
double dtime;
#ifdef USE_FAST_FLOAT
#ifdef USE_FAST_FLOAT
fast_float_strtod(c->argv[2]->ptr, &dtime);
#else
#else
dtime = strtod(c->argv[2]->ptr, NULL);
#endif
#endif
long long utime = dtime * 1000000;
struct timespec tv;

Expand Down
6 changes: 3 additions & 3 deletions src/resp_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ static int parseDouble(ReplyParser *parser, void *p_ctx) {
if (len <= MAX_LONG_DOUBLE_CHARS) {
memcpy(buf, proto + 1, len);
buf[len] = '\0';
#ifdef USE_FAST_FLOAT
#ifdef USE_FAST_FLOAT
fast_float_strtod(buf, &d);
#else
#else
d = strtod(buf, NULL); /* We expect a valid representation. */
#endif
#endif
}
parser->callbacks.double_callback(p_ctx, d, proto, parser->curr_location - proto);
return C_OK;
Expand Down
4 changes: 2 additions & 2 deletions src/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ void sortCommandGeneric(client *c, int readonly) {
if (sdsEncodedObject(byval)) {
char *eptr;
#ifdef USE_FAST_FLOAT
errno = 0;
errno = 0;
eptr = fast_float_strtod(byval->ptr, &(vector[j].u.score));
#else
#else
vector[j].u.score = strtod(byval->ptr, &eptr);
#endif
if (eptr[0] != '\0' || errno == ERANGE || errno == EINVAL || isnan(vector[j].u.score)) {
Expand Down
18 changes: 9 additions & 9 deletions src/t_zset.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
#include "intset.h" /* Compact integer set structure */
#include <math.h>

#ifdef USE_FAST_FLOAT
#ifdef USE_FAST_FLOAT
#include "../deps/fast_float/fast_float_strtod.h"
#endif
#endif

/*-----------------------------------------------------------------------------
* Skiplist implementation of the low level API
Expand Down Expand Up @@ -552,17 +552,17 @@ static int zslParseRange(robj *min, robj *max, zrangespec *spec) {
if (((char *)min->ptr)[0] == '(') {
#ifdef USE_FAST_FLOAT
eptr = fast_float_strtod((char *)min->ptr + 1, &(spec->min));
#else
#else
spec->min = strtod((char *)min->ptr + 1, &eptr);
#endif
if (eptr[0] != '\0' || isnan(spec->min)) return C_ERR;
spec->minex = 1;
} else {
#ifdef USE_FAST_FLOAT
eptr = fast_float_strtod((char *)min->ptr, &(spec->min));
#else
#else
spec->min = strtod((char *)min->ptr, &eptr);
#endif
#endif
if (eptr[0] != '\0' || isnan(spec->min)) return C_ERR;
}
}
Expand All @@ -572,15 +572,15 @@ static int zslParseRange(robj *min, robj *max, zrangespec *spec) {
if (((char *)max->ptr)[0] == '(') {
#ifdef USE_FAST_FLOAT
eptr = fast_float_strtod((char *)max->ptr + 1, &(spec->max));
#else
#else
spec->max = strtod((char *)max->ptr + 1, &eptr);
#endif
#endif
if (eptr[0] != '\0' || isnan(spec->max)) return C_ERR;
spec->maxex = 1;
} else {
#ifdef USE_FAST_FLOAT
eptr = fast_float_strtod((char *)max->ptr, &(spec->max));
#else
#else
spec->max = strtod((char *)max->ptr, &eptr);
#endif
if (eptr[0] != '\0' || isnan(spec->max)) return C_ERR;
Expand Down Expand Up @@ -778,7 +778,7 @@ double zzlStrtod(unsigned char *vstr, unsigned int vlen) {
memcpy(buf, vstr, vlen);
buf[vlen] = '\0';
#ifdef USE_FAST_FLOAT
double d;
double d;
fast_float_strtod(buf, &d);
return d;
#else
Expand Down
11 changes: 5 additions & 6 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
#include "sha256.h"
#include "config.h"

#ifdef USE_FAST_FLOAT
#ifdef USE_FAST_FLOAT
#include "../deps/fast_float/fast_float_strtod.h"
#endif
#endif

#define UNUSED(x) ((void)(x))

Expand Down Expand Up @@ -600,13 +600,12 @@ int string2d(const char *s, size_t slen, double *dp) {
errno = 0;
#ifdef USE_FAST_FLOAT
const char *eptr = fast_float_strtod(s, dp);
#else
char *eptr;
#else
char *eptr;
*dp = strtod(s, &eptr);
#endif
if (slen == 0 || isspace(((const char *)s)[0]) || (size_t)(eptr - (char *)s) != slen ||
(errno == ERANGE && (*dp == HUGE_VAL || *dp == -HUGE_VAL || fpclassify(*dp) == FP_ZERO))
|| isnan(*dp) || errno == EINVAL) {
(errno == ERANGE && (*dp == HUGE_VAL || *dp == -HUGE_VAL || fpclassify(*dp) == FP_ZERO)) || isnan(*dp) || errno == EINVAL) {
fprintf(stderr, "UNIQUE %s %d", s, errno);
errno = 0;
return 0;
Expand Down
8 changes: 4 additions & 4 deletions src/valkey-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
#include "mt19937-64.h"
#include "cli_commands.h"

#ifdef USE_FAST_FLOAt
#ifdef USE_FAST_FLOAT
#include "../deps/fast_float/fast_float_strtod.h"
#endif
#endif

#define UNUSED(V) ((void)V)

Expand Down Expand Up @@ -2545,12 +2545,12 @@ static int parseOptions(int argc, char **argv) {
exit(1);
}
} else if (!strcmp(argv[i], "-t") && !lastarg) {
double seconds;
double seconds;
errno = 0;
#ifdef USE_FAST_FLOAT
const char *eptr = fast_float_strtod(argv[++i], &seconds);
#else
char *eptr;
char *eptr;
seconds = strtod(argv[++i], &eptr);
#endif
if (eptr[0] != '\0' || isnan(seconds) || seconds < 0.0 || errno == EINVAL || errno == ERANGE) {
Expand Down

0 comments on commit a92d636

Please sign in to comment.