clean more whitespace 3
authorAndy Green <andy.green@linaro.org>
Sun, 6 Dec 2015 00:40:00 +0000 (08:40 +0800)
committerAndy Green <andy.green@linaro.org>
Sun, 6 Dec 2015 00:40:00 +0000 (08:40 +0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/client-handshake.c
lib/client-parser.c
lib/client.c
lib/context.c
lib/daemonize.c
lib/header.c

index 11dcc29..094ebfa 100644 (file)
@@ -1,10 +1,8 @@
 #include "private-libwebsockets.h"
 
-struct lws *lws_client_connect_2(
-       struct lws_context *context,
-       struct lws *wsi
-) {
-       struct lws_pollfd pfd;
+struct lws *
+lws_client_connect_2(struct lws_context *context, struct lws *wsi)
+{
 #ifdef LWS_USE_IPV6
        struct sockaddr_in6 server_addr6;
        struct sockaddr_in6 client_addr6;
@@ -12,17 +10,14 @@ struct lws *lws_client_connect_2(
 #endif
        struct sockaddr_in server_addr4;
        struct sockaddr_in client_addr4;
-
+       struct lws_pollfd pfd;
        struct sockaddr *v;
-       int n;
-       int plen = 0;
+       int n, plen = 0;
        const char *ads;
 
        lwsl_client("lws_client_connect_2\n");
 
-       /*
-        * proxy?
-        */
+       /* proxy? */
 
        if (context->http_proxy_port) {
                plen = sprintf((char *)context->service_buffer,
@@ -216,14 +211,13 @@ struct lws *lws_client_connect_2(
 
        if (connect(wsi->sock, v, n) == -1 || LWS_ERRNO == LWS_EISCONN) {
 
-               if (LWS_ERRNO == LWS_EALREADY
-                       || LWS_ERRNO == LWS_EINPROGRESS
-                       || LWS_ERRNO == LWS_EWOULDBLOCK
+               if (LWS_ERRNO == LWS_EALREADY ||
+                   LWS_ERRNO == LWS_EINPROGRESS ||
+                   LWS_ERRNO == LWS_EWOULDBLOCK
 #ifdef _WIN32
                        || LWS_ERRNO == WSAEINVAL
 #endif
-                       )
-               {
+               ) {
                        lwsl_client("nonblocking connect retry\n");
 
                        /*
@@ -249,26 +243,26 @@ struct lws *lws_client_connect_2(
 
        if (context->http_proxy_port) {
 
-               /* OK from now on we talk via the proxy, so connect to that */
-
                /*
+                * OK from now on we talk via the proxy, so connect to that
+                *
                 * (will overwrite existing pointer,
                 * leaving old string/frag there but unreferenced)
                 */
                if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS,
-                                                  context->http_proxy_address))
+                                         context->http_proxy_address))
                        goto failed;
                wsi->u.hdr.ah->c_port = context->http_proxy_port;
 
-               n = send(wsi->sock, (char *)context->service_buffer, plen, MSG_NOSIGNAL);
+               n = send(wsi->sock, (char *)context->service_buffer, plen,
+                        MSG_NOSIGNAL);
                if (n < 0) {
                        lwsl_debug("ERROR writing to proxy socket\n");
                        goto failed;
                }
 
-               lws_set_timeout(wsi,
-                       PENDING_TIMEOUT_AWAITING_PROXY_RESPONSE,
-                                                             AWAITING_TIMEOUT);
+               lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_PROXY_RESPONSE,
+                               AWAITING_TIMEOUT);
 
                wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY;
 
@@ -285,8 +279,8 @@ struct lws *lws_client_connect_2(
         * cover with a timeout.
         */
 
-       lws_set_timeout(wsi,
-               PENDING_TIMEOUT_SENT_CLIENT_HANDSHAKE, AWAITING_TIMEOUT);
+       lws_set_timeout(wsi, PENDING_TIMEOUT_SENT_CLIENT_HANDSHAKE,
+                       AWAITING_TIMEOUT);
 
        wsi->mode = LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE;
        pfd.fd = wsi->sock;
@@ -308,8 +302,8 @@ oom4:
        return NULL;
 
 failed:
-       lws_close_and_free_session(context, wsi,
-                                                    LWS_CLOSE_STATUS_NOSTATUS);
+       lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS);
+
        return NULL;
 }
 
@@ -334,15 +328,10 @@ failed:
  */
 
 LWS_VISIBLE struct lws *
-lws_client_connect(struct lws_context *context,
-                             const char *address,
-                             int port,
-                             int ssl_connection,
-                             const char *path,
-                             const char *host,
-                             const char *origin,
-                             const char *protocol,
-                             int ietf_version_or_minus_one)
+lws_client_connect(struct lws_context *context, const char *address,
+                  int port, int ssl_connection, const char *path,
+                  const char *host, const char *origin,
+                  const char *protocol, int ietf_version_or_minus_one)
 {
        struct lws *wsi;
 
@@ -392,16 +381,15 @@ lws_client_connect(struct lws_context *context,
                goto bail1;
 
        if (origin)
-               if (lws_hdr_simple_create(wsi,
-                               _WSI_TOKEN_CLIENT_ORIGIN, origin))
+               if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_ORIGIN, origin))
                        goto bail1;
        /*
         * this is a list of protocols we tell the server we're okay with
         * stash it for later when we compare server response with it
         */
        if (protocol)
-               if (lws_hdr_simple_create(wsi,
-                               _WSI_TOKEN_CLIENT_SENT_PROTOCOLS, protocol))
+               if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_SENT_PROTOCOLS,
+                                         protocol))
                        goto bail1;
 
        wsi->protocol = &context->protocols[0];
@@ -415,12 +403,12 @@ lws_client_connect(struct lws_context *context,
        
        if (lws_ext_callback_for_each_extension_type(context, wsi,
                        LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION,
-                                               (void *)address, port) > 0) {
+                                                    (void *)address, port) > 0) {
                lwsl_client("lws_client_connect: ext handling conn\n");
 
                lws_set_timeout(wsi,
                        PENDING_TIMEOUT_AWAITING_EXTENSION_CONNECT_RESPONSE,
-                                                             AWAITING_TIMEOUT);
+                               AWAITING_TIMEOUT);
 
                wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT;
                return wsi;
@@ -459,26 +447,22 @@ bail:
  */
 
 LWS_VISIBLE struct lws *
-lws_client_connect_extended(struct lws_context *context,
-                             const char *address,
-                             int port,
-                             int ssl_connection,
-                             const char *path,
-                             const char *host,
-                             const char *origin,
-                             const char *protocol,
-                             int ietf_version_or_minus_one,
-                             void *userdata)
+lws_client_connect_extended(struct lws_context *context, const char *address,
+                           int port, int ssl_connection, const char *path,
+                           const char *host, const char *origin,
+                           const char *protocol, int ietf_version_or_minus_one,
+                           void *userdata)
 {
-       struct lws *ws =
-               lws_client_connect(context, address, port,
-                       ssl_connection, path, host, origin, protocol,
-                                                    ietf_version_or_minus_one);
-
-       if (ws && !ws->user_space && userdata) {
-               ws->user_space_externally_allocated = 1;
-               ws->user_space = userdata ;
+       struct lws *wsi;
+
+       wsi = lws_client_connect(context, address, port, ssl_connection, path,
+                                host, origin, protocol,
+                                ietf_version_or_minus_one);
+
+       if (wsi && !wsi->user_space && userdata) {
+               wsi->user_space_externally_allocated = 1;
+               wsi->user_space = userdata ;
        }
 
-       return ws ;
+       return wsi;
 }
index 7eaf220..29a34c0 100644 (file)
@@ -24,9 +24,8 @@
 int lws_client_rx_sm(struct lws *wsi, unsigned char c)
 {
        int callback_action = LWS_CALLBACK_CLIENT_RECEIVE;
-       int handled;
        struct lws_tokens eff_buf;
-       int m;
+       int handled, m;
 
        switch (wsi->lws_rx_parse_state) {
        case LWS_RXPS_NEW:
@@ -54,7 +53,6 @@ int lws_client_rx_sm(struct lws *wsi, unsigned char c)
                }
                break;
 
-
        case LWS_RXPS_04_FRAME_HDR_LEN:
 
                wsi->u.ws.this_frame_masked = !!(c & 0x80);
@@ -287,7 +285,7 @@ spill:
 
                case LWS_WS_OPCODE_07__PING:
                        lwsl_info("received %d byte ping, sending pong\n",
-                                                wsi->u.ws.rx_user_buffer_head);
+                                 wsi->u.ws.rx_user_buffer_head);
 
                        if (wsi->u.ws.ping_pending_flag) {
                                /*
@@ -306,13 +304,15 @@ spill:
 
                        /* if existing buffer is too small, drop it */
                        if (wsi->u.ws.ping_payload_buf &&
-                           wsi->u.ws.ping_payload_alloc < wsi->u.ws.rx_user_buffer_head)
+                           wsi->u.ws.ping_payload_alloc <
+                           wsi->u.ws.rx_user_buffer_head)
                                lws_free2(wsi->u.ws.ping_payload_buf);
 
                        /* if no buffer, allocate it */
                        if (!wsi->u.ws.ping_payload_buf) {
-                               wsi->u.ws.ping_payload_buf = lws_malloc(wsi->u.ws.rx_user_buffer_head
-                                                                       + LWS_SEND_BUFFER_PRE_PADDING);
+                               wsi->u.ws.ping_payload_buf =
+                                       lws_malloc(wsi->u.ws.rx_user_buffer_head +
+                                                  LWS_SEND_BUFFER_PRE_PADDING);
                                wsi->u.ws.ping_payload_alloc =
                                        wsi->u.ws.rx_user_buffer_head;
                        }
@@ -334,9 +334,8 @@ ping_drop:
 
                case LWS_WS_OPCODE_07__PONG:
                        lwsl_info("client receied pong\n");
-                       lwsl_hexdump(&wsi->u.ws.rx_user_buffer[
-                               LWS_SEND_BUFFER_PRE_PADDING],
-                                   wsi->u.ws.rx_user_buffer_head);
+                       lwsl_hexdump(&wsi->u.ws.rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING],
+                                    wsi->u.ws.rx_user_buffer_head);
 
                        /* issue it */
                        callback_action = LWS_CALLBACK_CLIENT_RECEIVE_PONG;
@@ -366,7 +365,7 @@ ping_drop:
                                        &eff_buf, 0) <= 0) { /* not handle or fail */
 
                                lwsl_ext("Unhandled ext opc 0x%x\n",
-                                                             wsi->u.ws.opcode);
+                                        wsi->u.ws.opcode);
                                wsi->u.ws.rx_user_buffer_head = 0;
 
                                return 0;
