[master] dd28fc739 Style(9) and whitespace OCD
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Tue Mar 12 19:23:07 UTC 2019
commit dd28fc739f47d08a95b3f29e39ec2db73d2fe79f
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Tue Mar 12 20:10:06 2019 +0100
Style(9) and whitespace OCD
Dealing with code style violations around the return keyword, I figured
I could automate that fix, so I tried with my favourite refactoring tool
and following those steps:
$ cat >return.cocci <<EOF
@@
expression rv;
@@
- return rv;
+ return (rv);
EOF
$ spatch --dir . --in-place --sp-file return.cocci
Unfortunately that leads to proper return statements having their return
value enclosed twice, like `return ((rv))`. So a bit more steps to go:
$ cat >rereturn.cocci <<EOF
@@
expression rv;
@@
- return ((rv));
+ return (rv);
EOF
$ spatch --dir . --in-place --sp-file rreeturn.cocci
At this point you don't want to touch bundled code, right? So let's take
care of libvgz and shout out to teken that saw no changes at all!
$ git checkout -- lib/libvgz/
The next step is to manually review all the changes, because Coccinelle
is not aware of how we break lines and unbreaks them. That's quite
tedious but I was waiting for someone and they are still late as I'm
describing the whole process.
Care was taken not to touch varnishtest to make it easier to sync with
vtest. A dedicated patch will follow.
diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index 19e3463b3..3a94413d8 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -115,7 +115,7 @@ cli_sock(const char *T_arg, const char *S_arg)
if (S_arg == NULL) {
fprintf(stderr, "Authentication required\n");
closefd(&sock);
- return(-1);
+ return (-1);
}
fd = open(S_arg, O_RDONLY);
if (fd < 0) {
diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c
index 2d2f2ba69..a3eae6eb2 100644
--- a/bin/varnishd/cache/cache_ban_build.c
+++ b/bin/varnishd/cache/cache_ban_build.c
@@ -206,9 +206,9 @@ ban_parse_oper(const char *p)
for (i = 0; i < BAN_OPERARRSZ; i++) {
if (!strcmp(p, oper[i]))
- return _BANS_OPER_OFF + i;
+ return (_BANS_OPER_OFF + i);
}
- return -1;
+ return (-1);
}
/*--------------------------------------------------------------------
@@ -254,9 +254,9 @@ BAN_AddTest(struct ban_proto *bp,
if (op < 0 ||
((1U << BAN_OPERIDX(op)) & arg_opervalid[BAN_ARGIDX(pv->tag)]) == 0)
return (ban_error(bp,
- "expected conditional (%s) got \"%s\"",
- arg_operhelp[BAN_ARGIDX(pv->tag)],
- a2));
+ "expected conditional (%s) got \"%s\"",
+ arg_operhelp[BAN_ARGIDX(pv->tag)],
+ a2));
if ((pv->flag & BANS_FLAG_DURATION) == 0) {
assert(! BANS_HAS_ARG2_DOUBLE(pv->tag));
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index c4b1f0998..a48715055 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -69,7 +69,7 @@ static const char *
vgz_msg(const struct vgz *vg)
{
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
- return vg->vz.msg ? vg->vz.msg : "(null)";
+ return (vg->vz.msg ? vg->vz.msg : "(null)");
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index a778bf535..f43e214ff 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -998,7 +998,7 @@ hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh)
assert(oh->refcnt > 1);
oh->refcnt--;
Lck_Unlock(&oh->mtx);
- return(1);
+ return (1);
}
if (oh->refcnt == 1)
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 534cd5d2e..5e3c92cd0 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -143,7 +143,7 @@ HTTP_estimate(unsigned nhttp)
{
/* XXX: We trust the structs to size-aligned as necessary */
- return (PRNDUP(sizeof (struct http) + sizeof(txt) * nhttp + nhttp));
+ return (PRNDUP(sizeof(struct http) + sizeof(txt) * nhttp + nhttp));
}
struct http *
@@ -989,7 +989,7 @@ HTTP_GetStatusPack(struct worker *wrk, struct objcore *oc)
ptr = ObjGetAttr(wrk, oc, OA_HEADERS, NULL);
AN(ptr);
- return(vbe16dec(ptr + 2));
+ return (vbe16dec(ptr + 2));
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c
index 4021166e4..87dceb5ca 100644
--- a/bin/varnishd/cache/cache_lck.c
+++ b/bin/varnishd/cache/cache_lck.c
@@ -255,7 +255,7 @@ Lck_Delete(struct lock *lck)
struct VSC_lck *
Lck_CreateClass(struct vsc_seg **sg, const char *name)
{
- return(VSC_lck_New(NULL, sg, name));
+ return (VSC_lck_New(NULL, sg, name));
}
void
diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c
index aa7adc0c4..9add62d3c 100644
--- a/bin/varnishd/cache/cache_mempool.c
+++ b/bin/varnishd/cache/cache_mempool.c
@@ -305,7 +305,7 @@ MPL_Get(struct mempool *mpl, unsigned *size)
CHECK_OBJ_NOTNULL(mi, MEMITEM_MAGIC);
/* Throw away sizeof info for FlexeLint: */
- return ((void*)(uintptr_t)(mi+1));
+ return ((void *)(uintptr_t)(mi + 1));
}
void
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index 77a3771a7..d46f4e4da 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -318,7 +318,7 @@ ObjGetLen(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
AZ(ObjGetU64(wrk, oc, OA_LEN, &len));
- return(len);
+ return (len);
}
/*====================================================================
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index fbae9dadf..9289a60ba 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -83,7 +83,7 @@ reqbody_status_2str(enum req_body_state_e e)
#define REQ_BODY(U) case REQ_BODY_##U: return("R_BODY_" #U);
#include "tbl/req_body.h"
default:
- return("?");
+ return ("?");
}
}
@@ -106,12 +106,12 @@ const char *
sess_close_2str(enum sess_close sc, int want_desc)
{
switch (sc) {
- case SC_NULL: return(want_desc ? "(null)": "NULL");
+ case SC_NULL: return (want_desc ? "(null)" : "NULL");
#define SESS_CLOSE(nm, s, err, desc) \
case SC_##nm: return(want_desc ? desc : #nm);
#include "tbl/sess_close.h"
- default: return(want_desc ? "(invalid)" : "INVALID");
+ default: return (want_desc ? "(invalid)" : "INVALID");
}
}
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index 903c973b5..13c4ed07f 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -254,7 +254,7 @@ VRB_Ignore(struct req *req)
if (req->req_body_status == REQ_BODY_WITH_LEN ||
req->req_body_status == REQ_BODY_WITHOUT_LEN)
(void)VRB_Iterate(req, httpq_req_body_discard, NULL);
- return(0);
+ return (0);
}
/*----------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c
index 1eb4f5164..0e2fbd4f7 100644
--- a/bin/varnishd/cache/cache_tcp_pool.c
+++ b/bin/varnishd/cache/cache_tcp_pool.c
@@ -581,7 +581,7 @@ struct vtp_cs {
static inline int
tmo2msec(vtim_dur tmo)
{
- return ( (int)floor(tmo * 1000.0) );
+ return ((int)floor(tmo * 1000.0));
}
static int v_matchproto_(cp_open_f)
@@ -763,7 +763,7 @@ VTP_Ref(const struct suckaddr *ip4, const struct suckaddr *ip6, const char *uds,
if (ip6 != NULL)
tp->ip6 = VSA_Clone(ip6);
}
- return(VCP_New(tp->cp, id, tp, methods));
+ return (VCP_New(tp->cp, id, tp, methods));
}
/*--------------------------------------------------------------------
@@ -837,7 +837,7 @@ VTP_Get(struct tcp_pool *tp, vtim_dur tmo, struct worker *wrk,
unsigned force_fresh, int *err)
{
- return VCP_Get(tp->cp, tmo, wrk, force_fresh, err);
+ return (VCP_Get(tp->cp, tmo, wrk, force_fresh, err));
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 8940a6797..2edfb85b6 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -154,7 +154,7 @@ VRT_GetHdr(VRT_CTX, const struct gethdr_s *hs)
if (hs->where == HDR_OBJ) {
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
- return(HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore,
+ return (HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore,
hs->what));
}
hp = VRT_selecthttp(ctx, hs->where);
@@ -362,7 +362,7 @@ VRT_Strands(char *d, size_t dl, VCL_STRANDS s)
if (s->p[i] != NULL && *s->p[i] != '\0') {
x = strlen(s->p[i]);
if (b + x >= e)
- return(NULL);
+ return (NULL);
memcpy(b, s->p[i], x);
b += x;
}
@@ -824,7 +824,7 @@ int
VRT_strcmp(const char *s1, const char *s2)
{
if (s1 == NULL || s2 == NULL)
- return(1);
+ return (1);
return (strcmp(s1, s2));
}
@@ -839,7 +839,7 @@ VCL_BOOL
VRT_ipcmp(VCL_IP sua1, VCL_IP sua2)
{
if (sua1 == NULL || sua2 == NULL)
- return(1);
+ return (1);
return (VSA_Compare_IP(sua1, sua2));
}
diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c
index 20a0cf6fc..9cd0de3e7 100644
--- a/bin/varnishd/cache/cache_vrt_re.c
+++ b/bin/varnishd/cache/cache_vrt_re.c
@@ -121,10 +121,10 @@ VRT_regsub(VRT_CTX, int all, const char *str, void *re,
/* If it didn't match, we can return the original string */
if (i == VRE_ERROR_NOMATCH)
- return(str);
+ return (str);
if (i < VRE_ERROR_NOMATCH ) {
VSLb(ctx->vsl, SLT_VCL_Error, "Regexp matching returned %d", i);
- return(str);
+ return (str);
}
u = WS_Reserve(ctx->ws, 0);
@@ -162,7 +162,7 @@ VRT_regsub(VRT_CTX, int all, const char *str, void *re,
WS_Release(ctx->ws, 0);
VSLb(ctx->vsl, SLT_VCL_Error,
"Regexp matching returned %d", i);
- return(str);
+ return (str);
}
} while (i != VRE_ERROR_NOMATCH);
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index afd0d475a..c734e0a5a 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -692,8 +692,7 @@ VRT_r_bereq_xid(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
AN(ctx->bo->vsl);
- return (WS_Printf(ctx->ws, "%u",
- VXID(ctx->bo->vsl->wid)));
+ return (WS_Printf(ctx->ws, "%u", VXID(ctx->bo->vsl->wid)));
}
VCL_STRING
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index ce450584e..a0fc4eacb 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -270,7 +270,7 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio)
VSL(SLT_Debug, 0,
"Failing due to reqpoolfail (next= 0x%jx)",
reqpoolfail);
- return(retval);
+ return (retval);
}
}
diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c
index fcedbef5f..515de002c 100644
--- a/bin/varnishd/hash/hash_critbit.c
+++ b/bin/varnishd/hash/hash_critbit.c
@@ -268,7 +268,7 @@ hcb_insert(struct worker *wrk, struct hcb_root *root, const uint8_t *digest,
y2->leaf[s2] = *p;
VWMB();
*p = hcb_r_y(y2);
- return(oh2);
+ return (oh2);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index c2386dcb1..4f6e8efd1 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -65,7 +65,7 @@ http1_getstate(const struct sess *sp)
uintptr_t *p;
AZ(SES_Get_proto_priv(sp, &p));
- return (const char *)*p;
+ return ((const char *)*p);
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c
index 736febf85..4171c6151 100644
--- a/bin/varnishd/http1/cache_http1_vfp.c
+++ b/bin/varnishd/http1/cache_http1_vfp.c
@@ -290,5 +290,5 @@ V1F_Setup_Fetch(struct vfp_ctx *vfc, struct http_conn *htc)
break;
}
vfe->priv1 = htc;
- return 0;
+ return (0);
}
diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c
index cd2794612..7f1207c63 100644
--- a/bin/varnishd/mgt/mgt_acceptor.c
+++ b/bin/varnishd/mgt/mgt_acceptor.c
@@ -103,9 +103,9 @@ mac_opensocket(struct listen_sock *ls)
errno = 0;
if (ls->perms->mode != 0 &&
chmod(ls->endpoint, ls->perms->mode) != 0)
- return errno;
+ return (errno);
if (chown(ls->endpoint, ls->perms->uid, ls->perms->gid) != 0)
- return errno;
+ return (errno);
}
MCH_Fd_Inherit(ls->sock, "sock");
return (0);
@@ -134,7 +134,7 @@ MAC_reopen_sockets(void)
"Could not reopen listen socket %s: %s",
ls->endpoint, vstrerror(err));
}
- return fail;
+ return (fail);
}
/*--------------------------------------------------------------------*/
@@ -167,9 +167,9 @@ mk_listen_sock(const struct listen_arg *la, const struct suckaddr *sa)
if (fail != EAFNOSUPPORT)
ARGV_ERR("Could not get socket %s: %s\n",
la->endpoint, vstrerror(fail));
- return(NULL);
+ return (NULL);
}
- return(ls);
+ return (ls);
}
static int v_matchproto_(vss_resolved_f)
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index 92a6313ca..b28a26953 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -648,7 +648,7 @@ MCH_Start_Child(void)
mgt_launch_child(NULL);
if (child_state != CH_RUNNING)
return (2);
- return(0);
+ return (0);
}
/*====================================================================
diff --git a/bin/varnishd/mgt/mgt_jail_solaris.c b/bin/varnishd/mgt/mgt_jail_solaris.c
index f594eaede..dda89efae 100644
--- a/bin/varnishd/mgt/mgt_jail_solaris.c
+++ b/bin/varnishd/mgt/mgt_jail_solaris.c
@@ -242,13 +242,13 @@ static inline enum jail_gen_e
jail_subproc_gen(enum jail_subproc_e e)
{
assert(e < (1 << JAILG_SHIFT));
- return (enum jail_gen_e)e;
+ return ((enum jail_gen_e)e);
}
static inline enum jail_gen_e
jail_master_gen(enum jail_master_e e)
{
- return (enum jail_gen_e)(e << JAILG_SHIFT);
+ return ((enum jail_gen_e)(e << JAILG_SHIFT));
}
static int v_matchproto_(jail_init_f)
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 28fc35579..161063221 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -358,7 +358,7 @@ mgt_vcl_cache_vmod(const char *nm, const char *fm, const char *to)
closefd(&fi);
AZ(fchmod(fo, 0444));
closefd(&fo);
- return(ret);
+ return (ret);
}
void
diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c
index 926c6b5a9..99207e469 100644
--- a/bin/varnishd/storage/stevedore_utils.c
+++ b/bin/varnishd/storage/stevedore_utils.c
@@ -210,5 +210,5 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx)
/* Round down */
l -= (l % *granularity);
- return(l);
+ return (l);
}
diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
index fc316424b..d481358bb 100644
--- a/bin/varnishd/waiter/cache_waiter.c
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -120,7 +120,7 @@ Wait_HeapDue(const struct waiter *w, struct waited **wpp)
}
if (wpp != NULL)
*wpp = wp;
- return(Wait_When(wp));
+ return (Wait_When(wp));
}
/**********************************************************************/
diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c
index 8ab242e78..8a50c260c 100644
--- a/bin/varnishd/waiter/cache_waiter_kqueue.c
+++ b/bin/varnishd/waiter/cache_waiter_kqueue.c
@@ -131,7 +131,7 @@ vwk_thread(void *priv)
closefd(&vwk->pipe[0]);
closefd(&vwk->pipe[1]);
closefd(&vwk->kq);
- return(NULL);
+ return (NULL);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c
index 5d34a5539..dc5e82805 100644
--- a/bin/varnishd/waiter/cache_waiter_ports.c
+++ b/bin/varnishd/waiter/cache_waiter_ports.c
@@ -211,7 +211,7 @@ vws_thread(void *priv)
for (ei = 0; ei < nevents; ei++)
vws_port_ev(vws, w, &ev[ei], now);
}
- return NULL;
+ return (NULL);
}
/*--------------------------------------------------------------------*/
diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c
index e5cf0c411..45363b302 100644
--- a/lib/libvarnish/vcli_serve.c
+++ b/lib/libvarnish/vcli_serve.c
@@ -410,7 +410,7 @@ cls_feed(struct VCLS_fd *cfd, const char *p, const char *e)
VAV_Free(av);
VSB_destroy(&cli->cmd);
if (i)
- return(i);
+ return (i);
}
} else {
/* "<< nonce" mode */
diff --git a/lib/libvarnish/vjsn.c b/lib/libvarnish/vjsn.c
index 61280496a..2ef5629ca 100644
--- a/lib/libvarnish/vjsn.c
+++ b/lib/libvarnish/vjsn.c
@@ -234,7 +234,7 @@ vjsn_string(struct vjsn *js)
case 'u':
vjsn_unicode(js, &p);
if (js->err != NULL)
- return(NULL);
+ return (NULL);
break;
default:
js->err = "Bad string escape";
diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c
index 9502e9dc4..13bad74d1 100644
--- a/lib/libvarnish/vnum.c
+++ b/lib/libvarnish/vnum.c
@@ -80,7 +80,7 @@ VNUMpfx(const char *p, const char **t)
break;
}
if (e > 0.0)
- return(nan("")); // No digits
+ return (nan("")); // No digits
if (*p == 'e' || *p == 'E') {
p++;
if (*p == '-' || *p == '+')
diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c
index baf61f27e..d222d6bb4 100644
--- a/lib/libvarnish/vtcp.c
+++ b/lib/libvarnish/vtcp.c
@@ -518,7 +518,7 @@ VTCP_listen_on(const char *addr, const char *def_port, int depth,
sock = VSS_resolver(addr, def_port, vtcp_lo_cb, &h, errp);
if (*errp != NULL)
return (-1);
- return(sock);
+ return (sock);
}
/*--------------------------------------------------------------------
diff --git a/lib/libvarnish/vus.c b/lib/libvarnish/vus.c
index 12ee9af31..200679fc0 100644
--- a/lib/libvarnish/vus.c
+++ b/lib/libvarnish/vus.c
@@ -53,13 +53,13 @@ VUS_resolver(const char *path, vus_resolved_f *func, void *priv,
*err = NULL;
if (strlen(path) + 1 > sizeof(uds.sun_path)) {
*err = "Path too long for a Unix domain socket";
- return(-1);
+ return (-1);
}
bprintf(uds.sun_path, "%s", path);
uds.sun_family = PF_UNIX;
if (func != NULL)
ret = func(priv, &uds);
- return(ret);
+ return (ret);
}
int
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index f10c77e36..8c133a61e 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -857,7 +857,7 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf)
vf->b = NULL;
vf->e = NULL;
if (vg->refs > 0)
- return(0);
+ return (0);
if (vg->cluster) {
assert(vg->s == NULL);
diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c
index 4d088ecd1..8f19a0005 100644
--- a/lib/libvcc/vcc_symb.c
+++ b/lib/libvcc/vcc_symb.c
@@ -45,13 +45,13 @@
static vcc_kind_t
VCC_HandleKind(vcc_type_t fmt)
{
- if (fmt == ACL) return(SYM_ACL);
- if (fmt == BACKEND) return(SYM_BACKEND);
- if (fmt == PROBE) return(SYM_PROBE);
- if (fmt == STEVEDORE) return(SYM_STEVEDORE);
- if (fmt == SUB) return(SYM_SUB);
- if (fmt == INSTANCE) return(SYM_INSTANCE);
- return(SYM_NONE);
+ if (fmt == ACL) return (SYM_ACL);
+ if (fmt == BACKEND) return (SYM_BACKEND);
+ if (fmt == PROBE) return (SYM_PROBE);
+ if (fmt == STEVEDORE) return (SYM_STEVEDORE);
+ if (fmt == SUB) return (SYM_SUB);
+ if (fmt == INSTANCE) return (SYM_INSTANCE);
+ return (SYM_NONE);
}
void
diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c
index 594b84881..1ced6472f 100644
--- a/lib/libvmod_blob/base64.c
+++ b/lib/libvmod_blob/base64.c
@@ -39,19 +39,19 @@
size_t
base64nopad_encode_l(size_t l)
{
- return base64_l(l) + 4;
+ return (base64_l(l) + 4);
}
size_t
base64_encode_l(size_t l)
{
- return (((base64_l(l)) + 3) & ~3) + 1;
+ return ((((base64_l(l)) + 3) & ~3) + 1);
}
size_t
base64_decode_l(size_t l)
{
- return ((l) * 3) >> 2;
+ return (((l) * 3) >> 2);
}
static inline int
@@ -62,19 +62,19 @@ decode(char *restrict *restrict dest, const char *restrict const buf,
if (n <= 1) {
errno = EINVAL;
- return -1;
+ return (-1);
}
d = *dest;
for (int i = 0; i < n - 1; i++) {
if (d == buf + buflen) {
errno = ENOMEM;
- return -1;
+ return (-1);
}
*d++ = (u >> 16) & 0xff;
u <<= 8;
}
*dest += d - *dest;
- return 1;
+ return (1);
}
ssize_t
@@ -91,14 +91,14 @@ base64_encode(const enum encoding enc, const enum case_e kase,
AN(buf);
AN(alpha);
if (in == NULL || inlength == 0)
- return 0;
+ return (0);
if ((enc == BASE64URLNOPAD &&
buflen < base64nopad_encode_l(inlength)) ||
(enc != BASE64URLNOPAD &&
buflen < base64_encode_l(inlength))) {
errno = ENOMEM;
- return -1;
+ return (-1);
}
while (end - in >= 3) {
@@ -126,7 +126,7 @@ base64_encode(const enum encoding enc, const enum case_e kase,
}
}
assert(p >= buf && p - buf <= buflen);
- return p - buf;
+ return (p - buf);
}
ssize_t
@@ -155,7 +155,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
continue;
if (*s && term) {
errno = EINVAL;
- return -1;
+ return (-1);
}
while (*s && len) {
while (n < 4) {
@@ -163,7 +163,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
u <<= 6;
if (b == ILL) {
errno = EINVAL;
- return -1;
+ return (-1);
}
n++;
if (b == PAD) {
@@ -178,7 +178,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
}
if (n == 4) {
if (decode(&dest, buf, buflen, u, n-term) < 0)
- return -1;
+ return (-1);
n = 0;
}
}
@@ -187,8 +187,8 @@ base64_decode(const enum encoding dec, char *restrict const buf,
if (!alpha->padding)
u <<= (6 * (4 - n));
if (decode(&dest, buf, buflen, u, n-term) < 0)
- return -1;
+ return (-1);
}
- return dest - buf;
+ return (dest - buf);
}
diff --git a/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c
index 2306a2fec..79a44feb9 100644
--- a/lib/libvmod_blob/hex.c
+++ b/lib/libvmod_blob/hex.c
@@ -59,19 +59,19 @@ const uint8_t nibble[] = {
size_t
hex_encode_l(size_t l)
{
- return ((l) << 1) + 1;
+ return (((l) << 1) + 1);
}
size_t
hex_decode_l(size_t l)
{
- return ((l) + 1) >> 1;
+ return (((l) + 1) >> 1);
}
static inline char
hex2byte(const unsigned char hi, const unsigned char lo)
{
- return (nibble[hi - '0'] << 4) | nibble[lo - '0'];
+ return ((nibble[hi - '0'] << 4) | nibble[lo - '0']);
}
ssize_t
@@ -85,9 +85,9 @@ hex_encode(const enum encoding enc, const enum case_e kase,
AN(buf);
assert(enc == HEX);
if (in == NULL || inlen == 0)
- return 0;
+ return (0);
if (buflen < hex_encode_l(inlen))
- return -1;
+ return (-1);
if (kase == UPPER)
alphabet = hex_alphabet[1];
@@ -97,7 +97,7 @@ hex_encode(const enum encoding enc, const enum case_e kase,
*p++ = alphabet[in[i] & 0x0f];
}
- return p - buf;
+ return (p - buf);
}
ssize_t
@@ -130,13 +130,13 @@ hex_decode(const enum encoding dec, char *restrict const buf,
}
if (len == 0)
- return 0;
+ return (0);
if (n != -1 && len > n)
len = n;
if (((len+1) >> 1) > buflen) {
errno = ENOMEM;
- return -1;
+ return (-1);
}
if (len & 1) {
extranib = '0';
@@ -160,5 +160,5 @@ hex_decode(const enum encoding dec, char *restrict const buf,
extranib = *s;
}
assert(dest <= buf + buflen);
- return dest - buf;
+ return (dest - buf);
}
diff --git a/lib/libvmod_blob/id.c b/lib/libvmod_blob/id.c
index 3fc8d5280..e429db3ac 100644
--- a/lib/libvmod_blob/id.c
+++ b/lib/libvmod_blob/id.c
@@ -38,13 +38,13 @@
size_t
id_encode_l(size_t l)
{
- return l + 1;
+ return (l + 1);
}
size_t
id_decode_l(size_t l)
{
- return l;
+ return (l);
}
ssize_t
@@ -57,12 +57,12 @@ id_encode(const enum encoding enc, const enum case_e kase,
AN(buf);
if (buflen < inlen + 1)
- return -1;
+ return (-1);
if (in == NULL || inlen == 0)
- return 0;
+ return (0);
memcpy(buf, in, inlen);
- return inlen;
+ return (inlen);
}
ssize_t
@@ -92,11 +92,11 @@ id_decode(const enum encoding enc,
c -= len;
if ((outlen += len) > buflen) {
errno = ENOMEM;
- return -1;
+ return (-1);
}
memcpy(dest, s, len);
dest += len;
}
- return outlen;
+ return (outlen);
}
diff --git a/lib/libvmod_blob/url.c b/lib/libvmod_blob/url.c
index 1713bb5ab..f035bb6ae 100644
--- a/lib/libvmod_blob/url.c
+++ b/lib/libvmod_blob/url.c
@@ -46,13 +46,13 @@ enum state_e {
size_t
url_encode_l(size_t l)
{
- return (l * 3) + 1;
+ return ((l * 3) + 1);
}
size_t
url_decode_l(size_t l)
{
- return l;
+ return (l);
}
/*
@@ -90,7 +90,7 @@ url_encode(const enum encoding enc, const enum case_e kase,
AN(buf);
assert(enc == URL);
if (in == NULL || inlen == 0)
- return 0;
+ return (0);
if (kase == UPPER)
alphabet = hex_alphabet[1];
@@ -98,19 +98,19 @@ url_encode(const enum encoding enc, const enum case_e kase,
for (int i = 0; i < inlen; i++) {
if (isunreserved(in[i])) {
if (p == end)
- return -1;
+ return (-1);
*p++ = in[i];
}
else {
if (p + 3 > end)
- return -1;
+ return (-1);
*p++ = '%';
*p++ = alphabet[(in[i] & 0xf0) >> 4];
*p++ = alphabet[in[i] & 0x0f];
}
}
- return p - buf;
+ return (p - buf);
}
ssize_t
@@ -146,7 +146,7 @@ url_decode(const enum encoding dec, char *restrict const buf,
else {
if (dest == end) {
errno = ENOMEM;
- return -1;
+ return (-1);
}
*dest++ = *s;
}
@@ -155,19 +155,19 @@ url_decode(const enum encoding dec, char *restrict const buf,
if (isoutofrange(*s) ||
(nib = nibble[*s - '0']) == ILL) {
errno = EINVAL;
- return -1;
+ return (-1);
}
state = FIRSTNIB;
break;
case FIRSTNIB:
if (dest == end) {
errno = ENOMEM;
- return -1;
+ return (-1);
}
if (isoutofrange(*s) ||
(nib2 = nibble[*s - '0']) == ILL) {
errno = EINVAL;
- return -1;
+ return (-1);
}
*dest++ = (nib << 4) | nib2;
nib = 0;
@@ -182,8 +182,8 @@ url_decode(const enum encoding dec, char *restrict const buf,
}
if (state != NORMAL) {
errno = EINVAL;
- return -1;
+ return (-1);
}
assert(dest <= end);
- return dest - buf;
+ return (dest - buf);
}
diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c
index d032a439b..7820e810c 100644
--- a/lib/libvmod_blob/vmod_blob.c
+++ b/lib/libvmod_blob/vmod_blob.c
@@ -143,7 +143,7 @@ decode_l(enum encoding dec, VCL_STRANDS s)
if (s->p[i] != NULL && *s->p[i] != '\0')
len += strlen(s->p[i]);
- return(func[dec].decode_l(len));
+ return (func[dec].decode_l(len));
}
static void
@@ -175,9 +175,9 @@ check_enc_case(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, enum encoding enc,
{
if (!encodes_hex(enc) && kase != DEFAULT) {
VERR(ctx, "case %s is illegal with encoding %s", case_s, encs);
- return 0;
+ return (0);
}
- return 1;
+ return (1);
}
/* Objects */
@@ -373,7 +373,7 @@ encode(VRT_CTX, enum encoding enc, enum case_e kase, VCL_BLOB b)
AENC(enc);
if (b == NULL)
- return NULL;
+ return (NULL);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
snap = WS_Snapshot(ctx->ws);
@@ -386,16 +386,16 @@ encode(VRT_CTX, enum encoding enc, enum case_e kase, VCL_BLOB b)
ERRNOMEM(ctx, "cannot encode");
WS_Release(ctx->ws, 0);
WS_Reset(ctx->ws, snap);
- return NULL;
+ return (NULL);
}
if (len == 0) {
WS_Release(ctx->ws, 0);
WS_Reset(ctx->ws, snap);
- return "";
+ return ("");
}
buf[len] = '\0';
WS_Release(ctx->ws, len + 1);
- return buf;
+ return (buf);
}
VCL_STRING v_matchproto_(td_blob_encode)
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 8bcd48c33..17454ba49 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -148,7 +148,7 @@ xyzzy_test_priv_task(VRT_CTX, struct vmod_priv *priv, VCL_STRING s)
char *n = realloc(priv->priv,
strlen(priv->priv) + strlen(s) + 2);
if (n == NULL)
- return NULL;
+ return (NULL);
strcat(n, " ");
strcat(n, s);
priv->priv = n;
@@ -383,7 +383,7 @@ event_discard(VRT_CTX, void *priv)
VRT_RemoveVFP(ctx, &xyzzy_rot13);
if (--loads)
- return(0);
+ return (0);
/*
* The vsc and vsc_seg variables are not per-VCL, they are
@@ -394,7 +394,7 @@ event_discard(VRT_CTX, void *priv)
if (vsc)
VSC_debug_Destroy(&vsc_seg);
- return(0);
+ return (0);
}
int v_matchproto_(vmod_event_f)
diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c
index 1483098ff..70d709c43 100644
--- a/lib/libvmod_directors/shard_cfg.c
+++ b/lib/libvmod_directors/shard_cfg.c
@@ -96,7 +96,7 @@ shard_change_get(VRT_CTX, struct vmod_priv *priv,
shard_err0(ctx, shardd,
"cannot change more than one shard director "
"at a time");
- return NULL;
+ return (NULL);
}
return (change);
}
@@ -104,7 +104,7 @@ shard_change_get(VRT_CTX, struct vmod_priv *priv,
change = WS_Alloc(ctx->ws, sizeof(*change));
if (change == NULL) {
shard_err0(ctx, shardd, "could not get workspace");
- return NULL;
+ return (NULL);
}
INIT_OBJ(change, SHARD_CHANGE_MAGIC);
@@ -159,13 +159,13 @@ shard_change_task_backend(VRT_CTX,
change = shard_change_get(ctx, priv, shardd);
if (change == NULL)
- return 0;
+ return (0);
b = WS_Alloc(ctx->ws, sizeof(*b));
if (b == NULL) {
shard_err(ctx, shardd, ".%s_backend() WS_Alloc() failed",
task_e == ADD_BE ? "add" : "remove");
- return 0;
+ return (0);
}
b->backend = be;
@@ -174,7 +174,7 @@ shard_change_task_backend(VRT_CTX,
shard_change_task_add(ctx, change, task_e, b);
- return 1;
+ return (1);
}
/*
@@ -187,16 +187,16 @@ shardcfg_add_backend(VRT_CTX, struct vmod_priv *priv,
VCL_DURATION rampup)
{
AN(be);
- return shard_change_task_backend(ctx, priv, shardd, ADD_BE,
- be, ident, rampup);
+ return (shard_change_task_backend(ctx, priv, shardd, ADD_BE,
+ be, ident, rampup));
}
VCL_BOOL
shardcfg_remove_backend(VRT_CTX, struct vmod_priv *priv,
const struct sharddir *shardd, VCL_BACKEND be, VCL_STRING ident)
{
- return shard_change_task_backend(ctx, priv, shardd, REMOVE_BE,
- be, ident, 0);
+ return (shard_change_task_backend(ctx, priv, shardd, REMOVE_BE,
+ be, ident, 0));
}
VCL_BOOL
@@ -208,11 +208,11 @@ shardcfg_clear(VRT_CTX, struct vmod_priv *priv, const struct sharddir *shardd)
change = shard_change_get(ctx, priv, shardd);
if (change == NULL)
- return 0;
+ return (0);
shard_change_task_add(ctx, change, CLEAR, NULL);
- return 1;
+ return (1);
}
/*
@@ -226,7 +226,7 @@ static int
circlepoint_compare(const struct shard_circlepoint *a,
const struct shard_circlepoint *b)
{
- return (a->point == b->point) ? 0 : ((a->point > b->point) ? 1 : -1);
+ return ((a->point == b->point) ? 0 : ((a->point > b->point) ? 1 : -1));
}
static void
@@ -322,7 +322,7 @@ shardcfg_backend_cmp(const struct shard_backend *a,
/* vcl_names are unique, so we can compare the backend pointers */
if (ai == NULL && bi == NULL)
- return a->backend != b->backend;
+ return (a->backend != b->backend);
if (ai == NULL)
ai = VRT_BACKEND_string(a->backend);
@@ -332,7 +332,7 @@ shardcfg_backend_cmp(const struct shard_backend *a,
AN(ai);
AN(bi);
- return strcmp(ai, bi);
+ return (strcmp(ai, bi));
}
/* for removal, we delete all instances if the backend matches */
@@ -343,9 +343,9 @@ shardcfg_backend_del_cmp(const struct shard_backend *task,
assert(task->backend || task->ident);
if (task->ident == NULL)
- return task->backend != b->backend;
+ return (task->backend != b->backend);
- return shardcfg_backend_cmp(task, b);
+ return (shardcfg_backend_cmp(task, b));
}
static const struct shard_backend *
@@ -362,9 +362,9 @@ shardcfg_backend_lookup(const struct backend_reconfig *re,
if (bb[i].backend == NULL)
continue; // hole
if (!shardcfg_backend_cmp(b, &bb[i]))
- return &bb[i];
+ return (&bb[i]);
}
- return NULL;
+ return (NULL);
}
static void
@@ -587,15 +587,15 @@ shardcfg_reconfigure(VRT_CTX, struct vmod_priv *priv,
if (replicas <= 0) {
shard_err(ctx, shardd,
".reconfigure() invalid replicas argument %ld", replicas);
- return 0;
+ return (0);
}
change = shard_change_get(ctx, priv, shardd);
if (change == NULL)
- return 0;
+ return (0);
if (VSTAILQ_FIRST(&change->tasks) == NULL)
- return 1;
+ return (1);
sharddir_wrlock(shardd);
@@ -609,7 +609,7 @@ shardcfg_reconfigure(VRT_CTX, struct vmod_priv *priv,
if (shardd->n_backend == 0) {
shard_err0(ctx, shardd, ".reconfigure() no backends");
sharddir_unlock(shardd);
- return 0;
+ return (0);
}
shardcfg_hashcircle(shardd, replicas);
diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c
index 645d394a7..ac870cd6b 100644
--- a/lib/libvmod_directors/shard_dir.c
+++ b/lib/libvmod_directors/shard_dir.c
@@ -155,7 +155,7 @@ shard_lookup(const struct sharddir *shardd, const uint32_t key)
low = i;
} while (idx == -1);
- return idx;
+ return (idx);
}
static int
@@ -172,7 +172,7 @@ shard_next(struct shard_state *state, VCL_INT skip, VCL_BOOL healthy)
CHECK_OBJ_NOTNULL(state->shardd, SHARDDIR_MAGIC);
if (state->pickcount >= state->shardd->n_backend)
- return -1;
+ return (-1);
ringsz = state->shardd->n_backend * state->shardd->replicas;
@@ -217,7 +217,7 @@ shard_next(struct shard_state *state, VCL_INT skip, VCL_BOOL healthy)
if (++(state->idx) == ringsz)
state->idx = 0;
}
- return chosen;
+ return (chosen);
}
void
More information about the varnish-commit
mailing list