]> 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>
Tue, 12 Apr 2022 19:31:01 +0000 (21:31 +0200)
committerDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Tue, 12 Apr 2022 19:51:46 +0000 (21:51 +0200)
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
compat.c
gnutls.c
hpke.c
multicert.c
openconnect.h
openssl.c
pulse.c
win32-ipicmp.h

diff --git a/auth.c b/auth.c
index ca53a999e4e2251b252419ac52e876bf0c335838..ea4d30813dc9dba5929e83d428f29e07b1187b1c 100644 (file)
--- 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;
index 6b7a06c82745fe60c53119195968bd32352792b0..2080de3c1567fcc1c1a60acaaf7173c5aac6cf29 100644 (file)
--- 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 <afunix.h>
 #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;
index 19927222063a40d447f1efd84da491d5b4ee42dd..4e640f54d83ce89037e6c28b6238e4a7ed8aab1b 100644 (file)
--- 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 5f952959c7cdb03578f9e8b48653e9232b44cb7f..663cab9169617ddbdca0aafad0c07f7b39b402f2 100644 (file)
--- 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;
index af513b35e1b44247ae00ded7b66a6f795222d417..249a1757bb2e59e05c7de4a5553f115521c2d227 100644 (file)
@@ -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;
index 4fda33e0b80b2a2dbf37d8652a3501f6827bb050..04958618f353e641190d90f756de4c205a1b9478 100644 (file)
@@ -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
index 456f12ed776e813294d9f1f931fd380383712811..cc691ec3128b17b802cbff393fb9becf40cd943f 100644 (file)
--- 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 3ce765b486fdc0d48fd51acb653de2d69df339cb..3822e6a8981c5ec504113859e8d17074153d2577 100644 (file)
--- 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;
 
index 0a7622a1ecc3dc08f1cb8e8b0070ce0eb343d2fb..1e293a173a8d7342d403e46a42b00b5d2260d68c 100644 (file)
@@ -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