@@ -388,12 +387,12 @@ ping_drop:
                eff_buf.token_len = wsi->u.ws.rx_user_buffer_head;
                
                if (lws_ext_callback_for_each_active(wsi,
-                               LWS_EXT_CALLBACK_PAYLOAD_RX,
-                                               &eff_buf, 0) < 0) /* fail */
+                                                    LWS_EXT_CALLBACK_PAYLOAD_RX,
+                                                    &eff_buf, 0) < 0) /* fail */
                        return -1;
 
                if (eff_buf.token_len <= 0 &&
-                           callback_action != LWS_CALLBACK_CLIENT_RECEIVE_PONG)
+                   callback_action != LWS_CALLBACK_CLIENT_RECEIVE_PONG)
                        goto already_done;
 
                eff_buf.token[eff_buf.token_len] = '\0';
@@ -404,13 +403,9 @@ ping_drop:
                if (callback_action == LWS_CALLBACK_CLIENT_RECEIVE_PONG)
                        lwsl_info("Client doing pong callback\n");
 
-               m = wsi->protocol->callback(
-                       wsi->protocol->owning_server,
-                       wsi,
-                       (enum lws_callback_reasons)callback_action,
-                       wsi->user_space,
-                       eff_buf.token,
-                       eff_buf.token_len);
+               m = wsi->protocol->callback(wsi->protocol->owning_server,
+                       wsi, (enum lws_callback_reasons)callback_action,
+                       wsi->user_space, eff_buf.token, eff_buf.token_len);
 
                /* if user code wants to close, let caller know */
                if (m)
