laruence / yar-c

Yar C Framework
Apache License 2.0
106 stars 29 forks source link

yar_client.c 括号位置错误 #11

Closed Aidearn closed 4 years ago

Aidearn commented 4 years ago

yar_client yar_client_init(char hostname) / {{{ / { struct sockaddr sa; int sockfd; yar_client *client = calloc(1, sizeof(yar_client));

client->hostname = hostname;
client->call = yar_client_caller;

if (strncasecmp(hostname, "http://", sizeof("http://")) == 0
        || strncasecmp(hostname, "https://", sizeof("https://")) == 0) {
    /* libcurl */
    free(client);
    return NULL;
} else if (hostname[0] == '/') {
    /* unix domain socket */
    struct sockaddr_un *usa;
    usa = (struct sockaddr_un *)&sa;
            // 应该是:if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
    if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0) == -1)) {
        alog(YAR_ERROR, "Failed to create a socket '%s'", strerror(errno));
        free(client);
        return NULL;
    }
    usa->sun_family = AF_UNIX;
    memcpy(usa->sun_path, hostname, strlen(hostname) + 1);
laruence commented 4 years ago

提个pr吧?

laruence commented 4 years ago

fixed