[6.0] 66572d219 Monday morning flexelinting
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Thu Jul 11 09:35:11 UTC 2019
commit 66572d219cc36b8f598fa50f0c843b0cc550b3d8
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jan 21 09:16:46 2019 +0000
Monday morning flexelinting
diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index 750f5ddf7..7a09edf6a 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -73,7 +73,7 @@
} while (0)
-static double timeout = 5;
+static double timeout = 5; // XXX should be settable by arg ?
static void
cli_write(int sock, const char *s)
@@ -192,7 +192,7 @@ send_line(char *l)
cli_write(_line_sock, l);
cli_write(_line_sock, "\n");
if (*l)
- add_history(l);
+ AZ(add_history(l));
rl_callback_handler_install("varnish> ", send_line);
} else {
RL_EXIT(0);
@@ -234,6 +234,29 @@ varnishadm_completion (const char *text, int start, int end)
return (matches);
}
+static void
+pass_answer(int fd)
+{
+ unsigned u, status;
+ char *answer = NULL;
+
+ u = VCLI_ReadResult(fd, &status, &answer, timeout);
+ if (u) {
+ if (status == CLIS_COMMS)
+ RL_EXIT(0);
+ if (answer)
+ fprintf(stderr, "%s\n", answer);
+ RL_EXIT(1);
+ }
+
+ printf("%u\n", status);
+ if (answer) {
+ printf("%s\n", answer);
+ free(answer);
+ }
+ (void)fflush(stdout);
+}
+
/*
* No arguments given, simply pass bytes on stdin/stdout and CLI socket
* Send a "banner" to varnish, to provoke a welcome message.
@@ -242,7 +265,6 @@ static void
interactive(int sock)
{
struct pollfd fds[2];
- char buf[1024];
int i;
char *answer = NULL;
unsigned u, status;
@@ -293,25 +315,8 @@ interactive(int sock)
assert(i > 0);
if (fds[0].revents & POLLIN) {
/* Get rid of the prompt, kinda hackish */
- u = write(1, "\r \r", 13);
- u = VCLI_ReadResult(fds[0].fd, &status, &answer,
- timeout);
- if (u) {
- if (status == CLIS_COMMS)
- RL_EXIT(0);
- if (answer)
- fprintf(stderr, "%s\n", answer);
- RL_EXIT(1);
- }
-
- bprintf(buf, "%u\n", status);
- u = write(1, buf, strlen(buf));
- if (answer) {
- u = write(1, answer, strlen(answer));
- u = write(1, "\n", 1);
- free(answer);
- answer = NULL;
- }
+ printf("\r \r");
+ pass_answer(fds[0].fd);
rl_forced_update_display();
}
if (fds[1].revents & POLLIN) {
@@ -329,8 +334,6 @@ pass(int sock)
struct pollfd fds[2];
char buf[1024];
int i;
- char *answer = NULL;
- unsigned u, status;
ssize_t n;
fds[0].fd = sock;
@@ -343,26 +346,8 @@ pass(int sock)
continue;
}
assert(i > 0);
- if (fds[0].revents & POLLIN) {
- u = VCLI_ReadResult(fds[0].fd, &status, &answer,
- timeout);
- if (u) {
- if (status == CLIS_COMMS)
- RL_EXIT(0);
- if (answer)
- fprintf(stderr, "%s\n", answer);
- RL_EXIT(1);
- }
-
- bprintf(buf, "%u\n", status);
- u = write(1, buf, strlen(buf));
- if (answer) {
- u = write(1, answer, strlen(answer));
- u = write(1, "\n", 1);
- free(answer);
- answer = NULL;
- }
- }
+ if (fds[0].revents & POLLIN)
+ pass_answer(fds[0].fd);
if (fds[1].revents & POLLIN || fds[1].revents & POLLHUP) {
n = read(fds[1].fd, buf, sizeof buf - 1);
if (n == 0) {
@@ -392,8 +377,8 @@ usage(int status)
static int
n_arg_sock(const char *n_arg, const char *t_arg)
{
- char *T_arg = NULL, *T_start = NULL;
- char *S_arg = NULL;
+ char *T_arg, *T_start;
+ char *S_arg;
struct vsm *vsm;
char *p;
int sock;
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 4c999c350..95bc5f2ed 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -784,7 +784,9 @@ ved_stripgzip(struct req *req, const struct boc *boc)
ecx->l_crc += ilen;
}
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Straight through without processing.
+ */
static int v_matchproto_(vdp_fini_f)
ved_vdp_fini(struct req *req, void **priv)
diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c
index 3bea94871..20a4ac877 100644
--- a/lib/libvmod_blob/base64.c
+++ b/lib/libvmod_blob/base64.c
@@ -140,6 +140,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
unsigned u = 0, term = 0;
int n = 0;
size_t len = SIZE_MAX;
+ const char *s;
AN(buf);
AN(alpha);
@@ -149,7 +150,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
len = inlen;
for (int i = 0; len > 0 && i < strings->n; i++) {
- const char *s = strings->p[i];
+ s = strings->p[i];
if (s == NULL)
continue;
@@ -159,7 +160,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
}
while (*s && len) {
while (n < 4) {
- char b = alpha->i64[(unsigned) *s++];
+ char b = alpha->i64[(uint8_t) *s++];
u <<= 6;
if (b == ILL) {
errno = EINVAL;
@@ -170,7 +171,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
term++;
continue;
}
- u |= (unsigned) b;
+ u |= (uint8_t) b;
if (--len == 0)
break;
if (!*s)
diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c
index 3388fab4e..82bc00389 100644
--- a/lib/libvmod_debug/vmod_debug_obj.c
+++ b/lib/libvmod_debug/vmod_debug_obj.c
@@ -181,6 +181,8 @@ xyzzy_obj_opt__init(VRT_CTX,
if (args->valid_s)
AN(args->s);
+ (void)args->valid_b;
+ (void)args->b;
AN(op);
AZ(*op);
diff --git a/lib/libvmod_directors/shard_dir.h b/lib/libvmod_directors/shard_dir.h
index eeb17df64..e3a8b3128 100644
--- a/lib/libvmod_directors/shard_dir.h
+++ b/lib/libvmod_directors/shard_dir.h
@@ -42,10 +42,8 @@ enum healthy_e {
};
enum resolve_e {
- _RESOLVE_E_INVALID = 0,
#define VMODENUM(x) x,
#include "tbl_resolve.h"
- _RESOLVE_E_MAX
};
struct vbitmap;
More information about the varnish-commit
mailing list