index 895a523..2fd720a 100644 (file)
@@ -23,7 +23,7 @@
 
 int lws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len)
 {
-       int n;
+       unsigned int n;
 
        switch (wsi->mode) {
        case LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY:
@@ -44,12 +44,11 @@ int lws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len)
 }
 
 int lws_client_socket_service(struct lws_context *context,
-               struct lws *wsi, struct lws_pollfd *pollfd)
+                             struct lws *wsi, struct lws_pollfd *pollfd)
 {
-       int n;
        char *p = (char *)&context->service_buffer[0];
-       int len;
        unsigned char c;
+       int n, len;
 
        switch (wsi->mode) {
 
@@ -88,13 +87,12 @@ int lws_client_socket_service(struct lws_context *context,
                if (n < 0) {
                        
                        if (LWS_ERRNO == LWS_EAGAIN) {
-                               lwsl_debug(
-                                                  "Proxy read returned EAGAIN... retrying\n");
+                               lwsl_debug("Proxy read returned EAGAIN... retrying\n");
                                return 0;
                        }
                        
                        lws_close_and_free_session(context, wsi,
-                                                    LWS_CLOSE_STATUS_NOSTATUS);
+                                                  LWS_CLOSE_STATUS_NOSTATUS);
                        lwsl_err("ERROR reading from proxy socket\n");
                        return 0;
                }
@@ -104,7 +102,7 @@ int lws_client_socket_service(struct lws_context *context,
                    strcmp((char *)context->service_buffer, "HTTP/1.1 200 ")
                ) {
                        lws_close_and_free_session(context, wsi,
-                                                    LWS_CLOSE_STATUS_NOSTATUS);
+                                                  LWS_CLOSE_STATUS_NOSTATUS);
                        lwsl_err("ERROR proxy: %s\n", context->service_buffer);
                        return 0;
                }
@@ -493,22 +491,18 @@ strtolower(char *s)
 
 int
 lws_client_interpret_server_handshake(struct lws_context *context,
-               struct lws *wsi)
+                                     struct lws *wsi)
 {
+       int n, len, okay = 0, more = 1, isErrorCodeReceived = 0;
+       int close_reason = LWS_CLOSE_STATUS_PROTOCOL_ERR;
        const char *pc;
-       int okay = 0;
        char *p;
-       int len;
-       int isErrorCodeReceived = 0;
 #ifndef LWS_NO_EXTENSIONS
-       char ext_name[128];
        struct lws_extension *ext;
-       void *v;
-       int more = 1;
+       char ext_name[128];
        const char *c;
+       void *v;
 #endif
-       int n;
-       int close_reason = LWS_CLOSE_STATUS_PROTOCOL_ERR;
 
        /*
         * well, what the server sent looked reasonable for syntax.
@@ -736,7 +730,7 @@ check_accept:
 
        wsi->protocol->callback(context, wsi,
                                LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH,
-                                                    wsi->user_space, NULL, 0);
+                               wsi->user_space, NULL, 0);
 
        /* clear his proxy connection timeout */
 
@@ -777,9 +771,8 @@ check_accept:
 
        /* call him back to inform him he is up */
 
-       wsi->protocol->callback(context, wsi,
-                               LWS_CALLBACK_CLIENT_ESTABLISHED,
-                                                    wsi->user_space, NULL, 0);
+       wsi->protocol->callback(context, wsi, LWS_CALLBACK_CLIENT_ESTABLISHED,
+                               wsi->user_space, NULL, 0);
 #ifndef LWS_NO_EXTENSIONS
        /*
         * inform all extensions, not just active ones since they
@@ -811,20 +804,19 @@ bail2:
                if (isErrorCodeReceived && p) {
                        wsi->protocol->callback(context, wsi,
                                LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
-                                       wsi->user_space, p, (unsigned int)strlen(p));
+                                               wsi->user_space, p,
+                                               (unsigned int)strlen(p));
                } else {
                        wsi->protocol->callback(context, wsi,
                                LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
-                                                             wsi->user_space, NULL, 0);
+                                               wsi->user_space, NULL, 0);
                }
        }
 
        lwsl_info("closing connection due to bail2 connection error\n");
 
        /* free up his parsing allocations */
-
        lws_free2(wsi->u.hdr.ah);
-
        lws_close_and_free_session(context, wsi, close_reason);
 
        return 1;
@@ -833,12 +825,9 @@ bail2:
 
 char *
 lws_generate_client_handshake(struct lws_context *context,
-               struct lws *wsi, char *pkt)
+                             struct lws *wsi, char *pkt)
 {
-       char buf[128];
-       char hash[20];
-       char key_b64[40];
-       char *p = pkt;
+       char buf[128], hash[20], key_b64[40], *p = pkt;
        int n;
 #ifndef LWS_NO_EXTENSIONS
        struct lws_extension *ext;
@@ -848,7 +837,6 @@ lws_generate_client_handshake(struct lws_context *context,
        /*
         * create the random key
         */
-
        n = lws_get_random(context, hash, 16);
        if (n != 16) {
                lwsl_err("Unable to read from random dev %s\n",
@@ -887,15 +875,16 @@ lws_generate_client_handshake(struct lws_context *context,
         */
 
        p += sprintf(p, "GET %s HTTP/1.1\x0d\x0a",
-                               lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_URI));
+                    lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_URI));
 
-       p += sprintf(p,
-               "Pragma: no-cache\x0d\x0a""Cache-Control: no-cache\x0d\x0a");
+       p += sprintf(p, "Pragma: no-cache\x0d\x0a"
+                       "Cache-Control: no-cache\x0d\x0a");
 
        p += sprintf(p, "Host: %s\x0d\x0a",
-                              lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_HOST));
-       p += sprintf(p,
-"Upgrade: websocket\x0d\x0a""Connection: Upgrade\x0d\x0a""Sec-WebSocket-Key: ");
+                    lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_HOST));
+       p += sprintf(p, "Upgrade: websocket\x0d\x0a"
+                       "Connection: Upgrade\x0d\x0a"
+                       "Sec-WebSocket-Key: ");
        strcpy(p, key_b64);
        p += strlen(key_b64);
        p += sprintf(p, "\x0d\x0a");
