]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Fix Linux kernel coding style error and warnings
authorDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Sat, 31 Jul 2021 07:27:11 +0000 (09:27 +0200)
committerDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Sat, 26 Feb 2022 15:51:04 +0000 (16:51 +0100)
"foo * bar" should be "foo *bar"
"foo* bar" should be "foo *bar"
"(foo * )" should be "(foo *)"

Use the name ARRAY_SIZE() for a macro (as in Linux kernel).

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
library.c
openconnect-internal.h
tests/bad_dtls_test.c
tests/buftest.c
tests/lzstest.c
tun.c

index 1f78ea14b7423df44af6e23975687d0b20ce9b74..05340365f3fba6cf81f5c5025ca46a1dcd140855 100644 (file)
--- a/library.c
+++ b/library.c
@@ -1356,7 +1356,7 @@ static const char *compr_name_map[] = {
        [COMPR_LZO] = "LZO",
 };
 
-const char *openconnect_get_cstp_compression(struct openconnect_info * vpninfo)
+const char *openconnect_get_cstp_compression(struct openconnect_info *vpninfo)
 {
        if (vpninfo->cstp_compr <= 0 || vpninfo->cstp_compr > COMPR_MAX)
                return NULL;
@@ -1364,7 +1364,7 @@ const char *openconnect_get_cstp_compression(struct openconnect_info * vpninfo)
        return compr_name_map[vpninfo->cstp_compr];
 }
 
-const char *openconnect_get_dtls_compression(struct openconnect_info * vpninfo)
+const char *openconnect_get_dtls_compression(struct openconnect_info *vpninfo)
 {
        if (vpninfo->dtls_compr <= 0 || vpninfo->dtls_compr > COMPR_MAX)
                return NULL;
index 644f51bf0e88eef11dba6f60d41aa3298e32578a..5b11d76d5eda41660bca372fc47b60f387bcb168 100644 (file)
@@ -1333,7 +1333,7 @@ int lzs_decompress(unsigned char *dst, int dstlen, const unsigned char *src, int
 int lzs_compress(unsigned char *dst, int dstlen, const unsigned char *src, int srclen);
 
 /* ssl.c */
-unsigned string_is_hostname(const charstr);
+unsigned string_is_hostname(const char *str);
 int connect_https_socket(struct openconnect_info *vpninfo);
 int __attribute__ ((format(printf, 4, 5)))
     request_passphrase(struct openconnect_info *vpninfo, const char *label,
index 6fcc1eb408ed0658366615191b01dbf2583f0a5e..db1f7c8735e91eb2ab6de678119e71543e474728 100644 (file)
@@ -293,12 +293,14 @@ static EVP_MD_CTX *handshake_md5;
 static EVP_MD_CTX *handshake_sha1;
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
-static inline HMAC_CTX *HMAC_CTX_new(void) {
+static inline HMAC_CTX *HMAC_CTX_new(void)
+{
     HMAC_CTX *ret = malloc(sizeof(*ret));
     HMAC_CTX_init(ret);
     return ret;
 }
-static inline void HMAC_CTX_free(HMAC_CTX *ctx) {
+static inline void HMAC_CTX_free(HMAC_CTX *ctx)
+{
     HMAC_CTX_cleanup(ctx);
     free(ctx);
 }
index c3e69243f63d98fcffd96c55d2d4fff2f26e6452..01bf5f58e360ee2766b0a43856f27b121c2af911 100644 (file)
 
 /* I always coded as if it worked like this. Now it does. */
 #define realloc_inplace(p, size) do {                  \
-       void *__realloc_old = p;                        \
-       p = realloc(p, size);                           \
-       if (size && !p)                                 \
-               free(__realloc_old);                    \
-    } while (0)
+               void *__realloc_old = p;                \
+               p = realloc(p, size);                   \
+               if (size && !p)                         \
+                       free(__realloc_old);            \
+       } while (0)
 
 struct oc_packed_uint32_t {
        uint32_t d;
@@ -104,9 +104,14 @@ struct oc_text_buf {
 #define BUFTEST
 #include "../textbuf.c"
 
-#define assert(x) if (!(x)) {                                          \
-       fprintf(stderr, "assert(%s) failed at line %d\n", #x, __LINE__); \
-       exit(1); }
+#define assert(x) do {                                                 \
+               if (!(x)) {                                             \
+                       fprintf(stderr,                                 \
+                               "assert(%s) failed at line %d\n",       \
+                               #x, __LINE__);                          \
+                       exit(1);                                        \
+               }                                                       \
+       } while (0)
 
 
 static char testbytes[OC_BUF_MAX];
index 29f3f93682708cf72e4710e9f3d2eb95fd176c91..7edc47925238e45f27b5646fbce94a2a082d529d 100644 (file)
@@ -21,10 +21,7 @@ struct oc_packed_uint16_t {
        unsigned short d;
 } __attribute__((packed));
 
-int lzs_decompress(unsigned char *dst, int dstlen, const unsigned char *src, int srclen);
-int lzs_compress(unsigned char *dst, int dstlen, const unsigned char *src, int srclen);
-
-#include "../lzs.c"
+#include "../lzs.c" /* lzs_decompress() / lzs_compress() */
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/tun.c b/tun.c
index 98f59991cdf94d4c94c1cd1935cfbb7deaf3f046..2a4cab478c278f76992556d0794d2e743e4e811d 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -351,7 +351,7 @@ intptr_t os_setup_tun(struct openconnect_info *vpninfo)
        do {
                sc.sc_unit = unit_nr + 1;
 
-               if (!connect(tun_fd, (struct sockaddr * )&sc, sizeof(sc))) {
+               if (!connect(tun_fd, (struct sockaddr *)&sc, sizeof(sc))) {
                        if (!vpninfo->ifname &&
                            asprintf(&vpninfo->ifname, "utun%d", unit_nr) == -1) {
                                vpn_progress(vpninfo, PRG_ERR,