diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-05-08 14:13:47 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-05-08 14:13:47 +1000 |
commit | f00d326480d33d617e5e7df3ee5d795a676af1bc (patch) | |
tree | 5bd835d58157edd8dd87e0f6aebd53ff5e6516c5 | |
parent | 3dd3f75dd44217d303f1d4feeffa986d6fdb5eaf (diff) | |
download | mongo-f00d326480d33d617e5e7df3ee5d795a676af1bc.tar.gz |
Scan include files for style problems. Fix the ones found right away.
-rw-r--r-- | dist/dist.py | 7 | ||||
-rw-r--r-- | dist/s_string.ok | 1 | ||||
-rwxr-xr-x | dist/style.py | 1 | ||||
-rw-r--r-- | src/include/btree.i | 12 | ||||
-rw-r--r-- | src/include/cell.i | 10 | ||||
-rw-r--r-- | src/include/intpack.i | 12 | ||||
-rw-r--r-- | src/include/mutex.i | 48 | ||||
-rw-r--r-- | src/include/packing.i | 24 | ||||
-rw-r--r-- | src/include/verify_build.h | 5 |
9 files changed, 109 insertions, 11 deletions
diff --git a/dist/dist.py b/dist/dist.py index a51ce31b97b..725be8f96e3 100644 --- a/dist/dist.py +++ b/dist/dist.py @@ -1,8 +1,11 @@ -import filecmp, os, re, shutil +import filecmp, glob, os, re, shutil # source_files -- # Return a list of the source file names in filelist. -def source_files(): +def source_files(skip_includes=False): + if not skip_includes: + for line in glob.iglob('../src/include/*.[hi]'): + yield line file_re = re.compile(r'^\w') for line in open('filelist', 'r'): if file_re.match(line): diff --git a/dist/s_string.ok b/dist/s_string.ok index 4fe8fd94a73..3cb7de14054 100644 --- a/dist/s_string.ok +++ b/dist/s_string.ok @@ -891,6 +891,7 @@ trk trk's troot trunc +trylock trywrlock tsalvage tsplit diff --git a/dist/style.py b/dist/style.py index 15a50e721c3..f641da07981 100755 --- a/dist/style.py +++ b/dist/style.py @@ -4,7 +4,6 @@ from dist import source_files import re, sys - # Complain if a function comment is missing. def missing_comment(): for f in source_files(): diff --git a/src/include/btree.i b/src/include/btree.i index 2cb2bb9c7e1..e433a558d9c 100644 --- a/src/include/btree.i +++ b/src/include/btree.i @@ -163,18 +163,30 @@ __wt_cache_page_evict(WT_SESSION_IMPL *session, WT_PAGE *page) (void)WT_ATOMIC_ADD(cache->pages_evict, 1); } +/* + * __wt_cache_read_gen -- + * Get the current read generation number. + */ static inline uint64_t __wt_cache_read_gen(WT_SESSION_IMPL *session) { return (S2C(session)->cache->read_gen); } +/* + * __wt_cache_read_gen_incr -- + * Increment the current read generation number. + */ static inline void __wt_cache_read_gen_incr(WT_SESSION_IMPL *session) { ++S2C(session)->cache->read_gen; } +/* + * __wt_cache_read_gen_set -- + * Get the read generation to store in a page. + */ static inline uint64_t __wt_cache_read_gen_set(WT_SESSION_IMPL *session) { diff --git a/src/include/cell.i b/src/include/cell.i index 00a1e4d0e5b..071206c4b49 100644 --- a/src/include/cell.i +++ b/src/include/cell.i @@ -797,8 +797,9 @@ __cell_data_ref(WT_SESSION_IMPL *session, } /* - * __wt_dsk_cell_data_ref, __wt_page_cell_data_ref -- - * Set a buffer to reference the data from an unpacked cell, two flavors. + * __wt_dsk_cell_data_ref -- + * Set a buffer to reference the data from an unpacked cell. + * * There are two versions because of WT_CELL_VALUE_OVFL_RM type cells. When an * overflow item is deleted, its backing blocks are removed; if there are still * running transactions that might need to see the overflow item, we cache a @@ -816,6 +817,11 @@ __wt_dsk_cell_data_ref(WT_SESSION_IMPL *session, __wt_cell_type_raw(unpack->cell) != WT_CELL_VALUE_OVFL_RM); return (__cell_data_ref(session, NULL, page_type, unpack, store)); } + +/* + * __wt_page_cell_data_ref -- + * Set a buffer to reference the data from an unpacked cell. + */ static inline int __wt_page_cell_data_ref(WT_SESSION_IMPL *session, WT_PAGE *page, WT_CELL_UNPACK *unpack, WT_ITEM *store) diff --git a/src/include/intpack.i b/src/include/intpack.i index 1c4c549c5e6..9861e671857 100644 --- a/src/include/intpack.i +++ b/src/include/intpack.i @@ -166,7 +166,7 @@ __wt_vunpack_negint(const uint8_t **pp, size_t maxlen, uint64_t *retp) } /* - * __wt_vpack_uint + * __wt_vpack_uint -- * Variable-sized packing for unsigned integers */ static inline int @@ -194,7 +194,7 @@ __wt_vpack_uint(uint8_t **pp, size_t maxlen, uint64_t x) } /* - * __wt_vpack_int + * __wt_vpack_int -- * Variable-sized packing for signed integers */ static inline int @@ -224,7 +224,7 @@ __wt_vpack_int(uint8_t **pp, size_t maxlen, int64_t x) } /* - * __wt_vunpack_uint + * __wt_vunpack_uint -- * Variable-sized unpacking for unsigned integers */ static inline int @@ -262,7 +262,7 @@ __wt_vunpack_uint(const uint8_t **pp, size_t maxlen, uint64_t *xp) } /* - * __wt_vunpack_int + * __wt_vunpack_int -- * Variable-sized packing for signed integers */ static inline int @@ -327,7 +327,7 @@ __wt_vsize_negint(uint64_t x) } /* - * __wt_vsize_uint + * __wt_vsize_uint -- * Return the packed size of an unsigned integer. */ static inline size_t @@ -344,7 +344,7 @@ __wt_vsize_uint(uint64_t x) } /* - * __wt_vsize_int + * __wt_vsize_int -- * Return the packed size of a signed integer. */ static inline size_t diff --git a/src/include/mutex.i b/src/include/mutex.i index 7dacb2c4f7e..5d500d63de5 100644 --- a/src/include/mutex.i +++ b/src/include/mutex.i @@ -24,6 +24,10 @@ #define WT_SPIN_COUNT 1000 #endif +/* + * __wt_spin_init -- + * Initialize a spinlock. + */ static inline int __wt_spin_init(WT_SESSION_IMPL *session, WT_SPINLOCK *t, const char *name) { @@ -34,6 +38,10 @@ __wt_spin_init(WT_SESSION_IMPL *session, WT_SPINLOCK *t, const char *name) return (0); } +/* + * __wt_spin_destroy -- + * Destroy a spinlock. + */ static inline void __wt_spin_destroy(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { @@ -42,6 +50,10 @@ __wt_spin_destroy(WT_SESSION_IMPL *session, WT_SPINLOCK *t) *(t) = 0; } +/* + * __wt_spin_trylock_func -- + * Try to lock a spinlock or fail immediately if it is busy. + */ static inline int __wt_spin_trylock_func(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { @@ -50,6 +62,10 @@ __wt_spin_trylock_func(WT_SESSION_IMPL *session, WT_SPINLOCK *t) return (__sync_lock_test_and_set(t, 1) == 0 ? 0 : EBUSY); } +/* + * __wt_spin_lock -- + * Spin until the lock is acquired. + */ static inline void __wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { @@ -65,6 +81,10 @@ __wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) } } +/* + * __wt_spin_unlock -- + * Release the spinlock. + */ static inline void __wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { @@ -76,6 +96,10 @@ __wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) #elif SPINLOCK_TYPE == SPINLOCK_PTHREAD_MUTEX ||\ SPINLOCK_TYPE == SPINLOCK_PTHREAD_MUTEX_LOGGING +/* + * __wt_spin_init -- + * Initialize a spinlock. + */ static inline int __wt_spin_init(WT_SESSION_IMPL *session, WT_SPINLOCK *t, const char *name) { @@ -100,6 +124,10 @@ __wt_spin_init(WT_SESSION_IMPL *session, WT_SPINLOCK *t, const char *name) return (0); } +/* + * __wt_spin_destroy -- + * Destroy a spinlock. + */ static inline void __wt_spin_destroy(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { @@ -120,6 +148,10 @@ __wt_spin_destroy(WT_SESSION_IMPL *session, WT_SPINLOCK *t) #define __wt_spin_trylock(session, lock, idp) \ __wt_spin_trylock_func(session, lock) +/* + * __wt_spin_trylock_func -- + * Try to lock a spinlock or fail immediately if it is busy. + */ static inline int __wt_spin_trylock_func(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { @@ -128,6 +160,10 @@ __wt_spin_trylock_func(WT_SESSION_IMPL *session, WT_SPINLOCK *t) return (pthread_mutex_trylock(&t->lock)); } +/* + * __wt_spin_lock -- + * Spin until the lock is acquired. + */ static inline void __wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { @@ -154,6 +190,10 @@ __wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) __wt_spin_lock_func(session, lock, &__id, __FILE__, __LINE__); \ } while (0) +/* + * __wt_spin_trylock_func -- + * Try to lock a spinlock or fail immediately if it is busy. + */ static inline int __wt_spin_trylock_func(WT_SESSION_IMPL *session, WT_SPINLOCK *t, int *idp, const char *file, int line) @@ -203,6 +243,10 @@ __wt_spin_trylock_func(WT_SESSION_IMPL *session, return (ret); } +/* + * __wt_spin_lock_func -- + * Spin until the lock is acquired. + */ static inline void __wt_spin_lock_func(WT_SESSION_IMPL *session, WT_SPINLOCK *t, int *idp, const char *file, int line) @@ -228,6 +272,10 @@ __wt_spin_lock_func(WT_SESSION_IMPL *session, #endif +/* + * __wt_spin_unlock -- + * Release the spinlock. + */ static inline void __wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { diff --git a/src/include/packing.i b/src/include/packing.i index 1886e3a4007..fa8ee3e9025 100644 --- a/src/include/packing.i +++ b/src/include/packing.i @@ -37,6 +37,10 @@ typedef struct { #define WT_PACK_INIT { NULL, NULL, NULL, NULL, 0, WT_PACK_VALUE_INIT } #define WT_DECL_PACK(pack) WT_PACK pack = WT_PACK_INIT +/* + * __pack_initn -- + * Initialize a pack iterator with the specified string and length. + */ static inline int __pack_initn( WT_SESSION_IMPL *session, WT_PACK *pack, const char *fmt, size_t len) @@ -53,12 +57,20 @@ __pack_initn( return (0); } +/* + * __pack_init -- + * Initialize a pack iterator with the specified string. + */ static inline int __pack_init(WT_SESSION_IMPL *session, WT_PACK *pack, const char *fmt) { return (__pack_initn(session, pack, fmt, strlen(fmt))); } +/* + * __pack_next -- + * Get the next field type from a pack iterator. + */ static inline int __pack_next(WT_PACK *pack, WT_PACK_VALUE *pv) { @@ -173,6 +185,10 @@ next: if (pack->cur == pack->end) } \ } while (0) +/* + * __pack_size -- + * Get the size of a packed value. + */ static inline size_t __pack_size(WT_SESSION_IMPL *session, WT_PACK_VALUE *pv) { @@ -234,6 +250,10 @@ __pack_size(WT_SESSION_IMPL *session, WT_PACK_VALUE *pv) return ((size_t)-1); } +/* + * __pack_write -- + * Pack a value into a buffer. + */ static inline int __pack_write( WT_SESSION_IMPL *session, WT_PACK_VALUE *pv, uint8_t **pp, size_t maxlen) @@ -330,6 +350,10 @@ __pack_write( return (0); } +/* + * __unpack_read -- + * Read a packed value from a buffer. + */ static inline int __unpack_read(WT_SESSION_IMPL *session, WT_PACK_VALUE *pv, const uint8_t **pp, size_t maxlen) diff --git a/src/include/verify_build.h b/src/include/verify_build.h index b9dc72c41d2..811602be34a 100644 --- a/src/include/verify_build.h +++ b/src/include/verify_build.h @@ -40,6 +40,11 @@ #define ALIGN_CHECK(type, a) \ STATIC_ASSERT(WT_ALIGN(sizeof(type), (a)) == sizeof(type)) +/* + * __wt_verify_build -- + * This function is never called: it exists so there is a place for code + * that checks build-time conditions. + */ static inline void __wt_verify_build(void) { |