summaryrefslogtreecommitdiff
path: root/lib/dbm
diff options
context:
space:
mode:
authorFranziskus Kiefer <franziskuskiefer@gmail.com>2016-02-25 15:28:52 +0100
committerFranziskus Kiefer <franziskuskiefer@gmail.com>2016-02-25 15:28:52 +0100
commit11a75954a8c9f7d0c94f089d595b8c1da3a5ca83 (patch)
treeb60e60f4ace2e9be9c6eb9dca0c7f15d7fba6e51 /lib/dbm
parentdb6e138764000f48d554bcf63526896d0f8036f1 (diff)
downloadnss-hg-11a75954a8c9f7d0c94f089d595b8c1da3a5ca83.tar.gz
Bug 1251185, NSS clang-format: else line-break fixes, r=ttaubertNSS_3_23_BETA7
Diffstat (limited to 'lib/dbm')
-rw-r--r--lib/dbm/include/hash.h5
-rw-r--r--lib/dbm/src/dirent.c9
-rw-r--r--lib/dbm/src/dirent.h2
-rw-r--r--lib/dbm/src/h_bigkey.c33
-rw-r--r--lib/dbm/src/h_page.c42
-rw-r--r--lib/dbm/src/hash.c36
-rw-r--r--lib/dbm/src/hash_buf.c15
-rw-r--r--lib/dbm/src/memmove.c3
-rw-r--r--lib/dbm/src/mktemp.c3
-rw-r--r--lib/dbm/tests/lots.c33
10 files changed, 61 insertions, 120 deletions
diff --git a/lib/dbm/include/hash.h b/lib/dbm/include/hash.h
index e05d5a187..9faa0b724 100644
--- a/lib/dbm/include/hash.h
+++ b/lib/dbm/include/hash.h
@@ -163,9 +163,8 @@ typedef struct htab { /* Memory resident data structure */
#define ALL_CLEAR 0
#define PTROF(X) ((ptrdiff_t)(X) == BUF_DISK ? 0 : (X))
-#define ISDISK(X) ((X) ? ((ptrdiff_t)(X) == BUF_DISK ? BUF_DISK \
- : \
- (X)->is_disk) \
+#define ISDISK(X) ((X) ? ((ptrdiff_t)(X) == BUF_DISK ? BUF_DISK \
+ : (X)->is_disk) \
: 0)
#define BITS_PER_MAP 32
diff --git a/lib/dbm/src/dirent.c b/lib/dbm/src/dirent.c
index c0a572793..da3e83e5c 100644
--- a/lib/dbm/src/dirent.c
+++ b/lib/dbm/src/dirent.c
@@ -81,8 +81,7 @@ getFSType(const char *path)
if (isalpha(path[0]) && path[1] == ':') {
unit = toupper(path[0]) - '@';
path += 2;
- }
- else {
+ } else {
ULONG driveMap;
#if OS2 >= 2
if (DosQueryCurrentDisk(&unit, &driveMap))
@@ -109,8 +108,7 @@ getFSType(const char *path)
if (infolen >= sizeof(FSQBUFFER2)) {
FSQBUFFER2 *p = (FSQBUFFER2 *)info;
r = p->szFSDName[p->cbName];
- }
- else
+ } else
#else
if (DosQFSAttach((PSZ)drive, 0, FSAIL_QUERYNAME, (PVOID)info, &infolen, 0))
return 0;
@@ -118,8 +116,7 @@ getFSType(const char *path)
char *p = info + sizeof(USHORT);
p += sizeof(USHORT) + *(USHORT *)p + 1 + sizeof(USHORT);
r = *p;
- }
- else
+ } else
#endif
r = 0;
return cache[unit] = r;
diff --git a/lib/dbm/src/dirent.h b/lib/dbm/src/dirent.h
index 0db1485ad..0b4ae5dd2 100644
--- a/lib/dbm/src/dirent.h
+++ b/lib/dbm/src/dirent.h
@@ -61,7 +61,7 @@ struct dirent {
#else
char d_name[MAXNAMLEN + 1]; /* garentee null termination */
char d_attribute; /* .. extension .. */
- unsigned long d_size; /* .. extension .. */
+ unsigned long d_size; /* .. extension .. */
#endif
};
diff --git a/lib/dbm/src/h_bigkey.c b/lib/dbm/src/h_bigkey.c
index f4f9288d3..6edfe7f5a 100644
--- a/lib/dbm/src/h_bigkey.c
+++ b/lib/dbm/src/h_bigkey.c
@@ -129,8 +129,7 @@ __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
p[n - 2] = FULL_KEY_DATA;
FREESPACE(p) = FREESPACE(p) - move_bytes;
OFFSET(p) = off;
- }
- else
+ } else
p[n - 2] = FULL_KEY;
}
p = (uint16 *)bufp->page;
@@ -164,8 +163,7 @@ __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
return (-1);
cp = bufp->page;
p = (uint16 *)cp;
- }
- else
+ } else
p[n] = FULL_KEY_DATA;
bufp->flags |= BUF_MOD;
}
@@ -236,8 +234,7 @@ __big_delete(HTAB *hashp, BUFHEAD *bufp)
bp[1] = pageno;
bp[2] = OVFLPAGE;
bufp->ovfl = rbufp->ovfl;
- }
- else
+ } else
/* This is the last page. */
bufp->ovfl = NULL;
n -= 2;
@@ -295,8 +292,7 @@ __find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size)
++hash_collisions;
#endif
return (-2);
- }
- else
+ } else
return (ndx);
}
@@ -384,8 +380,7 @@ __big_return(
save_addr = save_p->addr;
off = bp[1];
len = 0;
- }
- else if (!FREESPACE(bp)) {
+ } else if (!FREESPACE(bp)) {
/*
* This is a hack. We can't distinguish between
* FULL_KEY_DATA that contains complete data or
@@ -401,8 +396,7 @@ __big_return(
if (!bufp)
return (-1);
bp = (uint16 *)bufp->page;
- }
- else {
+ } else {
/* The data is all on one page. */
tp = (char *)bp;
off = bp[bp[0]];
@@ -414,8 +408,7 @@ __big_return(
hashp->cpage = NULL;
hashp->cbucket++;
hashp->cndx = 1;
- }
- else {
+ } else {
hashp->cpage = __get_buf(hashp,
bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
@@ -528,8 +521,7 @@ collect_data(
if (bp[0] == 2) { /* No more buckets in chain */
hashp->cpage = NULL;
hashp->cbucket++;
- }
- else {
+ } else {
hashp->cpage = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
return (-1);
@@ -589,8 +581,7 @@ collect_key(
return (-1);
if (__big_return(hashp, bufp, 1, val, set))
return (-1);
- }
- else {
+ } else {
xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!xbp || ((totlen =
collect_key(hashp, xbp, totlen, val, set)) < 1))
@@ -639,8 +630,7 @@ __big_split(
__get_buf(hashp, ret->next_addr, big_keyp, 0)))
return (-1);
;
- }
- else
+ } else
ret->nextp = NULL;
/* Now make one of np/op point to the big key/data pair */
@@ -706,8 +696,7 @@ __big_split(
if (!tmpp)
return (-1);
tp[4] = n;
- }
- else
+ } else
tmpp = big_keyp;
if (change)
diff --git a/lib/dbm/src/h_page.c b/lib/dbm/src/h_page.c
index ecdc29310..bf1252aeb 100644
--- a/lib/dbm/src/h_page.c
+++ b/lib/dbm/src/h_page.c
@@ -256,8 +256,7 @@ __delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
if (bp[i + 1] == OVFLPAGE) {
bp[i - 2] = bp[i];
bp[i - 1] = bp[i + 1];
- }
- else {
+ } else {
bp[i - 2] = bp[i] + pairlen;
bp[i - 1] = bp[i + 1] + pairlen;
}
@@ -341,12 +340,10 @@ __split_page(HTAB *hashp, uint32 obucket, uint32 nbucket)
off - ino[n + 1]);
ino[ndx] = copyto + ino[n] - ino[n + 1];
ino[ndx + 1] = copyto;
- }
- else
+ } else
copyto = ino[n + 1];
ndx += 2;
- }
- else {
+ } else {
/* Switch page */
val.data = (uint8 *)op + ino[n + 1];
val.size = ino[n] - ino[n + 1];
@@ -460,8 +457,7 @@ ugly_split(HTAB *hashp, uint32 obucket, BUFHEAD *old_bufp,
cino = (char *)bufp->page;
ino = (uint16 *)cino;
last_bfp = ret.nextp;
- }
- else if (ino[n + 1] == OVFLPAGE) {
+ } else if (ino[n + 1] == OVFLPAGE) {
ov_addr = ino[n];
/*
* Fix up the old page -- the extra 2 are the fields
@@ -508,8 +504,7 @@ ugly_split(HTAB *hashp, uint32 obucket, BUFHEAD *old_bufp,
putpair((char *)op, &key, &val);
}
old_bufp->flags |= BUF_MOD;
- }
- else {
+ } else {
/* Move to new page */
if (PAIRFITS(np, (&key), (&val)))
putpair((char *)np, &key, &val);
@@ -560,8 +555,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
return (-1);
}
bp = (uint16 *)bufp->page;
- }
- else
+ } else
/* Try to squeeze key on this page */
if (FREESPACE(bp) > PAIRSIZE(key, val)) {
{
@@ -575,8 +569,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
hashp->NKEYS++;
return (0);
}
- }
- else {
+ } else {
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp) {
#ifdef DEBUG
@@ -716,8 +709,7 @@ __get_page(HTAB *hashp,
if (!is_bitmap && !bp[0]) {
PAGE_INIT(p);
- }
- else {
+ } else {
if (hashp->LORDER != BYTE_ORDER) {
register int i, max;
@@ -726,8 +718,7 @@ __get_page(HTAB *hashp,
max = hashp->BSIZE >> 2; /* divide by 4 */
for (i = 0; i < max; i++)
M_32_SWAP(((int *)p)[i]);
- }
- else {
+ } else {
M_16_SWAP(bp[0]);
max = bp[0] + 2;
@@ -779,8 +770,7 @@ __get_page(HTAB *hashp,
return (DATABASE_CORRUPTED_ERROR);
offset = bp[i + 1];
- }
- else {
+ } else {
/* there are no other valid keys after
* seeing a non REAL_KEY
*/
@@ -820,8 +810,7 @@ __put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap)
max = hashp->BSIZE >> 2; /* divide by 4 */
for (i = 0; i < max; i++)
M_32_SWAP(((int *)p)[i]);
- }
- else {
+ } else {
max = ((uint16 *)p)[0] + 2;
/* bound the size of max by
@@ -865,8 +854,7 @@ __put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap)
max = hashp->BSIZE >> 2; /* divide by 4 */
for (i = 0; i < max; i++)
M_32_SWAP(((int *)p)[i]);
- }
- else {
+ } else {
uint16 *bp = (uint16 *)p;
M_16_SWAP(bp[0]);
@@ -959,8 +947,7 @@ overflow_page(HTAB *hashp)
((hashp->BSIZE << BYTE_SHIFT) - 1);
j = bit / BITS_PER_MAP;
bit = bit & ~(BITS_PER_MAP - 1);
- }
- else {
+ } else {
bit = 0;
j = 0;
}
@@ -1029,8 +1016,7 @@ overflow_page(HTAB *hashp)
hashp->SPARES[splitnum - 1]--;
offset = 0;
}
- }
- else {
+ } else {
/*
* Free_bit addresses the last used bit. Bump it to address
* the first available bit.
diff --git a/lib/dbm/src/hash.c b/lib/dbm/src/hash.c
index d9a90ad02..5af4db73d 100644
--- a/lib/dbm/src/hash.c
+++ b/lib/dbm/src/hash.c
@@ -173,8 +173,7 @@ __hash_open(const char *file, int flags, int mode, const HASHINFO *info, int dfl
if (errno == ENOENT)
errno = 0; /* Just in case someone looks at errno */
new_table = 1;
- }
- else if (statbuf.st_mtime && statbuf.st_size == 0) {
+ } else if (statbuf.st_mtime && statbuf.st_size == 0) {
/* check for a zero length file and delete it
* if it exists
*/
@@ -195,8 +194,7 @@ __hash_open(const char *file, int flags, int mode, const HASHINFO *info, int dfl
if (new_table) {
if (!init_hash(hashp, file, (HASHINFO *)info))
RETURN_ERROR(errno, error1);
- }
- else {
+ } else {
/* Table already exists */
if (info && info->hash)
hashp->hash = info->hash;
@@ -706,10 +704,8 @@ hash_put(
return (DBM_ERROR);
}
- rv = hash_access(hashp, flag == R_NOOVERWRITE ?
- HASH_PUTNEW
- :
- HASH_PUT,
+ rv = hash_access(hashp, flag == R_NOOVERWRITE ? HASH_PUTNEW
+ : HASH_PUT,
(DBT *)key, (DBT *)data);
if (rv == DATABASE_CORRUPTED_ERROR) {
@@ -802,8 +798,7 @@ hash_access(
#endif
bp += 2;
ndx += 2;
- }
- else if (bp[1] == OVFLPAGE) {
+ } else if (bp[1] == OVFLPAGE) {
/* database corruption: overflow loop detection */
if (last_overflow_page_no == (int32)*bp)
@@ -826,8 +821,7 @@ hash_access(
n = *bp++;
ndx = 1;
off = hashp->BSIZE;
- }
- else if (bp[1] < REAL_KEY) {
+ } else if (bp[1] < REAL_KEY) {
if ((ndx =
__find_bigpair(hashp, rbufp, ndx, kp, (int)size)) > 0)
goto found;
@@ -849,8 +843,7 @@ hash_access(
n = *bp++;
ndx = 1;
off = hashp->BSIZE;
- }
- else {
+ } else {
save_bufp->flags &= ~BUF_PIN;
return (DBM_ERROR);
}
@@ -864,8 +857,7 @@ hash_access(
if (__addel(hashp, rbufp, key, val)) {
save_bufp->flags &= ~BUF_PIN;
return (DBM_ERROR);
- }
- else {
+ } else {
save_bufp->flags &= ~BUF_PIN;
return (SUCCESS);
}
@@ -886,8 +878,7 @@ found:
if (bp[ndx + 1] < REAL_KEY) {
if (__big_return(hashp, rbufp, ndx, val, 0))
return (DBM_ERROR);
- }
- else {
+ } else {
val->data = (uint8 *)rbufp->page + (int)bp[ndx + 1];
val->size = bp[ndx] - bp[ndx + 1];
}
@@ -956,8 +947,7 @@ hash_seq(
hashp->cbucket = -1;
return (ABNORMAL);
}
- }
- else
+ } else
bp = (uint16 *)hashp->cpage->page;
#ifdef DEBUG
@@ -981,8 +971,7 @@ hash_seq(
if (bp[ndx + 1] < REAL_KEY) {
if (__big_keydata(hashp, bufp, key, data, 1))
return (DBM_ERROR);
- }
- else {
+ } else {
key->data = (uint8 *)hashp->cpage->page + bp[ndx];
key->size = (ndx > 1 ? bp[ndx - 1] : hashp->BSIZE) - bp[ndx];
data->data = (uint8 *)hashp->cpage->page + bp[ndx + 1];
@@ -992,8 +981,7 @@ hash_seq(
hashp->cpage = NULL;
hashp->cbucket++;
hashp->cndx = 1;
- }
- else
+ } else
hashp->cndx = ndx;
}
return (SUCCESS);
diff --git a/lib/dbm/src/hash_buf.c b/lib/dbm/src/hash_buf.c
index 22e98c90a..581ba169a 100644
--- a/lib/dbm/src/hash_buf.c
+++ b/lib/dbm/src/hash_buf.c
@@ -120,8 +120,7 @@ __get_buf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp, int newpage)
bp = NULL;
if (!newpage)
is_disk = BUF_DISK;
- }
- else {
+ } else {
/* Grab buffer out of directory */
segment_ndx = addr & (hashp->SGSIZE - 1);
@@ -173,8 +172,7 @@ __get_buf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp, int newpage)
segp[segment_ndx] = bp;
#endif
}
- }
- else {
+ } else {
BUF_REMOVE(bp);
MRU_INSERT(bp);
}
@@ -225,8 +223,7 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp)
if (hashp->nbufs)
hashp->nbufs--;
- }
- else {
+ } else {
/* Kick someone out */
BUF_REMOVE(bp);
/*
@@ -331,8 +328,7 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp)
#endif
prev_bp->ovfl = bp;
bp->flags = 0;
- }
- else
+ } else
bp->flags = BUF_BUCKET;
MRU_INSERT(bp);
return (bp);
@@ -394,8 +390,7 @@ __buf_free(HTAB *hashp, int do_free, int to_disk)
BUF_REMOVE(bp);
free(bp);
bp = LRU;
- }
- else
+ } else
bp = bp->prev;
}
return (0);
diff --git a/lib/dbm/src/memmove.c b/lib/dbm/src/memmove.c
index c938774e5..93e8873a4 100644
--- a/lib/dbm/src/memmove.c
+++ b/lib/dbm/src/memmove.c
@@ -111,8 +111,7 @@ register size_t length;
TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
t = length & wmask;
TLOOP(*dst++ = *src++);
- }
- else {
+ } else {
/*
* Copy backwards. Otherwise essentially the same.
* Alignment works as before, except that it takes
diff --git a/lib/dbm/src/mktemp.c b/lib/dbm/src/mktemp.c
index 7a4be2b1a..b668ece18 100644
--- a/lib/dbm/src/mktemp.c
+++ b/lib/dbm/src/mktemp.c
@@ -127,8 +127,7 @@ _gettemp(char *path, register int *doopen, int extraFlags)
return (1);
if (errno != EEXIST)
return (0);
- }
- else if (stat(path, &sbuf))
+ } else if (stat(path, &sbuf))
return (errno == ENOENT ? 1 : 0);
/* tricky little algorithm for backward compatibility */
diff --git a/lib/dbm/tests/lots.c b/lib/dbm/tests/lots.c
index 0069b6913..91bba4965 100644
--- a/lib/dbm/tests/lots.c
+++ b/lib/dbm/tests/lots.c
@@ -249,19 +249,16 @@ VerifyRange(int32 low, int32 high, int32 should_exist, key_type_enum key_type)
/* got the item */
if (!should_exist) {
ReportError("Item exists but shouldn't: %ld", num);
- }
- else {
+ } else {
/* else verify the data */
VerifyData(&data, num, key_type);
}
- }
- else if (status > 0) {
+ } else if (status > 0) {
/* item not found */
if (should_exist) {
ReportError("Item not found but should be: %ld", num);
}
- }
- else {
+ } else {
/* database error */
ReportError("Database error");
return (-1);
@@ -285,8 +282,7 @@ GenData(int32 num)
data = (DBT *)malloc(sizeof(DBT));
data->size = 0;
data->data = 0;
- }
- else if (data->data) {
+ } else if (data->data) {
free(data->data);
}
@@ -328,8 +324,7 @@ AddOrDelRange(int32 low, int32 high, int action, key_type_enum key_type)
if (action == ADD_RANGE) {
TraceMe(1, ("Adding: %ld to %ld: %s keys", low, high,
key_type == USE_SMALL_KEY ? "SMALL" : "LARGE"));
- }
- else {
+ } else {
TraceMe(1, ("Deleting: %ld to %ld: %s keys", low, high,
key_type == USE_SMALL_KEY ? "SMALL" : "LARGE"));
}
@@ -341,8 +336,7 @@ AddOrDelRange(int32 low, int32 high, int action, key_type_enum key_type)
if (action == ADD_RANGE) {
data = GenData(num);
status = (*database->put)(database, key, data, 0);
- }
- else {
+ } else {
status = (*database->del)(database, key, 0);
}
@@ -350,13 +344,11 @@ AddOrDelRange(int32 low, int32 high, int action, key_type_enum key_type)
ReportError("Database error %s item: %ld",
action == ADD_RANGE ? "ADDING" : "DELETING",
num);
- }
- else if (status > 0) {
+ } else if (status > 0) {
ReportError("Could not %s item: %ld",
action == ADD_RANGE ? "ADD" : "DELETE",
num);
- }
- else if (action == ADD_RANGE) {
+ } else if (action == ADD_RANGE) {
#define SYNC_EVERY_TIME
#ifdef SYNC_EVERY_TIME
status = (*database->sync)(database, 0);
@@ -388,8 +380,7 @@ AddOrDelRange(int32 low, int32 high, int action, key_type_enum key_type)
if (action == ADD_RANGE) {
TraceMe(1, ("Successfully added: %ld to %ld", low, high));
- }
- else {
+ } else {
TraceMe(1, ("Successfully deleted: %ld to %ld", low, high));
}
@@ -524,8 +515,7 @@ main(int argc, char **argv)
if (1 || j) {
TestRange(START_RANGE, i, USE_LARGE_KEY);
j = 0;
- }
- else {
+ } else {
TestRange(START_RANGE, i, USE_SMALL_KEY);
j = 1;
}
@@ -545,8 +535,7 @@ main(int argc, char **argv)
#endif
exit(1);
}
- }
- else {
+ } else {
/* reopen database without closeing the other */
database = dbopen("test.db", O_RDWR | O_CREAT, 0644, DB_HASH, 0);
if (!database) {