@@ -916,7 +905,7 @@ lws_generate_client_handshake(struct lws_context *context,
 
                n = lws_ext_callback_for_each_extension_type(context, wsi,
                           LWS_EXT_CALLBACK_CHECK_OK_TO_PROPOSE_EXTENSION,
-                                                         (char *)ext->name, 0);
+                          (char *)ext->name, 0);
                if (n) { /* an extension vetos us */
                        lwsl_ext("ext %s vetoed\n", (char *)ext->name);
                        ext++;
@@ -953,13 +942,14 @@ lws_generate_client_handshake(struct lws_context *context,
 
        if (wsi->ietf_spec_revision)
                p += sprintf(p, "Sec-WebSocket-Version: %d\x0d\x0a",
-                                              wsi->ietf_spec_revision);
+                            wsi->ietf_spec_revision);
 
        /* give userland a chance to append, eg, cookies */
 
        context->protocols[0].callback(context, wsi,
-               LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER,
-               NULL, &p, (pkt + sizeof(context->service_buffer)) - p - 12);
+                                      LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER,
+                                      NULL, &p,
+                                      (pkt + sizeof(context->service_buffer)) - p - 12);
 
        p += sprintf(p, "\x0d\x0a");
 
@@ -971,8 +961,8 @@ lws_generate_client_handshake(struct lws_context *context,
        lws_SHA1((unsigned char *)buf, n, (unsigned char *)hash);
 
        lws_b64_encode_string(hash, 20,
-                       wsi->u.hdr.ah->initial_handshake_hash_base64,
-                         sizeof(wsi->u.hdr.ah->initial_handshake_hash_base64));
+                             wsi->u.hdr.ah->initial_handshake_hash_base64,
+                             sizeof(wsi->u.hdr.ah->initial_handshake_hash_base64));
 
        return p;
 }
