[Openvpn-devel,v6,1/2] Selectively reformat too long lines

Message ID 20200920205704.18274-1-themiron@yandex-team.ru
State Superseded
Headers show
Series
  • [Openvpn-devel,v6,1/2] Selectively reformat too long lines
Related show

Commit Message

Vladislav Grishenko Sept. 20, 2020, 8:57 p.m.
Per https://community.openvpn.net/openvpn/wiki/CodeStyle the maximum line
length is 80 characters. This patch allows to split upcoming changes into
CodeStyle-conformant (w/o real code change) and more feature-specific.

Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
---
 src/openvpn/init.c    |  3 ++-
 src/openvpn/options.c | 44 +++++++++++++++++++++++++++++--------------
 src/openvpn/socket.c  | 26 +++++++++++++++++--------
 3 files changed, 50 insertions(+), 23 deletions(-)

Comments

Antonio Quartulli Sept. 24, 2020, 8:11 a.m. | #1
Hi,

On 20/09/2020 22:57, Vladislav Grishenko wrote:
> @@ -3170,7 +3179,7 @@ static const struct proto_names proto_names[] = {
>      {"udp6","UDPv6", AF_INET6, PROTO_UDP},
>      {"tcp6-server","TCPv6_SERVER", AF_INET6, PROTO_TCP_SERVER},
>      {"tcp6-client","TCPv6_CLIENT", AF_INET6, PROTO_TCP_CLIENT},
> -    {"tcp6","TCPv6", AF_INET6, PROTO_TCP},
> +    {"tcp6",       "TCPv6", AF_INET6, PROTO_TCP},

What are you actually fixing here? Adding a tab?
I feel there should be a space after each ',', but that is probably out
of the scope of this patch?
Vladislav Grishenko Sept. 24, 2020, 9:22 a.m. | #2
Hi Antonio,

 

Here's I have aligned the last line to add next new proto, already aligned.

Yes, you’re right “UDPv6” also needs to be aligned, and space needs to be added for all lines, thank you.

V7 is sent

 



 

--

Best Regards, Vladislav Grishenko

 

> -----Original Message-----

> From: Antonio Quartulli <a@unstable.cc>

> Sent: Thursday, September 24, 2020 1:12 PM

> To: Vladislav Grishenko <themiron@yandex-team.ru>; openvpn-

> devel@lists.sourceforge.net

> Subject: Re: [Openvpn-devel] [PATCH v6 1/2] Selectively reformat too long lines

> 

> Hi,

> 

> On 20/09/2020 22:57, Vladislav Grishenko wrote:

> > @@ -3170,7 +3179,7 @@ static const struct proto_names proto_names[] = {

> >      {"udp6","UDPv6", AF_INET6, PROTO_UDP},

> >      {"tcp6-server","TCPv6_SERVER", AF_INET6, PROTO_TCP_SERVER},

> >      {"tcp6-client","TCPv6_CLIENT", AF_INET6, PROTO_TCP_CLIENT},

> > -    {"tcp6","TCPv6", AF_INET6, PROTO_TCP},

> > +    {"tcp6",       "TCPv6", AF_INET6, PROTO_TCP},

> 

> What are you actually fixing here? Adding a tab?

> I feel there should be a space after each ',', but that is probably out of the scope

> of this patch?

> 

> 

> --

> Antonio Quartulli
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
	{mso-style-priority:99;
	mso-style-link:"Текст Знак";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
span.a
	{mso-style-name:"Текст Знак";
	mso-style-priority:99;
	mso-style-link:Текст;
	font-family:"Calibri",sans-serif;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:2.0cm 129.75pt 2.0cm 129.7pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=RU link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoPlainText><span lang=EN-US>Hi Antonio,<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoPlainText><span lang=EN-US>Here's I have aligned the last line to add next new proto, already aligned.<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>Yes, you’re right “UDPv6” also needs to be aligned, and space needs to be added for all lines, thank you.<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>V7 is sent<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoPlainText><img width=700 height=430 style='width:7.2916in;height:4.475in' id="Рисунок_x0020_1" src="cid:image001.jpg@01D6927E.3099D1D0"><span lang=EN-US><o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoPlainText><span lang=EN-US>--<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>Best Regards, Vladislav Grishenko<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoPlainText>&gt; <span style='mso-fareast-language:RU'>-----Original Message-----</span></p><p class=MsoPlainText>&gt; <span style='mso-fareast-language:RU'>From: Antonio Quartulli &lt;a@unstable.cc&gt;</span></p><p class=MsoPlainText>&gt; <span style='mso-fareast-language:RU'>Sent: Thursday, September 24, 2020 1:12 PM</span></p><p class=MsoPlainText>&gt; <span style='mso-fareast-language:RU'>To: Vladislav Grishenko &lt;themiron@yandex-team.ru&gt;; openvpn-</span></p><p class=MsoPlainText>&gt; <span style='mso-fareast-language:RU'>devel@lists.sourceforge.net</span></p><p class=MsoPlainText>&gt; <span style='mso-fareast-language:RU'>Subject: Re: [Openvpn-devel] [PATCH v6 1/2] Selectively reformat too long lines</span></p><p class=MsoPlainText>&gt; </p><p class=MsoPlainText>&gt; Hi,</p><p class=MsoPlainText>&gt; </p><p class=MsoPlainText>&gt; On 20/09/2020 22:57, Vladislav Grishenko wrote:</p><p class=MsoPlainText>&gt; &gt; @@ -3170,7 +3179,7 @@ static const struct proto_names proto_names[] = {</p><p class=MsoPlainText>&gt; &gt;      {&quot;udp6&quot;,&quot;UDPv6&quot;, AF_INET6, PROTO_UDP},</p><p class=MsoPlainText>&gt; &gt;      {&quot;tcp6-server&quot;,&quot;TCPv6_SERVER&quot;, AF_INET6, PROTO_TCP_SERVER},</p><p class=MsoPlainText>&gt; &gt;      {&quot;tcp6-client&quot;,&quot;TCPv6_CLIENT&quot;, AF_INET6, PROTO_TCP_CLIENT},</p><p class=MsoPlainText>&gt; &gt; -    {&quot;tcp6&quot;,&quot;TCPv6&quot;, AF_INET6, PROTO_TCP},</p><p class=MsoPlainText>&gt; &gt; +    {&quot;tcp6&quot;,       &quot;TCPv6&quot;, AF_INET6, PROTO_TCP},</p><p class=MsoPlainText>&gt; </p><p class=MsoPlainText>&gt; What are you actually fixing here? Adding a tab?</p><p class=MsoPlainText>&gt; I feel there should be a space after each ',', but that is probably out of the scope</p><p class=MsoPlainText>&gt; of this patch?</p><p class=MsoPlainText>&gt; </p><p class=MsoPlainText>&gt; </p><p class=MsoPlainText>&gt; --</p><p class=MsoPlainText>&gt; Antonio Quartulli</p></div></body></html>

Patch

diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index d1ad5c8f..31ecadcc 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -3646,7 +3646,8 @@  do_close_link_socket(struct context *c)
           && ( (c->options.persist_remote_ip)
                ||
                ( c->sig->source != SIG_SOURCE_HARD
-                 && ((c->c1.link_socket_addr.current_remote && c->c1.link_socket_addr.current_remote->ai_next)
+                 && ((c->c1.link_socket_addr.current_remote
+                      && c->c1.link_socket_addr.current_remote->ai_next)
                      || c->options.no_advance))
                )))
     {
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 4b22d3d9..ed4229c0 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -1983,7 +1983,8 @@  connection_entry_load_re(struct connection_entry *ce, const struct remote_entry
 }
 
 static void
-options_postprocess_verify_ce(const struct options *options, const struct connection_entry *ce)
+options_postprocess_verify_ce(const struct options *options,
+                              const struct connection_entry *ce)
 {
     struct options defaults;
     int dev = DEV_TYPE_UNDEF;
@@ -2011,7 +2012,8 @@  options_postprocess_verify_ce(const struct options *options, const struct connec
      */
     if (ce->proto == PROTO_TCP)
     {
-        msg(M_USAGE, "--proto tcp is ambiguous in this context.  Please specify --proto tcp-server or --proto tcp-client");
+        msg(M_USAGE, "--proto tcp is ambiguous in this context. "
+            "Please specify --proto tcp-server or --proto tcp-client");
     }
 
     /*
@@ -2065,7 +2067,8 @@  options_postprocess_verify_ce(const struct options *options, const struct connec
      */
     if (options->ce.tun_mtu_defined && options->ce.link_mtu_defined)
     {
-        msg(M_USAGE, "only one of --tun-mtu or --link-mtu may be defined (note that --ifconfig implies --link-mtu %d)", LINK_MTU_DEFAULT);
+        msg(M_USAGE, "only one of --tun-mtu or --link-mtu may be defined "
+            "(note that --ifconfig implies --link-mtu %d)", LINK_MTU_DEFAULT);
     }
 
     if (!proto_is_udp(ce->proto) && options->mtu_test)
@@ -2092,18 +2095,22 @@  options_postprocess_verify_ce(const struct options *options, const struct connec
     if (string_defined_equal(ce->remote, options->ifconfig_local)
         || string_defined_equal(ce->remote, options->ifconfig_remote_netmask))
     {
-        msg(M_USAGE, "--local and --remote addresses must be distinct from --ifconfig addresses");
+        msg(M_USAGE, "--local and --remote addresses must be distinct from "
+            "--ifconfig addresses");
     }
 
     if (string_defined_equal(ce->local, options->ifconfig_local)
         || string_defined_equal(ce->local, options->ifconfig_remote_netmask))
     {
-        msg(M_USAGE, "--local addresses must be distinct from --ifconfig addresses");
+        msg(M_USAGE, "--local addresses must be distinct from "
+            "--ifconfig addresses");
     }
 
-    if (string_defined_equal(options->ifconfig_local, options->ifconfig_remote_netmask))
+    if (string_defined_equal(options->ifconfig_local,
+                             options->ifconfig_remote_netmask))
     {
-        msg(M_USAGE, "local and remote/netmask --ifconfig addresses must be different");
+        msg(M_USAGE, "local and remote/netmask --ifconfig addresses "
+            "must be different");
     }
 
     if (ce->bind_defined && !ce->bind_local)
@@ -2217,11 +2224,14 @@  options_postprocess_verify_ce(const struct options *options, const struct connec
 
     if ((ce->http_proxy_options) && ce->proto != PROTO_TCP_CLIENT)
     {
-        msg(M_USAGE, "--http-proxy MUST be used in TCP Client mode (i.e. --proto tcp-client)");
+        msg(M_USAGE, "--http-proxy MUST be used in TCP Client mode "
+            "(i.e. --proto tcp-client)");
     }
+
     if ((ce->http_proxy_options) && !ce->http_proxy_options->server)
     {
-        msg(M_USAGE, "--http-proxy not specified but other http proxy options present");
+        msg(M_USAGE, "--http-proxy not specified but "
+            "other http proxy options present");
     }
 
     if (ce->http_proxy_options && ce->socks_proxy_server)
@@ -2817,12 +2827,14 @@  options_postprocess_mutate_ce(struct options *o, struct connection_entry *ce)
     }
 #endif
 
-    if (ce->proto == PROTO_TCP_CLIENT && !ce->local && !ce->local_port_defined && !ce->bind_defined)
+    if (ce->proto == PROTO_TCP_CLIENT && !ce->local
+        && !ce->local_port_defined && !ce->bind_defined)
     {
         ce->bind_local = false;
     }
 
-    if (ce->proto == PROTO_UDP && ce->socks_proxy_server && !ce->local && !ce->local_port_defined && !ce->bind_defined)
+    if (ce->proto == PROTO_UDP && ce->socks_proxy_server && !ce->local
+        && !ce->local_port_defined && !ce->bind_defined)
     {
         ce->bind_local = false;
     }
@@ -2832,7 +2844,9 @@  options_postprocess_mutate_ce(struct options *o, struct connection_entry *ce)
         ce->local_port = NULL;
     }
 
-    /* if protocol forcing is enabled, disable all protocols except for the forced one */
+    /* if protocol forcing is enabled, disable all protocols
+     * except for the forced one
+     */
     if (o->proto_force >= 0 && o->proto_force != ce->proto)
     {
         ce->flags |= CE_DISABLED;
@@ -5690,7 +5704,8 @@  add_option(struct options *options,
                 const sa_family_t af = ascii2af(p[3]);
                 if (proto < 0)
                 {
-                    msg(msglevel, "remote: bad protocol associated with host %s: '%s'", p[1], p[3]);
+                    msg(msglevel, "remote: bad protocol associated "
+                        "with host %s: '%s'", p[1], p[3]);
                     goto err;
                 }
                 re.proto = proto;
@@ -6210,7 +6225,8 @@  add_option(struct options *options,
         af = ascii2af(p[1]);
         if (proto < 0)
         {
-            msg(msglevel, "Bad protocol: '%s'.  Allowed protocols with --proto option: %s",
+            msg(msglevel, "Bad protocol: '%s'. "
+                "Allowed protocols with --proto option: %s",
                 p[1],
                 proto2ascii_all(&gc));
             goto err;
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 76bdbfc5..296fb294 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -378,7 +378,8 @@  do_preresolve(struct context *c)
         /* HTTP remote hostname does not need to be resolved */
         if (!ce->http_proxy_options)
         {
-            status = do_preresolve_host(c, remote, ce->remote_port, ce->af, flags);
+            status = do_preresolve_host(c, remote, ce->remote_port,
+                                        ce->af, flags);
             if (status != 0)
             {
                 goto err;
@@ -417,7 +418,8 @@  do_preresolve(struct context *c)
         {
             flags |= GETADDR_PASSIVE;
             flags &= ~GETADDR_RANDOMIZE;
-            status = do_preresolve_host(c, ce->local, ce->local_port, ce->af, flags);
+            status = do_preresolve_host(c, ce->local, ce->local_port,
+                                        ce->af, flags);
             if (status != 0)
             {
                 goto err;
@@ -526,7 +528,9 @@  openvpn_getaddrinfo(unsigned int flags,
         if ((flags & GETADDR_MENTION_RESOLVE_RETRY)
             && !resolve_retry_seconds)
         {
-            fmt = "RESOLVE: Cannot resolve host address: %s:%s (%s) (I would have retried this name query if you had specified the --resolv-retry option.)";
+            fmt = "RESOLVE: Cannot resolve host address: %s:%s (%s) "
+                  "(I would have retried this name query if you had "
+                  "specified the --resolv-retry option.)";
         }
 
         if (!(flags & GETADDR_RESOLVE) || status == EAI_FAIL)
@@ -558,11 +562,13 @@  openvpn_getaddrinfo(unsigned int flags,
         while (true)
         {
 #ifndef _WIN32
+            /* force resolv.conf reload */
             res_init();
 #endif
             /* try hostname lookup */
             hints.ai_flags &= ~AI_NUMERICHOST;
-            dmsg(D_SOCKET_DEBUG, "GETADDRINFO flags=0x%04x ai_family=%d ai_socktype=%d",
+            dmsg(D_SOCKET_DEBUG,
+                 "GETADDRINFO flags=0x%04x ai_family=%d ai_socktype=%d",
                  flags, hints.ai_family, hints.ai_socktype);
             status = getaddrinfo(hostname, servname, &hints, res);
 
@@ -573,7 +579,8 @@  openvpn_getaddrinfo(unsigned int flags,
                 {
                     if (*signal_received == SIGUSR1) /* ignore SIGUSR1 */
                     {
-                        msg(level, "RESOLVE: Ignored SIGUSR1 signal received during DNS resolution attempt");
+                        msg(level, "RESOLVE: Ignored SIGUSR1 signal received "
+                            "during DNS resolution attempt");
                         *signal_received = 0;
                     }
                     else
@@ -634,7 +641,8 @@  openvpn_getaddrinfo(unsigned int flags,
         /* IP address parse succeeded */
         if (flags & GETADDR_RANDOMIZE)
         {
-            msg(M_WARN, "WARNING: ignoring --remote-random-hostname because the hostname is an IP address");
+            msg(M_WARN, "WARNING: ignoring --remote-random-hostname "
+                "because the hostname is an IP address");
         }
     }
 
@@ -1802,7 +1810,8 @@  resolve_remote(struct link_socket *sock,
                 sock->info.lsa->remote_list = ai;
                 sock->info.lsa->current_remote = ai;
 
-                dmsg(D_SOCKET_DEBUG, "RESOLVE_REMOTE flags=0x%04x phase=%d rrs=%d sig=%d status=%d",
+                dmsg(D_SOCKET_DEBUG,
+                     "RESOLVE_REMOTE flags=0x%04x phase=%d rrs=%d sig=%d status=%d",
                      flags,
                      phase,
                      retry,
@@ -3170,7 +3179,7 @@  static const struct proto_names proto_names[] = {
     {"udp6","UDPv6", AF_INET6, PROTO_UDP},
     {"tcp6-server","TCPv6_SERVER", AF_INET6, PROTO_TCP_SERVER},
     {"tcp6-client","TCPv6_CLIENT", AF_INET6, PROTO_TCP_CLIENT},
-    {"tcp6","TCPv6", AF_INET6, PROTO_TCP},
+    {"tcp6",       "TCPv6", AF_INET6, PROTO_TCP},
 };
 
 bool
@@ -3182,6 +3191,7 @@  proto_is_net(int proto)
     }
     return proto != PROTO_NONE;
 }
+
 bool
 proto_is_dgram(int proto)
 {