Repository: valkey-io/valkey
File: src/cli_common.c (C)

Code before:
        default: s = sdscatprintf(s, *(unsigned char *)p <= 0x1f ? "\\u%04x" : "%c", *p);
        }
        p++;
    }
    return sdscatlen(s, "\"", 1);
}

sds cliVersion(void) {
    sds version = sdscatprintf(sdsempty(), "%s", VALKEY_VERSION);

    /* Add git commit and working tree status when available. */
    if (strtoll(serverGitSHA1(), NULL, 16)) {
        version = sdscatprintf(version, " (git:%s", serverGitSHA1());
        if (strtoll(serverGitDirty(), NULL, 10)) version = sdscatprintf(version, "-dirty");
        version = sdscat(version, ")");
    }
    return version;
}

/* This is a wrapper to call valkeyConnect or valkeyConnectWithTimeout. */
valkeyContext *valkeyConnectWrapper(const char *ip, int port, const struct timeval tv, int nonblock, int rdma) {
    valkeyOptions options = {0};
    if (rdma) {
#ifdef USE_RDMA
        VALKEY_OPTIONS_SET_RDMA(&options, ip, port);
#endif
    } else {
        VALKEY_OPTIONS_SET_TCP(&options, ip, port);
    }

    if (tv.tv_sec || tv.tv_usec) {
        options.connect_timeout = &tv;
    }

    if (nonblock) {
        options.options |= VALKEY_OPT_NONBLOCK;
    }

    return valkeyConnectWithOptions(&options);
}

/* This is a wrapper to call valkeyConnectUnix or valkeyConnectUnixWithTimeout. */
valkeyContext *valkeyConnectUnixWrapper(const char *path, const struct timeval tv, int nonblock) {
    valkeyOptions options = {0};
    VALKEY_OPTIONS_SET_UNIX(&options, path);

    if (tv.tv_sec || tv.tv_usec) {
        options.connect_timeout = &tv;
    }

    if (nonblock) {

Review comment (suggestion):
If `rdma` is passed when this is compiled without USE_RDMA, we shouldn't raise an error instead of ignoring it.

Let's do some assert or just return NULL?

```suggestion
#else
        assert(!rdma);
#endif
```



Code after:
        default: s = sdscatprintf(s, *(unsigned char *)p <= 0x1f ? "\\u%04x" : "%c", *p);
        }
        p++;
    }
    return sdscatlen(s, "\"", 1);
}

sds cliVersion(void) {
    sds version = sdscatprintf(sdsempty(), "%s", VALKEY_VERSION);

    /* Add git commit and working tree status when available. */
    if (strtoll(serverGitSHA1(), NULL, 16)) {
        version = sdscatprintf(version, " (git:%s", serverGitSHA1());
        if (strtoll(serverGitDirty(), NULL, 10)) version = sdscatprintf(version, "-dirty");
        version = sdscat(version, ")");
    }
    return version;
}

/* This is a wrapper to call valkeyConnect or valkeyConnectWithTimeout. */
valkeyContext *valkeyConnectWrapper(enum valkeyConnectionType ct, const char *ip_or_path, int port, const struct timeval tv, int nonblock) {
    valkeyOptions options = {0};

    switch (ct) {
    case VALKEY_CONN_TCP:
        VALKEY_OPTIONS_SET_TCP(&options, ip_or_path, port);
        break;

    case VALKEY_CONN_UNIX:
        VALKEY_OPTIONS_SET_UNIX(&options, ip_or_path);
        break;

    case VALKEY_CONN_RDMA:
#ifdef USE_RDMA
        VALKEY_OPTIONS_SET_RDMA(&options, ip_or_path, port);
        break;
#else
        assert(0); /* requesting RDMA connection without RDMA support??? */
#endif

    default:
        assert(0); /* this should not happen */
    }

    if (tv.tv_sec || tv.tv_usec) {
        options.connect_timeout = &tv;
    }

    if (nonblock) {
        options.options |= VALKEY_OPT_NONBLOCK;
    }