[memcached] plindner, r493: update clean-whitespace, add automated w...

commits at code.sixapart.com commits at code.sixapart.com
Tue Apr 10 11:54:30 UTC 2007


update clean-whitespace, add automated whitespace test, and clean whitespace (merge from trunk)

U   branches/multithreaded/server/assoc.c
U   branches/multithreaded/server/configure.ac
U   branches/multithreaded/server/devtools/clean-whitespace.pl
U   branches/multithreaded/server/items.c
U   branches/multithreaded/server/memcached.c
U   branches/multithreaded/server/slabs.c
U   branches/multithreaded/server/slabs.h
U   branches/multithreaded/server/stats.c
A   branches/multithreaded/server/t/whitespace.t
U   branches/multithreaded/server/thread.c


Modified: branches/multithreaded/server/assoc.c
===================================================================
--- branches/multithreaded/server/assoc.c	2007-04-10 11:51:57 UTC (rev 492)
+++ branches/multithreaded/server/assoc.c	2007-04-10 11:54:23 UTC (rev 493)
@@ -64,7 +64,7 @@
   the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
   is commonly produced by subtraction) look like a single 1-bit
   difference.
-* the base values were pseudorandom, all zero but one bit set, or 
+* the base values were pseudorandom, all zero but one bit set, or
   all zero plus a counter that starts at zero.
 
 Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that
@@ -74,7 +74,7 @@
    14  9  3  7 17  3
 Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing
 for "differ" defined as + with a one-bit base and a two-bit delta.  I
-used http://burtleburtle.net/bob/hash/avalanche.html to choose 
+used http://burtleburtle.net/bob/hash/avalanche.html to choose
 the operations, constants, and arrangements of the variables.
 
 This does not achieve avalanche.  There are input bits of (a,b,c)
@@ -113,7 +113,7 @@
   the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
   is commonly produced by subtraction) look like a single 1-bit
   difference.
-* the base values were pseudorandom, all zero but one bit set, or 
+* the base values were pseudorandom, all zero but one bit set, or
   all zero plus a counter that starts at zero.
 
 These constants passed:
@@ -137,7 +137,7 @@
 }
 
 #if HASH_LITTLE_ENDIAN == 1
-uint32_t hash( 
+uint32_t hash(
   const void *key,       /* the key to hash */
   size_t      length,    /* length of the key */
   const uint32_t    initval)   /* initval */
@@ -145,7 +145,7 @@
   uint32_t a,b,c;                                          /* internal state */
   union { const void *ptr; size_t i; } u;     /* needed for Mac Powerbook G4 */
 
-  /* Set up the internal state */  
+  /* Set up the internal state */
   a = b = c = 0xdeadbeef + ((uint32_t)length) + initval;
 
   u.ptr = key;
@@ -167,7 +167,7 @@
     }
 
     /*----------------------------- handle the last (probably partial) block */
-    /* 
+    /*
      * "k[2]&0xffffff" actually reads beyond the end of the string, but
      * then masks off the part it's not allowed to read.  Because the
      * string is aligned, the masked-off tail is in the same word as the
@@ -316,7 +316,7 @@
  * hashbig():
  * This is the same as hashword() on big-endian machines.  It is different
  * from hashlittle() on all machines.  hashbig() takes advantage of
- * big-endian byte ordering. 
+ * big-endian byte ordering.
  */
 uint32_t hash( const void *key, size_t length, const uint32_t initval)
 {
@@ -345,7 +345,7 @@
     }
 
     /*----------------------------- handle the last (probably partial) block */
-    /* 
+    /*
      * "k[2]<<8" actually reads beyond the end of the string, but
      * then shifts out the part it's not allowed to read.  Because the
      * string is aligned, the illegal read is in the same word as the
@@ -442,7 +442,7 @@
   return c;
 }
 #else // HASH_XXX_ENDIAN == 1
-#error Must define HASH_BIG_ENDIAN or HASH_LITTLE_ENDIAN 
+#error Must define HASH_BIG_ENDIAN or HASH_LITTLE_ENDIAN
 #endif // hash_XXX_ENDIAN == 1
 
 typedef  unsigned long  int  ub4;   /* unsigned 4-byte quantities */