index 5a58c07..cd2cbc0 100644 (file)
@@ -75,10 +75,10 @@ LWS_VISIBLE struct lws_context *
 lws_create_context(struct lws_context_creation_info *info)
 {
        struct lws_context *context = NULL;
-       char *p;
 #if LWS_POSIX
        int pid_daemon = get_daemonize_pid();
 #endif
+       char *p;
 
        lwsl_notice("Initial logging level %d\n", log_level);
 
@@ -304,7 +304,6 @@ lws_context_destroy(struct lws_context *context)
        }
 
        lws_plat_context_early_destroy(context);
-
        lws_ssl_context_destroy(context);
 
        if (context->fds)
index 0892cb0..7e79bb0 100644 (file)
@@ -34,9 +34,7 @@ int get_daemonize_pid()
 static void
 child_handler(int signum)
 {
-       int fd;
-       int len;
-       int sent;
+       int fd, len, sent;
        char sz[20];
 
        switch (signum) {
@@ -93,11 +91,10 @@ static void lws_daemon_closing(int sigact)
 LWS_VISIBLE int
 lws_daemonize(const char *_lock_path)
 {
+       struct sigaction act;
        pid_t sid, parent;
-       int fd;
+       int n, fd, ret;
        char buf[10];
-       int n, ret;
-       struct sigaction act;
 
        /* already a daemon */
        if (getppid() == 1)
index 663f45c..5daf0d8 100644 (file)
@@ -29,20 +29,20 @@ const unsigned char *lws_token_to_string(enum lws_token_indexes token)
 
        if ((unsigned int)token >= ARRAY_SIZE(set))
                return NULL;
+
        return (unsigned char *)set[token];
 }
 
-int lws_add_http_header_by_name(struct lws_context *context,
-                           struct lws *wsi,
+int
+lws_add_http_header_by_name(struct lws_context *context, struct lws *wsi,
                            const unsigned char *name,
-                           const unsigned char *value,
-                           int length,
-                           unsigned char **p,
-                           unsigned char *end)
+                           const unsigned char *value, int length,
+                           unsigned char **p, unsigned char *end)
 {
 #ifdef LWS_USE_HTTP2
        if (wsi->mode == LWS_CONNMODE_HTTP2_SERVING)
-               return lws_add_http2_header_by_name(context, wsi, name, value, length, p, end);
+               return lws_add_http2_header_by_name(context, wsi, name,
+                                                   value, length, p, end);
 #else
        (void)wsi;
        (void)context;
@@ -61,13 +61,12 @@ int lws_add_http_header_by_name(struct lws_context *context,
        *p += length;
        *((*p)++) = '\x0d';
        *((*p)++) = '\x0a';
+
        return 0;
 }
 
-int lws_finalize_http_header(struct lws_context *context,
-                           struct lws *wsi,
-                           unsigned char **p,
-                           unsigned char *end)
+int lws_finalize_http_header(struct lws_context *context, struct lws *wsi,
+                            unsigned char **p, unsigned char *end)
 {
        (void)context;
 #ifdef LWS_USE_HTTP2
@@ -80,16 +79,15 @@ int lws_finalize_http_header(struct lws_context *context,
                return 1;
        *((*p)++) = '\x0d';
        *((*p)++) = '\x0a';
+
        return 0;
 }
 
-int lws_add_http_header_by_token(struct lws_context *context,
-                           struct lws *wsi,
-                           enum lws_token_indexes token,
-                           const unsigned char *value,
-                           int length,
-                           unsigned char **p,
-                           unsigned char *end)
+int
+lws_add_http_header_by_token(struct lws_context *context, struct lws *wsi,
+                            enum lws_token_indexes token,
+                            const unsigned char *value, int length,
+                            unsigned char **p, unsigned char *end)
 {
        const unsigned char *name;
 #ifdef LWS_USE_HTTP2
@@ -103,10 +101,9 @@ int lws_add_http_header_by_token(struct lws_context *context,
 }
 
 int lws_add_http_header_content_length(struct lws_context *context,
-                           struct lws *wsi,
-                           unsigned long content_length,
-                           unsigned char **p,
-                           unsigned char *end)
+                                      struct lws *wsi,
+                                      unsigned long content_length,
+                                      unsigned char **p, unsigned char *end)
 {
        char b[24];
        int n;
@@ -150,11 +147,10 @@ static const char *err500[] = {
        "HTTP Version Not Supported"
 };
 
-int lws_add_http_header_status(struct lws_context *context,
-                           struct lws *wsi,
-                           unsigned int code,
-                           unsigned char **p,
-                           unsigned char *end)
+int
+lws_add_http_header_status(struct lws_context *context, struct lws *wsi,
+                          unsigned int code, unsigned char **p,
+                          unsigned char *end)
 {
        unsigned char code_and_desc[60];
        const char *description = "";
@@ -171,7 +167,8 @@ int lws_add_http_header_status(struct lws_context *context,
 
        n = sprintf((char *)code_and_desc, "HTTP/1.0 %u %s", code, description);
 
-       return lws_add_http_header_by_name(context, wsi, NULL, code_and_desc, n, p, end);
+       return lws_add_http_header_by_name(context, wsi, NULL, code_and_desc,
+                                          n, p, end);
 }
 
 /**
@@ -184,25 +181,31 @@ int lws_add_http_header_status(struct lws_context *context,
  *     Helper to report HTTP errors back to the client cleanly and
  *     consistently
  */
-LWS_VISIBLE int lws_return_http_status(
-               struct lws_context *context, struct lws *wsi,
-                                      unsigned int code, const char *html_body)
+LWS_VISIBLE int
+lws_return_http_status(struct lws_context *context, struct lws *wsi,
+                      unsigned int code, const char *html_body)
 {
        int n, m;
 
-       unsigned char *p = context->service_buffer + LWS_SEND_BUFFER_PRE_PADDING;
+       unsigned char *p = context->service_buffer +
+                          LWS_SEND_BUFFER_PRE_PADDING;
        unsigned char *start = p;
        unsigned char *end = p + sizeof(context->service_buffer) -
-                                       LWS_SEND_BUFFER_PRE_PADDING;
+                            LWS_SEND_BUFFER_PRE_PADDING;
 
        if (!html_body)
                html_body = "";
 
        if (lws_add_http_header_status(context, wsi, code, &p, end))
                return 1;
-       if (lws_add_http_header_by_token(context, wsi, WSI_TOKEN_HTTP_SERVER, (unsigned char *)"libwebsockets", 13, &p, end))
+       if (lws_add_http_header_by_token(context, wsi, WSI_TOKEN_HTTP_SERVER,
+                                        (unsigned char *)"libwebsockets", 13,
+                                        &p, end))
                return 1;
-       if (lws_add_http_header_by_token(context, wsi, WSI_TOKEN_HTTP_CONTENT_TYPE, (unsigned char *)"text/html", 9, &p, end))
+       if (lws_add_http_header_by_token(context, wsi,
+                                        WSI_TOKEN_HTTP_CONTENT_TYPE,
+                                        (unsigned char *)"text/html", 9,
+                                        &p, end))
                return 1;
        if (lws_finalize_http_header(context, wsi, &p, end))
                return 1;
@@ -211,7 +214,8 @@ LWS_VISIBLE int lws_return_http_status(
        if (m != (int)(p - start))
                return 1;
 
-       n = sprintf((char *)start, "<html><body><h1>%u</h1>%s</body></html>", code, html_body);
+       n = sprintf((char *)start, "<html><body><h1>%u</h1>%s</body></html>",
+                   code, html_body);
        m = lws_write(wsi, start, n, LWS_WRITE_HTTP);
 
        return m != n;