Changeset 759

Show
Ignore:
Timestamp:
03/18/08 17:21:31 (5 months ago)
Author:
dsallings
Message:

Style fix: horizontal spacing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/binary/server/memcached.c

    r758 r759  
    166166 
    167167static void settings_init(void) { 
    168     settings.access=0700; 
     168    settings.access = 0700; 
    169169    settings.port = 11211; 
    170170    settings.udpport = 0; 
     
    296296 
    297297static char *prot_text(enum protocol prot) { 
    298     char *rv="unknown"; 
     298    char *rv = "unknown"; 
    299299    switch(prot) { 
    300300        case ascii_prot: 
    301             rv="ascii"; 
     301            rv = "ascii"; 
    302302            break; 
    303303        case binary_prot: 
    304             rv="binary"; 
     304            rv = "binary"; 
    305305            break; 
    306306        case ascii_udp_prot: 
    307             rv="ascii-udp"; 
     307            rv = "ascii-udp"; 
    308308            break; 
    309309        case negotiating_prot: 
    310             rv="auto-negotiate"; 
     310            rv = "auto-negotiate"; 
    311311            break; 
    312312    } 
     
    351351            if (c->rbuf != 0) free(c->rbuf); 
    352352            if (c->wbuf != 0) free(c->wbuf); 
    353             if (c->ilist !=0) free(c->ilist); 
     353            if (c->ilist != 0) free(c->ilist); 
    354354            if (c->suffixlist != 0) free(c->suffixlist); 
    355355            if (c->iov != 0) free(c->iov); 
     
    515515 
    516516static enum conn_states get_init_state(conn *c) { 
    517     int rv=0; 
     517    int rv = 0; 
    518518    assert(c != NULL); 
    519519 
    520520    switch(c->protocol) { 
    521521        case binary_prot: 
    522             rv=conn_bin_init; 
     522            rv = conn_bin_init; 
    523523            break; 
    524524        case negotiating_prot: 
    525             rv=conn_negotiate; 
     525            rv = conn_negotiate; 
    526526            break; 
    527527        default: 
    528             rv=conn_read; 
     528            rv = conn_read; 
    529529    } 
    530530    return rv; 
     
    865865 
    866866static void add_bin_header(conn *c, int err, int hdr_len, int body_len) { 
    867     int i=0; 
     867    int i = 0; 
    868868    uint32_t *res_header; 
    869869 
     
    896896    } 
    897897 
    898     for(i=0; i<BIN_PKT_HDR_WORDS; i++) { 
     898    for(i = 0; i<BIN_PKT_HDR_WORDS; i++) { 
    899899        res_header[i] = htonl(res_header[i]); 
    900900    } 
     
    905905 
    906906static void write_bin_error(conn *c, int err, int swallow) { 
    907     char *errstr="Unknown error"; 
     907    char *errstr = "Unknown error"; 
    908908    switch(err) { 
    909909        case ERR_UNKNOWN_CMD: 
    910             errstr="Unknown command"; 
     910            errstr = "Unknown command"; 
    911911            break; 
    912912        case ERR_NOT_FOUND: 
    913             errstr="Not found"; 
     913            errstr = "Not found"; 
    914914            break; 
    915915        case ERR_INVALID_ARGUMENTS: 
    916             errstr="Invalid arguments"; 
     916            errstr = "Invalid arguments"; 
    917917            break; 
    918918        case ERR_EXISTS: 
    919             errstr="Data exists for key."; 
     919            errstr = "Data exists for key."; 
    920920            break; 
    921921        case ERR_TOO_LARGE: 
    922             errstr="Too large."; 
     922            errstr = "Too large."; 
    923923            break; 
    924924        case ERR_NOT_STORED: 
    925             errstr="Not stored."; 
     925            errstr = "Not stored."; 
    926926            break; 
    927927        default: 
    928             errstr="UNHANDLED ERROR"; 
     928            errstr = "UNHANDLED ERROR"; 
    929929            fprintf(stderr, "UNHANDLED ERROR:  %d\n", err); 
    930930    } 
     
    937937    conn_set_state(c, conn_mwrite); 
    938938    if(swallow > 0) { 
    939         c->sbytes=swallow; 
     939        c->sbytes = swallow; 
    940940        c->write_and_go = conn_swallow; 
    941941    } else { 
     
    959959    /* Little endian, flip the bytes around until someone makes a faster/better 
    960960    * way to do this. */ 
    961     int64_t rv=0; 
    962     int i=0; 
    963      for(i=0; i<8; i++) { 
     961    int64_t rv = 0; 
     962    int i = 0; 
     963     for(i = 0; i<8; i++) { 
    964964        rv = (rv << 8) | (in & 0xff); 
    965965        in >>= 8; 
     
    984984    assert(c != NULL); 
    985985 
    986     key=c->rbuf + BIN_INCR_HDR_LEN; 
    987     nkey=c->keylen; 
    988     key[nkey]=0x00; 
     986    key = c->rbuf + BIN_INCR_HDR_LEN; 
     987    nkey = c->keylen; 
     988    key[nkey] = 0x00; 
    989989 
    990990    delta = swap64(*((int64_t*)(c->rbuf))); 
     
    994994    if(settings.verbose) { 
    995995        fprintf(stderr, "incr "); 
    996         for(i=0; i<nkey; i++) { 
     996        for(i = 0; i<nkey; i++) { 
    997997            fprintf(stderr, "%c", key[i]); 
    998998        } 
     
    10041004        /* Weird magic in add_delta forces me to pad here */ 
    10051005        char tmpbuf[INCR_MAX_STORAGE_LEN]; 
    1006         uint64_t l=0; 
     1006        uint64_t l = 0; 
    10071007        memset(tmpbuf, ' ', INCR_MAX_STORAGE_LEN); 
    1008         tmpbuf[INCR_MAX_STORAGE_LEN]=0x00; 
     1008        tmpbuf[INCR_MAX_STORAGE_LEN] = 0x00; 
    10091009        add_delta(it, c->cmd == CMD_INCR, delta, tmpbuf); 
    1010         *response_buf=swap64(strtoull(tmpbuf, NULL, 10)); 
     1010        *response_buf = swap64(strtoull(tmpbuf, NULL, 10)); 
    10111011 
    10121012        write_bin_response(c, response_buf, BIN_INCR_HDR_LEN, INCR_RES_LEN); 
     
    10161016            /* Save some room for the response */ 
    10171017            assert(c->wsize > BIN_INCR_HDR_LEN + BIN_DEL_HDR_LEN); 
    1018             *response_buf=swap64(initial); 
     1018            *response_buf = swap64(initial); 
    10191019            it = item_alloc(key, nkey, 0, realtime(exptime), 
    10201020                INCR_MAX_STORAGE_LEN); 
     
    10351035 
    10361036static void complete_update_bin(conn *c) { 
    1037     int eno=-1, ret=0; 
     1037    int eno = -1, ret = 0; 
    10381038    assert(c != NULL); 
    10391039 
     
    10621062        default: 
    10631063            if(c->item_comm == NREAD_ADD) { 
    1064                 eno=ERR_EXISTS; 
     1064                eno = ERR_EXISTS; 
    10651065            } else if(c->item_comm == NREAD_REPLACE) { 
    1066                 eno=ERR_NOT_FOUND; 
     1066                eno = ERR_NOT_FOUND; 
    10671067            } else { 
    1068                 eno=ERR_NOT_STORED; 
     1068                eno = ERR_NOT_STORED; 
    10691069            } 
    10701070            write_bin_error(c, eno, 0); 
     
    10871087        /* This is a bit of magic.  I'm using wbuf as the header, so I'll place 
    10881088        this is int in far enough to cover the header */ 
    1089         flags=(int*)(c->wbuf + MIN_BIN_PKT_LENGTH); 
    1090         *flags=htonl(strtoul(ITEM_suffix(it), NULL, 10)); 
     1089        flags = (int*)(c->wbuf + MIN_BIN_PKT_LENGTH); 
     1090        *flags = htonl(strtoul(ITEM_suffix(it), NULL, 10)); 
    10911091 
    10921092        /* the length has two unnecessary bytes, and then we write four more */ 
     
    10941094        /* Flags */ 
    10951095        add_iov(c, flags, 4); 
    1096         identifier=(uint64_t*)(c->wbuf + MIN_BIN_PKT_LENGTH + 4); 
    1097         *identifier=swap64((uint32_t)it->cas_id); 
     1096        identifier = (uint64_t*)(c->wbuf + MIN_BIN_PKT_LENGTH + 4); 
     1097        *identifier = swap64((uint32_t)it->cas_id); 
    10981098        add_iov(c, identifier, 8); 
    10991099        /* bytes minus the CRLF */ 
     
    11651165    item *it; 
    11661166    int comm; 
    1167     int hdrlen=BIN_SET_HDR_LEN; 
     1167    int hdrlen = BIN_SET_HDR_LEN; 
    11681168 
    11691169    assert(c != NULL); 
    11701170 
    1171     key=c->rbuf + hdrlen; 
    1172     nkey=c->keylen; 
    1173     key[nkey]=0x00; 
     1171    key = c->rbuf + hdrlen; 
     1172    nkey = c->keylen; 
     1173    key[nkey] = 0x00; 
    11741174 
    11751175    flags = ntohl(*((int*)(c->rbuf))); 
     
    12361236    key = c->rbuf + 4; 
    12371237    nkey = c->keylen; 
    1238     key[nkey]=0x00; 
     1238    key[nkey] = 0x00; 
    12391239 
    12401240    if(settings.verbose) { 
     
    12541254        } else { 
    12551255            /* XXX:  This is really lame, but defer_delete returns a string */ 
    1256             char *res=defer_delete(it, exptime); 
     1256            char *res = defer_delete(it, exptime); 
    12571257            if(res[0] == 'D') { 
    12581258                write_bin_response(c, NULL, 0, 0); 
     
    12711271    if(c->cmd < 0) { 
    12721272        /* No command defined.  Figure out what they're trying to say. */ 
    1273         int i=0; 
     1273        int i = 0; 
    12741274        /* I did a bit of hard-coding around the packet sizes */ 
    12751275        assert(BIN_PKT_HDR_WORDS == 3); 
    1276         for(i=0; i<BIN_PKT_HDR_WORDS; i++) { 
     1276        for(i = 0; i<BIN_PKT_HDR_WORDS; i++) { 
    12771277            c->bin_header[i] = ntohl(c->bin_header[i]); 
    12781278        } 
     
    13681368    /* We've already got the first letter of the command, so pretend like we 
    13691369     * Did a single byte read from try_read_command */ 
    1370     c->rcurr=c->rbuf; 
    1371     c->rbytes=1; 
     1370    c->rcurr = c->rbuf; 
     1371    c->rbytes = 1; 
    13721372    conn_set_state(c, conn_read); 
    13731373} 
     
    21132113    } 
    21142114    if(value < 0) { 
    2115         value=0; 
     2115        value = 0; 
    21162116    } 
    21172117    sprintf(buf, "%llu", value); 
     
    26652665            return TRANSMIT_SOFT_ERROR; 
    26662666        } 
    2667         /* if res==0 or res==-1 and error is not EAGAIN or EWOULDBLOCK, 
     2667        /* if res == 0 or res == -1 and error is not EAGAIN or EWOULDBLOCK, 
    26682668           we have a real error, on which we close the connection */ 
    26692669        if (settings.verbose > 0) 
     
    31553155    addr.sun_family = AF_UNIX; 
    31563156    strcpy(addr.sun_path, path); 
    3157     old_umask=umask( ~(access_mask&0777)); 
     3157    old_umask = umask( ~(access_mask&0777)); 
    31583158    if (bind(sfd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { 
    31593159        perror("bind()"); 
     
    36753675 
    36763676    /* 
    3677      * ignore SIGPIPE signals; we can use errno==EPIPE if we 
     3677     * ignore SIGPIPE signals; we can use errno == EPIPE if we 
    36783678     * need that information 
    36793679     */