From a2a7f1adb0956c30b223ac3033f66ac8b7f234a7 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> Date: Tue, 12 Apr 2022 21:31:01 +0200 Subject: [PATCH] Fix Linux kernel coding style error and warnings open brace '{' following struct go on the same line open brace '{' following function definitions go on the next line "(foo*)" should be "(foo *)" "foo * bar" should be "foo *bar" sizeof foo should be sizeof(foo) quoted string split across lines please, no space before tabs Statements should start on a tabstop Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> --- auth.c | 9 ++++----- compat.c | 7 +++---- gnutls.c | 20 +++++++++----------- hpke.c | 2 +- multicert.c | 6 ++---- openconnect.h | 4 ++-- openssl.c | 2 +- pulse.c | 3 ++- win32-ipicmp.h | 2 +- 9 files changed, 25 insertions(+), 30 deletions(-) diff --git a/auth.c b/auth.c index ca53a999..ea4d3081 100644 --- a/auth.c +++ b/auth.c @@ -45,8 +45,7 @@ enum { CERT2_REQUESTED = (1<<2), }; -struct cert_request -{ +struct cert_request { unsigned int state:16; unsigned int hashes:16; }; @@ -1844,7 +1843,7 @@ void parse_multicert_request(struct openconnect_info *vpninfo, if (hash == OPENCONNECT_HASH_UNKNOWN) { vpn_progress(vpninfo, PRG_INFO, _("Unsupported hash algorithm '%s' requested.\n"), - (char*) content); + (char *) content); goto next; } @@ -1853,7 +1852,7 @@ void parse_multicert_request(struct openconnect_info *vpninfo, if (oldhashes == cert_rq->hashes) vpn_progress(vpninfo, PRG_INFO, _("Duplicate hash algorithm '%s' requested.\n"), - (char*) content); + (char *) content); next: xmlFree(content); @@ -1871,7 +1870,7 @@ static int post_multicert_response(struct openconnect_info *vpninfo, const xmlCh const xmlChar *hashname; xmlDocPtr doc; xmlNodePtr root, auth, node, chain; - + doc = xmlpost_new_query(vpninfo, "auth-reply", &root); if (!doc) goto bad; diff --git a/compat.c b/compat.c index 6b7a06c8..2080de3c 100644 --- a/compat.c +++ b/compat.c @@ -381,11 +381,10 @@ WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH #include #else #define UNIX_PATH_MAX 108 -struct sockaddr_un -{ +struct sockaddr_un { ADDRESS_FAMILY sun_family; /* AF_UNIX */ char sun_path[UNIX_PATH_MAX]; /* pathname */ -} SOCKADDR_UN, *PSOCKADDR_UN;; +} SOCKADDR_UN, *PSOCKADDR_UN; #endif /* HAS_AFUNIX_H */ /* dumb_socketpair: @@ -488,7 +487,7 @@ int dumb_socketpair(OPENCONNECT_CMD_SOCKET socks[2], int make_overlapped) if (setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (char *) &reuse, (socklen_t) sizeof(reuse)) == -1) - goto fallback;; + goto fallback; if (bind(listener, &a.addr, addrlen) == SOCKET_ERROR) goto fallback; diff --git a/gnutls.c b/gnutls.c index 19927222..4e640f54 100644 --- a/gnutls.c +++ b/gnutls.c @@ -1085,7 +1085,7 @@ int load_certificate(struct openconnect_info *vpninfo, struct cert_info *certinf } #endif /* HAVE_PKCS11 */ - certinfo->priv_info = gci = calloc(1, sizeof *gci); + certinfo->priv_info = gci = calloc(1, sizeof(*gci)); if (!gci) { ret = -ENOMEM; goto out; @@ -1902,7 +1902,7 @@ static int load_primary_certificate(struct openconnect_info *vpninfo) * If not, disable TLSv1.3 which would make PSS mandatory. * https://bugzilla.redhat.com/show_bug.cgi?id=1663058 */ - gnutls_datum_t fdata= { (void *)gci, sizeof *gci }; + gnutls_datum_t fdata= { (void *)gci, sizeof(*gci) }; gnutls_datum_t pkey_sig = { NULL, 0 }; err = gnutls_privkey_sign_data2(gci->pkey, GNUTLS_SIGN_RSA_PSS_RSAE_SHA256, 0, &fdata, &pkey_sig); @@ -3033,7 +3033,7 @@ int hkdf_sha256_extract_expand(struct openconnect_info *vpninfo, unsigned char * int aes_256_gcm_decrypt(struct openconnect_info *vpninfo, unsigned char *key, unsigned char *data, int len, unsigned char *iv, unsigned char *tag) - { +{ gnutls_cipher_hd_t h = NULL; gnutls_datum_t d = { key, SHA256_SIZE }; @@ -3080,17 +3080,16 @@ static int app_error(int err) if (err >= 0) return 0; - switch (err) - { + switch (err) { case GNUTLS_E_MEMORY_ERROR: - return -ENOMEM; + return -ENOMEM; case GNUTLS_E_ILLEGAL_PARAMETER: case GNUTLS_E_INVALID_REQUEST: - return -EINVAL; + return -EINVAL; case GNUTLS_E_CONSTRAINT_ERROR: case GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM: default: - return -EIO; + return -EIO; } } @@ -3175,7 +3174,7 @@ static int check_multicert_compat(struct openconnect_info *vpninfo, */ for (kp = 0; ; kp++) { - size_t oid_size = sizeof oid; + size_t oid_size = sizeof(oid); err = gnutls_x509_crt_get_key_purpose_oid(crt, kp, oid, &oid_size, &critical); @@ -3230,8 +3229,7 @@ static int check_multicert_compat(struct openconnect_info *vpninfo, */ if (kp > 0 || usage != 0) { vpn_progress(vpninfo, PRG_INFO, - _("The certificate specifies key usages " - "incompatible with authentication.\n")); + _("The certificate specifies key usages incompatible with authentication.\n")); return 0; } diff --git a/hpke.c b/hpke.c index 5f952959..663cab91 100644 --- a/hpke.c +++ b/hpke.c @@ -115,7 +115,7 @@ int handle_external_browser(struct openconnect_info *vpninfo) DEFAULT_EXTERNAL_BROWSER); pid_t pid = 0; - char * browser_argv[3] = { (char *)DEFAULT_EXTERNAL_BROWSER, vpninfo->sso_login, NULL }; + char *browser_argv[3] = { (char *)DEFAULT_EXTERNAL_BROWSER, vpninfo->sso_login, NULL }; if (posix_spawn(&pid, DEFAULT_EXTERNAL_BROWSER, NULL, NULL, browser_argv, environ)) { ret = -errno; diff --git a/multicert.c b/multicert.c index af513b35..249a1757 100644 --- a/multicert.c +++ b/multicert.c @@ -2,8 +2,6 @@ #include "openconnect-internal.h" -#define NELEM(array) (sizeof(array)/sizeof(array[0])) - static const struct { openconnect_hash_type id; const char *name; @@ -17,7 +15,7 @@ const char *multicert_hash_get_name(int id) { size_t i; - if (id > 0 && (size_t) id < NELEM(digest_table)) { + if (id > 0 && (size_t) id < ARRAY_SIZE(digest_table)) { i = (size_t) id; if (digest_table[i].id) return digest_table[i].name; @@ -30,7 +28,7 @@ openconnect_hash_type multicert_hash_get_id(const char *name) size_t i; if (name) { - for (i = 1; i < NELEM(digest_table); i++) { + for (i = 1; i < ARRAY_SIZE(digest_table); i++) { if (digest_table[i].name && !strcmp(digest_table[i].name, name)) return digest_table[i].id; diff --git a/openconnect.h b/openconnect.h index 4fda33e0..04958618 100644 --- a/openconnect.h +++ b/openconnect.h @@ -219,8 +219,8 @@ struct oc_vpn_proto { #define OC_FORM_OPT_SELECT 3 #define OC_FORM_OPT_HIDDEN 4 #define OC_FORM_OPT_TOKEN 5 -#define OC_FORM_OPT_SSO_TOKEN 6 -#define OC_FORM_OPT_SSO_USER 7 +#define OC_FORM_OPT_SSO_TOKEN 6 +#define OC_FORM_OPT_SSO_USER 7 #define OC_FORM_RESULT_ERR -1 #define OC_FORM_RESULT_OK 0 diff --git a/openssl.c b/openssl.c index 456f12ed..cc691ec3 100644 --- a/openssl.c +++ b/openssl.c @@ -1139,7 +1139,7 @@ int load_certificate(struct openconnect_info *vpninfo, struct cert_info *certinf (void) flags; - certinfo->priv_info = oci = calloc(1, sizeof *oci); + certinfo->priv_info = oci = calloc(1, sizeof(*oci)); if (!oci) { ret = -ENOMEM; goto done; diff --git a/pulse.c b/pulse.c index 3ce765b4..3822e6a8 100644 --- a/pulse.c +++ b/pulse.c @@ -2197,7 +2197,8 @@ int pulse_obtain_cookie(struct openconnect_info *vpninfo) static int handle_attr_elements(struct openconnect_info *vpninfo, unsigned char *bytes, int len, struct oc_vpn_option **new_opts, - struct oc_ip_info *new_ip_info) { + struct oc_ip_info *new_ip_info) +{ unsigned char *p = bytes; int l = len; diff --git a/win32-ipicmp.h b/win32-ipicmp.h index 0a7622a1..1e293a17 100644 --- a/win32-ipicmp.h +++ b/win32-ipicmp.h @@ -52,7 +52,7 @@ struct ip6_hdr { } ip6_ctlun; struct in6_addr ip6_src; /* source address */ struct in6_addr ip6_dst; /* destination address */ - }; +}; #define ip6_vfc ip6_ctlun.ip6_un2_vfc -- 2.49.0