]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
style: switch and while are not functions
authorDimitri Papadopoulos Orfanos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Tue, 31 Dec 2024 14:41:02 +0000 (15:41 +0100)
committerDimitri Papadopoulos Orfanos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Tue, 31 Dec 2024 14:46:26 +0000 (15:46 +0100)
K&R and Linux Kernel coding style expect a space after these keywords:
if, switch, case, for, do, while

Signed-off-by: Dimitri Papadopoulos Orfanos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
17 files changed:
array.c
dtls.c
esp.c
gnutls.c
gnutls_tpm2.c
gnutls_tpm2_esys.c
gnutls_tpm2_ibm.c
library.c
main.c
oath.c
oidc.c
oncp.c
openconnect-internal.h
openssl.c
ppp.c
pulse.c
stoken.c

diff --git a/array.c b/array.c
index 9d8031a5347368afc7b07d389bc4d618c4ca9774..e7ee2e40b2dbfe393737820ae0a683901a4a5ead 100644 (file)
--- a/array.c
+++ b/array.c
@@ -862,7 +862,7 @@ int array_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable)
                        continue;
                }
 
-               switch(buf[0] >> 4) {
+               switch (buf[0] >> 4) {
                case 4:
                        iplen = load_be16(buf + 2);
                        break;
@@ -1106,7 +1106,7 @@ int array_dtls_mainloop(struct openconnect_info *vpninfo, int *timeout, int read
        /* Nothing to do here for Cisco DTLS as it is preauthenticated */
        if (vpninfo->dtls_state == DTLS_CONNECTED) {
                /* First, see if there's a response for us. */
-               while(readable) {
+               while (readable) {
                        int receive_mtu = MAX(16384, vpninfo->ip_info.mtu);
                        int len;
 
diff --git a/dtls.c b/dtls.c
index 434feba8fb395c306a9b4f2fc65d7e06c2ef7015..6e167126fe60d8a2d635329f13bdb7d5ca0bd5fc 100644 (file)
--- a/dtls.c
+++ b/dtls.c
@@ -205,7 +205,7 @@ int udp_tos_update(struct openconnect_info *vpninfo, struct pkt *pkt)
        int tos;
 
        /* Extract TOS field from IP header (IPv4 and IPv6 differ) */
-       switch(pkt->data[0] >> 4) {
+       switch (pkt->data[0] >> 4) {
        case 4:
                tos = pkt->data[1];
                break;
diff --git a/esp.c b/esp.c
index 7f8469d1b4356afd2feb14b23725f65b0f919b7c..ecc1db0f900b6b800b41765b903f3b528ca93776 100644 (file)
--- a/esp.c
+++ b/esp.c
@@ -35,7 +35,7 @@ int print_esp_keys(struct openconnect_info *vpninfo, const char *name, struct es
        const char *enctype, *mactype;
        char enckey[256], mackey[256];
 
-       switch(vpninfo->esp_enc) {
+       switch (vpninfo->esp_enc) {
        case ENC_AES_128_CBC:
                enctype = "AES-128-CBC (RFC3602)";
                break;
@@ -45,7 +45,7 @@ int print_esp_keys(struct openconnect_info *vpninfo, const char *name, struct es
        default:
                return -EINVAL;
        }
-       switch(vpninfo->esp_hmac) {
+       switch (vpninfo->esp_hmac) {
        case HMAC_MD5:
                mactype = "HMAC-MD5-96 (RFC2403)";
                break;
index 6c2e3aec29c1c0db60509ed7893de7d603043719..b01a610be27e8db797ac3b8f7ca56e6feac642e6 100644 (file)
--- a/gnutls.c
+++ b/gnutls.c
@@ -2777,7 +2777,7 @@ int hotp_hmac(struct openconnect_info *vpninfo, const void *challenge)
        unsigned char hash[64]; /* Enough for a SHA256 */
        gnutls_mac_algorithm_t alg;
 
-       switch(vpninfo->oath_hmac_alg) {
+       switch (vpninfo->oath_hmac_alg) {
        case OATH_ALG_HMAC_SHA1:
                alg = GNUTLS_MAC_SHA1;
                hpos = 19;
index 67a57a675e99c774a1f3b2ce10fe2f28fb70447d..c4a3d098bc53a453dd07976cf3bd83c47018fe39 100644 (file)
@@ -338,7 +338,7 @@ int load_tpm2_key(struct openconnect_info *vpninfo, struct cert_info *certinfo,
 
        gnutls_privkey_init(pkey);
 
-       switch(ret) {
+       switch (ret) {
        case GNUTLS_PK_RSA:
 #if GNUTLS_VERSION_NUMBER >= 0x030600
                gnutls_privkey_import_ext4(*pkey, certinfo, NULL, tpm2_rsa_sign_hash_fn, NULL, NULL, rsa_key_info, 0);
@@ -607,7 +607,7 @@ static int oc_pss_mgf1_pad(struct openconnect_info *vpninfo, gnutls_digest_algor
 int oc_pad_rsasig(struct openconnect_info *vpninfo, gnutls_sign_algorithm_t algo,
                  unsigned char *buf, int size, const gnutls_datum_t *data, int keybits)
 {
-       switch(algo) {
+       switch (algo) {
        case GNUTLS_SIGN_UNKNOWN:
        case GNUTLS_SIGN_RSA_SHA1:
        case GNUTLS_SIGN_RSA_SHA256:
index 7f54b0b09c96002a1ff77fb2223831907e0791db..2d5510b4f49d4e1d4aeff7cec39c9050e171986f 100644 (file)
@@ -191,7 +191,7 @@ static int init_tpm2_primary(struct openconnect_info *vpninfo, struct cert_info
        const char *hierarchy_name;
        ESYS_TR hierarchy;
 
-       switch(certinfo->tpm2->parent) {
+       switch (certinfo->tpm2->parent) {
        case TPM2_RH_OWNER:     hierarchy = ESYS_TR_RH_OWNER;   hierarchy_name = _("owner"); break;
        case TPM2_RH_NULL:      hierarchy = ESYS_TR_RH_NULL;    hierarchy_name = _("null"); break;
        case TPM2_RH_ENDORSEMENT:hierarchy = ESYS_TR_RH_ENDORSEMENT; hierarchy_name = _("endorsement"); break;
@@ -610,7 +610,7 @@ int install_tpm2_key(struct openconnect_info *vpninfo, struct cert_info *certinf
        certinfo->tpm2->need_userauth = !emptyauth;
        certinfo->tpm2->legacy_srk = legacy;
 
-       switch(certinfo->tpm2->pub.publicArea.type) {
+       switch (certinfo->tpm2->pub.publicArea.type) {
        case TPM2_ALG_RSA: return GNUTLS_PK_RSA;
        case TPM2_ALG_ECC: return GNUTLS_PK_ECC;
        }
index ce399f00c924691773508404010a15c6724fb109..b3645bd84e7fcd48368c51be539093b75cbf3c71 100644 (file)
@@ -541,7 +541,7 @@ int install_tpm2_key(struct openconnect_info *vpninfo, struct cert_info *certinf
                goto err_out;
        }
 
-       switch(certinfo->tpm2->pub.publicArea.type) {
+       switch (certinfo->tpm2->pub.publicArea.type) {
        case TPM_ALG_RSA: return GNUTLS_PK_RSA;
        case TPM_ALG_ECC: return GNUTLS_PK_ECC;
        }
index 2abea4d17457f5f51459b696f288684322f6bf91..d5021594d7f8f9faa150430e78bfe8c6cca35786 100644 (file)
--- a/library.c
+++ b/library.c
@@ -1606,7 +1606,7 @@ const char *openconnect_get_peer_cert_hash(struct openconnect_info *vpninfo)
 int openconnect_set_compression_mode(struct openconnect_info *vpninfo,
                                     oc_compression_mode_t mode)
 {
-       switch(mode) {
+       switch (mode) {
        case OC_COMPRESSION_MODE_NONE:
                vpninfo->req_compr = 0;
                return 0;
diff --git a/main.c b/main.c
index 18d2901e2f70c1ab9fc5b96504f8b1bb4c15cfb5..a24fc1800f60a1e3303ece3f3623f84072691a74 100644 (file)
--- a/main.c
+++ b/main.c
@@ -699,7 +699,7 @@ static void print_build_opts(void)
                printf("%sRSA software token", sep);
                sep = comma;
        }
-       switch(openconnect_has_oath_support()) {
+       switch (openconnect_has_oath_support()) {
        case 2:
                printf("%sHOTP software token", sep);
                sep = comma;
@@ -2923,7 +2923,7 @@ static void init_token(struct openconnect_info *vpninfo,
 
        if (token_str && (token_mode == OC_TOKEN_MODE_TOTP ||
                          token_mode == OC_TOKEN_MODE_HOTP)) {
-               switch(token_str[0]) {
+               switch (token_str[0]) {
                case '@':
                        token_str++;
                        /* fall through... */
@@ -2986,7 +2986,7 @@ static void init_token(struct openconnect_info *vpninfo,
                break;
 
        case OC_TOKEN_MODE_YUBIOATH:
-               switch(ret) {
+               switch (ret) {
                case 0:
                        return;
                case -ENOENT:
diff --git a/oath.c b/oath.c
index 8730f64b8bbba5ffb0449fa96f009d568a1309f8..d62fb3280c55580b56fc8d341ea612322c8e86ed 100644 (file)
--- a/oath.c
+++ b/oath.c
@@ -75,7 +75,7 @@ static int decode_b32_group(unsigned char *out, const char *in)
 
        store_be32(out + 1, d);
 
-       switch(len) {
+       switch (len) {
        case 8:
                return 5;
        case 7:
diff --git a/oidc.c b/oidc.c
index 555c35a6b8cd7f518b48fff83a2bee3e89aa4054..d9d49651a40146989a5957b82612c378766422dc 100644 (file)
--- a/oidc.c
+++ b/oidc.c
@@ -32,7 +32,7 @@ int set_oidc_token(struct openconnect_info *vpninfo, const char *token_str)
        if (!token_str)
                return -ENOENT;
 
-       switch(token_str[0]) {
+       switch (token_str[0]) {
        case '@':
                token_str++;
                /* fall through */
diff --git a/oncp.c b/oncp.c
index a81756010249f93375d4835e4beb4e92a087cc76..d910f54293b9e774e0fd76846fb6a130fa6293f1 100644 (file)
--- a/oncp.c
+++ b/oncp.c
@@ -68,7 +68,7 @@ static int process_attr(struct openconnect_info *vpninfo,
        char buf[80];
        int i;
 
-       switch(GRP_ATTR(group, attr)) {
+       switch (GRP_ATTR(group, attr)) {
        case GRP_ATTR(6, 2):
                if (attrlen != 4) {
                badlen:
@@ -968,7 +968,7 @@ int oncp_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable)
                        /* Need at least 6 bytes of payload to check the IP packet length */
                        if (vpninfo->cstp_pkt->len < 26)
                                continue;
-                       switch(vpninfo->cstp_pkt->data[0] >> 4) {
+                       switch (vpninfo->cstp_pkt->data[0] >> 4) {
                        case 4:
                                iplen = load_be16(vpninfo->cstp_pkt->data + 2);
                                break;
index fd8d486e48cb51985294cbbaae72bc0e72a3b6ca..7ec0f21c10df9bc7441bb61a4ac2c04fbeb4ce9c 100644 (file)
@@ -930,7 +930,7 @@ static inline void free_pkt(struct openconnect_info *vpninfo, struct pkt *pkt)
 #define vpn_progress(_v, lvl, ...) do {                                \
        if ((_v)->verbose >= (lvl))                             \
                (_v)->progress((_v)->cbdata, lvl, __VA_ARGS__); \
-       } while(0)
+       } while (0)
 #define vpn_perror(vpninfo, msg) vpn_progress((vpninfo), PRG_ERR, "%s: %s\n", (msg), strerror(errno))
 
 #ifdef _WIN32
@@ -946,7 +946,7 @@ static inline void free_pkt(struct openconnect_info *vpninfo, struct pkt *pkt)
 
 #define __unmonitor_fd(_v, _n) do { CloseHandle(_v->_n##_event); \
                _v->_n##_event = (HANDLE)0;                      \
-       } while(0)
+       } while (0)
 
 #else
 
@@ -988,10 +988,10 @@ static inline void __remove_epoll_fd(struct openconnect_info *vpninfo, int fd)
 
 #define __unmonitor_fd(_v, _n) do {                \
                __remove_epoll_fd(_v, _v->_n##_fd); \
-               _v->_n##_epoll = 0; } while(0)
+               _v->_n##_epoll = 0; } while (0)
 
 #else /* !HAVE_POLL */
-#define __unmonitor_fd(_v, _n) do { } while(0)
+#define __unmonitor_fd(_v, _n) do { } while (0)
 #endif
 
 static inline void __monitor_fd_event(struct openconnect_info *vpninfo,
@@ -1053,7 +1053,7 @@ static inline void __monitor_fd_new(struct openconnect_info *vpninfo,
                unmonitor_write_fd(_v, _n);     \
                unmonitor_except_fd(_v, _n);    \
                __unmonitor_fd(_v, _n);         \
-       } while(0)
+       } while (0)
 
 /* Key material for DTLS-PSK */
 #define PSK_LABEL "EXPORTER-openconnect-psk"
@@ -1634,12 +1634,12 @@ void http_common_headers(struct openconnect_info *vpninfo, struct oc_text_buf *b
                if ((vpninfo)->verbose >= PRG_DEBUG) {          \
                        do_dump_buf(vpninfo, prefix, buf);      \
                }                                               \
-       } while(0)
+       } while (0)
 #define dump_buf_hex(vpninfo, loglevel, prefix, buf, len) do {                 \
                if ((vpninfo)->verbose >= (loglevel)) {                         \
                        do_dump_buf_hex(vpninfo, loglevel, prefix, buf, len);   \
                }                                                               \
-       } while(0)
+       } while (0)
 
 /* http-auth.c */
 void *openconnect_base64_decode(int *len, const char *in);
@@ -1708,7 +1708,7 @@ static inline int strprefix_match(const char *str, int len, const char *match)
                                if (res == NULL) return -ENOMEM;        \
                        } else res = NULL;                              \
                }                                                       \
-       } while(0)
+       } while (0)
 
 #define UTF8CHECK(arg) \
        do {                                                            \
@@ -1718,7 +1718,7 @@ static inline int strprefix_match(const char *str, int len, const char *match)
                                     __func__, #arg);                   \
                        return -EILSEQ;                                 \
                }                                                       \
-       } while(0)
+       } while (0)
 
 #define UTF8CHECK_VOID(arg) \
        do {                                                            \
@@ -1728,7 +1728,7 @@ static inline int strprefix_match(const char *str, int len, const char *match)
                                     __func__, #arg);                   \
                        return;                                         \
                }                                                       \
-       } while(0)
+       } while (0)
 
 /* Let's stop open-coding big-endian and little-endian loads/stores.
  *
index b354cf7466e66da794933ea230cc86eecd1e19e5..c05297cbbaade2cb4e026d3b2480162fcbb7e815 100644 (file)
--- a/openssl.c
+++ b/openssl.c
@@ -2182,7 +2182,7 @@ int hotp_hmac(struct openconnect_info *vpninfo, const void *challenge)
        unsigned int hashlen = sizeof(hash);
        const EVP_MD *alg;
 
-       switch(vpninfo->oath_hmac_alg) {
+       switch (vpninfo->oath_hmac_alg) {
        case OATH_ALG_HMAC_SHA1:
                alg = EVP_sha1();
                break;
@@ -2276,7 +2276,7 @@ static int ttls_pull_func(BIO *b, char *buf, int len)
 
 static long ttls_ctrl_func(BIO *b, int cmd, long larg, void *iarg)
 {
-       switch(cmd) {
+       switch (cmd) {
        case BIO_CTRL_FLUSH:
                return 1;
        default:
diff --git a/ppp.c b/ppp.c
index baa55fda2c9e608ac21725268188e80d03b605a2..7875ab8dc29d4719fef5f768080d8e13b46634b5 100644 (file)
--- a/ppp.c
+++ b/ppp.c
@@ -1651,7 +1651,7 @@ int ppp_udp_mainloop(struct openconnect_info *vpninfo, int *timeout, int readabl
        int work_done = 0;
        time_t now = time(NULL);
 
-       switch(vpninfo->dtls_state) {
+       switch (vpninfo->dtls_state) {
        case DTLS_CONNECTING:
                if (vpninfo->ppp->ppp_state == PPPS_DEAD)
                        vpninfo->delay_tunnel_reason = "DTLS connecting";
@@ -1663,7 +1663,7 @@ int ppp_udp_mainloop(struct openconnect_info *vpninfo, int *timeout, int readabl
 
        case DTLS_CONNECTED:
                /* First, see if there's a response for us. */
-               while(readable) {
+               while (readable) {
                        int receive_mtu = MAX(16384, vpninfo->ip_info.mtu);
                        int len;
 
diff --git a/pulse.c b/pulse.c
index 76cad8bacc3b44459304600a0a3992dff0d534f6..ace9439bb0bcc8b4105523f5f06e118efa2dc6b0 100644 (file)
--- a/pulse.c
+++ b/pulse.c
@@ -2745,7 +2745,7 @@ int pulse_connect(struct openconnect_info *vpninfo)
                        goto bad_pkt;
                }
 
-               switch(load_be32(bytes + 0x20)) {
+               switch (load_be32(bytes + 0x20)) {
                case 0x2c20f000:
                case 0x2e20f000: /* Variant seen on Pulse 9.1R14 */
                        ret = handle_main_config_packet(vpninfo, bytes, config_len);
@@ -2879,7 +2879,7 @@ int pulse_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable)
                vpninfo->ssl_times.last_rx = time(NULL);
                len = payload_len + 0x10;
 
-               switch(load_be32(&pkt->pulse.type)) {
+               switch (load_be32(&pkt->pulse.type)) {
                case 4:
                        vpn_progress(vpninfo, PRG_TRACE,
                                     _("Received data packet of %d bytes\n"),
index c0beb3d57e4e8e9c5f0d5f8bd00327508a6024d2..62265abcef8b2eff27772804ae764fb719c5090e 100644 (file)
--- a/stoken.c
+++ b/stoken.c
@@ -43,7 +43,7 @@ int set_libstoken_mode(struct openconnect_info *vpninfo, const char *token_str)
        }
 
        if (token_str) {
-               switch(token_str[0]) {
+               switch (token_str[0]) {
                case '@':
                        token_str++;
                        /* fall through */