@@ -610,7 +610,7 @@
         hash_items--;
         return;
     }
-    /* Note:  we never actually get here.  the callers don't delete things 
+    /* Note:  we never actually get here.  the callers don't delete things
        they can't find. */
     assert(*before != 0);
 }

Modified: branches/multithreaded/server/configure.ac
===================================================================
--- branches/multithreaded/server/configure.ac	2007-04-10 11:51:57 UTC (rev 492)
+++ branches/multithreaded/server/configure.ac	2007-04-10 11:54:23 UTC (rev 493)
@@ -102,10 +102,10 @@
 AC_C_CONST
 AC_CHECK_HEADER(malloc.h, AC_DEFINE(HAVE_MALLOC_H,,[do we have malloc.h?]))
 AC_CHECK_MEMBER([struct mallinfo.arena], [
-		AC_DEFINE(HAVE_STRUCT_MALLINFO,,[do we have stuct mallinfo?])
-	], ,[
-#	include <malloc.h>
-	]
+        AC_DEFINE(HAVE_STRUCT_MALLINFO,,[do we have stuct mallinfo?])
+    ], ,[
+#    include <malloc.h>
+    ]
 )
 
 dnl From licq: Copyright (c) 2000 Dirk Mueller

Modified: branches/multithreaded/server/devtools/clean-whitespace.pl
===================================================================
--- branches/multithreaded/server/devtools/clean-whitespace.pl	2007-04-10 11:51:57 UTC (rev 492)
+++ branches/multithreaded/server/devtools/clean-whitespace.pl	2007-04-10 11:54:23 UTC (rev 493)
@@ -2,7 +2,7 @@
 use strict;
 use FindBin qw($Bin);
 chdir "$Bin/.." or die;
-my @files = (glob("*.h"), glob("*.c"));
+my @files = (glob("*.h"), glob("*.c"), glob("*.ac"));
 foreach my $f (@files) {
     open(my $fh, $f) or die;
     my $before = do { local $/; <$fh>; };

Modified: branches/multithreaded/server/items.c
===================================================================
--- branches/multithreaded/server/items.c	2007-04-10 11:51:57 UTC (rev 492)
+++ branches/multithreaded/server/items.c	2007-04-10 11:54:23 UTC (rev 493)
@@ -54,7 +54,7 @@
 /*
  * Generates the variable-sized part of the header for an object.
  *
- * key     - The key 
+ * key     - The key
  * nkey    - The length of the key
  * flags   - key flags
  * nbytes  - Number of bytes to hold value and addition CRLF terminator
@@ -69,7 +69,7 @@
     *nsuffix = (uint8_t) snprintf(suffix, 40, " %d %d\r\n", flags, nbytes - 2);
     return sizeof(item) + nkey + *nsuffix + nbytes;
 }
- 
+
 /*@null@*/
 item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_time_t exptime, const int nbytes) {
     uint8_t nsuffix;
@@ -92,8 +92,8 @@
 
         if (settings.evict_to_free == 0) return NULL;
 
-        /* 
-         * try to get one off the right LRU 
+        /*
+         * try to get one off the right LRU
          * don't necessariuly unlink the tail because it may be locked: refcount>0
          * search up from tail an item with refcount==0 and unlink it; give up after 50
          * tries

Modified: branches/multithreaded/server/memcached.c
===================================================================
--- branches/multithreaded/server/memcached.c	2007-04-10 11:51:57 UTC (rev 492)
+++ branches/multithreaded/server/memcached.c	2007-04-10 11:54:23 UTC (rev 493)
@@ -61,7 +61,7 @@
 #endif
 
 /*
- * forward declarations 
+ * forward declarations
  */
 static void drive_machine(conn *c);
 static int new_socket(const bool is_udp);
@@ -484,7 +484,7 @@
             c->ilist = newbuf;
             c->isize = ITEM_LIST_INITIAL;
         }
-	/* TODO check error condition? */
+    /* TODO check error condition? */
     }
 
     if (c->msgsize > MSG_LIST_HIGHWAT) {
@@ -493,7 +493,7 @@
             c->msglist = newbuf;
             c->msgsize = MSG_LIST_INITIAL;
         }
-	/* TODO check error condition? */
+    /* TODO check error condition? */
     }
 
     if (c->iovsize > IOV_LIST_HIGHWAT) {
@@ -502,7 +502,7 @@
             c->iov = newbuf;
             c->iovsize = IOV_LIST_INITIAL;
         }
-	/* TODO check return value */
+    /* TODO check return value */
     }
 }
 
@@ -754,14 +754,14 @@
 #define KEY_TOKEN 1
 #define KEY_MAX_LENGTH 250
 
-#define MAX_TOKENS 6 
+#define MAX_TOKENS 6
 
 /*
  * Tokenize the command string by replacing whitespace with '\0' and update
  * the token array tokens with pointer to start of each token and length.
  * Returns total number of tokens.  The last valid token is the terminal
  * token (value points to the first unprocessed character of the string and
- * length zero).  
+ * length zero).
  *
  * Usage example:
  *
@@ -779,12 +779,12 @@
     size_t length = 0;
     size_t ntokens = 0;
 
-    assert(command != NULL && tokens != NULL && max_tokens > 1); 
+    assert(command != NULL && tokens != NULL && max_tokens > 1);
 
     cp = command;
     while(*cp != '\0' && ntokens < max_tokens - 1) {
         if(*cp == ' ') {
-            // If we've accumulated a token, this is the end of it. 
+            // If we've accumulated a token, this is the end of it.
             if(length > 0) {
                 tokens[ntokens].value = value;
                 tokens[ntokens].length = length;
@@ -942,7 +942,7 @@
             out_string(c, "SERVER_ERROR out of memory");
             return;
         }
-            
+
         fd = open("/proc/self/maps", O_RDONLY);
         if (fd == -1) {
             out_string(c, "SERVER_ERROR cannot open the maps file");
@@ -964,7 +964,7 @@
         strcpy(wbuf + res, "END\r\n");
         c->write_and_free = wbuf;
         c->wcurr = wbuf;
-        c->wbytes = res + 5; // Don't write the terminal '\0' 
+        c->wbytes = res + 5; // Don't write the terminal '\0'
         conn_set_state(c, conn_write);
         c->write_and_go = conn_read;
         close(fd);
@@ -1077,15 +1077,15 @@
 
     do {
         while(key_token->length != 0) {
-            
+
             key = key_token->value;
             nkey = key_token->length;
-            
+
             if(nkey > KEY_MAX_LENGTH) {
                 out_string(c, "CLIENT_ERROR bad command line format");
                 return;
             }
-                
+
             STATS_LOCK();
             stats.get_cmds++;
             STATS_UNLOCK();
@@ -1101,7 +1101,7 @@
                         c->ilist = new_list;
                     } else break;
                 }
-                    
+
                 /*
                  * Construct the response. Each hit adds three elements to the
                  * outgoing data list:
@@ -1131,7 +1131,7 @@
                 stats.get_misses++;
                 STATS_UNLOCK();
             }
-            
+
             key_token++;
         }
 
@@ -1143,16 +1143,16 @@
             ntokens = tokenize_command(key_token->value, tokens, MAX_TOKENS);
             key_token = tokens;
         }
-        
+
     } while(key_token->value != NULL);
 
     c->icurr = c->ilist;
     c->ileft = i;
-            
+
     if (settings.verbose > 1)
         fprintf(stderr, ">%d END\n", c->sfd);
     add_iov(c, "END\r\n", 5);
-        
+
     if (c->udp && build_udp_headers(c) != 0) {
         out_string(c, "SERVER_ERROR out of memory");
     }
@@ -1184,7 +1184,7 @@
     flags = strtoul(tokens[2].value, NULL, 10);
     exptime = strtol(tokens[3].value, NULL, 10);
     vlen = strtol(tokens[4].value, NULL, 10);
-    
+
     if(errno == ERANGE || ((flags == 0 || exptime == 0) && errno == EINVAL)) {
         out_string(c, "CLIENT_ERROR bad command line format");
         return;
@@ -1219,7 +1219,7 @@
         c->sbytes = vlen + 2;
         return;
     }
-    
+
     c->item_comm = comm;
     c->item = it;
     c->ritem = ITEM_data(it);
@@ -1233,17 +1233,17 @@
     unsigned int delta;
     char *key;
     size_t nkey;
-    
+
     assert(c != NULL);
 
-    if(tokens[KEY_TOKEN].length > KEY_MAX_LENGTH) { 
+    if(tokens[KEY_TOKEN].length > KEY_MAX_LENGTH) {
         out_string(c, "CLIENT_ERROR bad command line format");
         return;
     }
 
     key = tokens[KEY_TOKEN].value;
     nkey = tokens[KEY_TOKEN].length;
-        
+
     if (settings.managed) {
         int bucket = c->bucket;
         if (bucket == -1) {
@@ -1258,7 +1258,7 @@
     }
 
     delta = strtoul(tokens[2].value, NULL, 10);
-        
+
     if(errno == ERANGE) {
         out_string(c, "CLIENT_ERROR bad command line format");
         return;
@@ -1281,7 +1281,7 @@
  * incr  true to increment value, false to decrement
  * delta amount to adjust value by
  * buf   buffer for response string
- * 
+ *
  * returns a response string to send back to the client.
  */
 char *do_add_delta(item *it, int incr, unsigned int delta, char *buf) {
@@ -1291,7 +1291,7 @@
 
     ptr = ITEM_data(it);
     while ((*ptr != '\0') && (*ptr < '0' && *ptr > '9')) ptr++;    // BUG: can't be true
-        
+
     value = strtol(ptr, NULL, 10);
 
     if(errno == ERANGE) {
@@ -1329,7 +1329,7 @@
     size_t nkey;
     item *it;
     time_t exptime = 0;
-    
+
     assert(c != NULL);
 
     if (settings.managed) {
@@ -1344,7 +1344,7 @@
             return;
         }
     }
-    
+
     key = tokens[KEY_TOKEN].value;
     nkey = tokens[KEY_TOKEN].length;
 
@@ -1355,7 +1355,7 @@
 
     if(ntokens == 4) {
         exptime = strtol(tokens[2].value, NULL, 10);
-        
+
         if(errno == ERANGE) {
             out_string(c, "CLIENT_ERROR bad command line format");
             return;
@@ -1393,8 +1393,8 @@
         if (new_delete) {
             todelete = new_delete;
             deltotal *= 2;
-        } else { 
-            /* 
+        } else {
+            /*
              * can't delete it immediately, user wants a delay,
              * but we ran out of memory for the delete queue
              */
@@ -1402,7 +1402,7 @@
             return "SERVER_ERROR out of memory";
         }
     }
-    
+
     /* use its expiration time as its deletion time now */
     it->exptime = realtime(exptime);
     it->it_flags |= ITEM_DELETED;
@@ -1412,7 +1412,7 @@
 }
 
 static void process_command(conn *c, char *command) {
-    
+
     token_t tokens[MAX_TOKENS];
     size_t ntokens;
     int comm;
@@ -1422,11 +1422,11 @@
     if (settings.verbose > 1)
         fprintf(stderr, "<%d %s\n", c->sfd, command);
 
-    /* 
+    /*
      * for commands set/add/replace, we build an item and read the data
      * directly into it, then continue in nread_complete().
-     */ 
-    
+     */
+
     c->msgcurr = 0;
     c->msgused = 0;
     c->iovused = 0;
@@ -1440,14 +1440,14 @@
     if (ntokens >= 3 &&
         ((strcmp(tokens[COMMAND_TOKEN].value, "get") == 0) ||
          (strcmp(tokens[COMMAND_TOKEN].value, "bget") == 0))) {
-        
+
         process_get_command(c, tokens, ntokens);
 
-    } else if (ntokens == 6 && 
-               ((strcmp(tokens[COMMAND_TOKEN].value, "add") == 0 && (comm = NREAD_ADD)) || 
+    } else if (ntokens == 6 &&
+               ((strcmp(tokens[COMMAND_TOKEN].value, "add") == 0 && (comm = NREAD_ADD)) ||
                 (strcmp(tokens[COMMAND_TOKEN].value, "set") == 0 && (comm = NREAD_SET)) ||
                 (strcmp(tokens[COMMAND_TOKEN].value, "replace") == 0 && (comm = NREAD_REPLACE)))) {
-        
+
         process_update_command(c, tokens, ntokens, comm);
 
     } else if (ntokens == 4 && (strcmp(tokens[COMMAND_TOKEN].value, "incr") == 0)) {
@@ -1468,7 +1468,7 @@
             out_string(c, "CLIENT_ERROR not a managed instance");
             return;
         }
-        
+
         if (sscanf(tokens[1].value, "%u:%u", &bucket,&gen) == 2) {
             if ((bucket < 0) || (bucket >= MAX_BUCKETS)) {
                 out_string(c, "CLIENT_ERROR bucket number out of range");
@@ -1524,7 +1524,7 @@
         }
 
     } else if (ntokens >= 2 && (strcmp(tokens[COMMAND_TOKEN].value, "stats") == 0)) {
-        
+
         process_stat(c, tokens, ntokens);
 
     } else if (ntokens >= 2 && ntokens <= 3 && (strcmp(tokens[COMMAND_TOKEN].value, "flush_all") == 0)) {
@@ -1548,7 +1548,7 @@
         item_flush_expired();
         out_string(c, "OK");
         return;
- 
+
     } else if (ntokens == 2 && (strcmp(tokens[COMMAND_TOKEN].value, "version") == 0)) {
 
         out_string(c, "VERSION " VERSION);
@@ -1556,7 +1556,7 @@
     } else if (ntokens == 2 && (strcmp(tokens[COMMAND_TOKEN].value, "quit") == 0)) {
 
         conn_set_state(c, conn_closing);
-        
+
     } else if (ntokens == 5 && (strcmp(tokens[COMMAND_TOKEN].value, "slabs") == 0 &&
                                 strcmp(tokens[COMMAND_TOKEN + 1].value, "reassign") == 0)) {
 #ifdef ALLOW_SLABS_REASSIGN
@@ -2706,7 +2706,7 @@
         exit(EXIT_FAILURE);
     }
     /* create the initial listening connection */
-    if (!(listen_conn = conn_new(l_socket, conn_listening, 
+    if (!(listen_conn = conn_new(l_socket, conn_listening,
                                  EV_READ | EV_PERSIST, 1, false, main_base))) {
         fprintf(stderr, "failed to create listening connection");
         exit(EXIT_FAILURE);

Modified: branches/multithreaded/server/slabs.c
===================================================================
--- branches/multithreaded/server/slabs.c	2007-04-10 11:51:57 UTC (rev 492)
+++ branches/multithreaded/server/slabs.c	2007-04-10 11:54:23 UTC (rev 493)
@@ -73,8 +73,8 @@
  * Figures out which slab class (chunk size) is required to store an item of
  * a given size.
  *
- * Given object size, return id to use when allocating/freeing memory for object 
- * 0 means error: can't store such a large object 
+ * Given object size, return id to use when allocating/freeing memory for object
+ * 0 means error: can't store such a large object
  */
 
 unsigned int slabs_clsid(const size_t size) {

Modified: branches/multithreaded/server/slabs.h
===================================================================
--- branches/multithreaded/server/slabs.h	2007-04-10 11:51:57 UTC (rev 492)
+++ branches/multithreaded/server/slabs.h	2007-04-10 11:54:23 UTC (rev 493)
@@ -6,7 +6,7 @@
 void slabs_init(const size_t limit, const double factor);
 
 
-/*  
+/*
  * Given object size, return id to use when allocating/freeing memory for object
  * 0 means error: can't store such a large object
  */

Modified: branches/multithreaded/server/stats.c
===================================================================
--- branches/multithreaded/server/stats.c	2007-04-10 11:51:57 UTC (rev 492)
+++ branches/multithreaded/server/stats.c	2007-04-10 11:54:23 UTC (rev 493)
@@ -127,7 +127,7 @@
  */
 void stats_prefix_record_delete(char *key) {
     PREFIX_STATS *pfs;
-    
+
     STATS_LOCK();
     pfs = stats_prefix_find(key);
     if (NULL != pfs) {
@@ -141,7 +141,7 @@
  */
 void stats_prefix_record_set(char *key) {
     PREFIX_STATS *pfs;
-    
+
     STATS_LOCK();
     pfs = stats_prefix_find(key);
     if (NULL != pfs) {
@@ -181,12 +181,12 @@
     pos = 0;
     for (i = 0; i < PREFIX_HASH_SIZE; i++) {
         for (pfs = prefix_stats[i]; NULL != pfs; pfs = pfs->next) {
-            pos += sprintf(buf + pos, format, 
+            pos += sprintf(buf + pos, format,
                            pfs->prefix, pfs->num_gets, pfs->num_hits,
                            pfs->num_sets, pfs->num_deletes);
         }
     }
-    
+
     STATS_UNLOCK();
     strcpy(buf + pos, "END\r\n");
 

Copied: branches/multithreaded/server/t/whitespace.t (from rev 492, trunk/server/t/whitespace.t)

Modified: branches/multithreaded/server/thread.c
===================================================================
--- branches/multithreaded/server/thread.c	2007-04-10 11:51:57 UTC (rev 492)
+++ branches/multithreaded/server/thread.c	2007-04-10 11:54:23 UTC (rev 493)
@@ -301,21 +301,21 @@
             fprintf(stderr, "Can't read from libevent pipe\n");
 
     if (item = cq_peek(&me->new_conn_queue)) {
-	conn *c = conn_new(item->sfd, item->init_state, item->event_flags,
-	                   item->read_buffer_size, item->is_udp, me->base);
-	if (!c) {
-	    if (item->is_udp) {
-	        fprintf(stderr, "Can't listen for events on UDP socket\n");
-	        exit(1);
+    conn *c = conn_new(item->sfd, item->init_state, item->event_flags,
+                       item->read_buffer_size, item->is_udp, me->base);
+    if (!c) {
+        if (item->is_udp) {
+            fprintf(stderr, "Can't listen for events on UDP socket\n");
+            exit(1);
             }
-	    else {
-		if (settings.verbose > 0) {
-	            fprintf(stderr, "Can't listen for events on fd %d\n",
-		            item->sfd);
-		}
-		close(item->sfd);
-	    }
-	}
+        else {
+        if (settings.verbose > 0) {
+                fprintf(stderr, "Can't listen for events on fd %d\n",
+                    item->sfd);
+        }
+        close(item->sfd);
+        }
+    }
         cqi_free(item);
     }
 }
@@ -594,7 +594,7 @@
         threads[i].notify_receive_fd = fds[0];
         threads[i].notify_send_fd = fds[1];
 
-	setup_thread(&threads[i]);
+    setup_thread(&threads[i]);
     }
 
     /* Create threads after we've done all the libevent setup. */




More information about the memcached-commits mailing list