Remove unused function xor
PATCH 1/4 Remove unused function xor
The function name xor is also a reserved keyword in C++
--- src/openvpn/buffer.h | 10 ---------- 1 file changed, 10 deletions(-)
src/openvpn/buffer.h +0 -10
@@ -689,16 +689,6 @@ bool buf_string_compare_advance (struct buffer *src, const char *match);int buf_substring_len (const struct buffer *buf,int delim);/* -* Bitwise operations -*/ -static inline void -xor (uint8_t *dest,const uint8_t *src,int len) -{ -while (len-- >0 ) - *dest++ ^= *src++; -} - -/* * Print a string which might be NULL */ const char *np (const char *str);
Signature · 1 line
1.7.9.5
PATCH 2/4 Use casts when assigning void* variables.
Clang in c mode warns about these. In C++ mode these are forbidden.
--- src/openvpn/base64.c | 2 +- src/openvpn/buffer.c | 6 +++--- src/openvpn/init.c | 2 +- src/openvpn/list.c | 2 +- src/openvpn/misc.c | 4 ++-- src/openvpn/options.c | 8 ++++---- src/openvpn/plugin.c | 4 ++-- src/openvpn/proxy.c | 2 +- src/openvpn/route.c | 4 ++-- src/openvpn/ssl_openssl.c | 2 +- src/openvpn/ssl_verify_openssl.c | 8 ++++---- src/openvpn/ssl_verify_polarssl.c | 4 ++-- src/openvpn/win32.c | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-)
src/openvpn/base64.c +1 -1
@@ -137,7 +137,7 @@ openvpn_base64_decode(const char *str, void *data, int size)unsigned char *q;unsigned char *e =NULL ; - q = data; + q = (unsigned char *) data;if (size >=0 ) e = q + size;for (p = str; *p && (*p =='=' ||strchr (base64_chars, *p)); p +=4 ) {
src/openvpn/buffer.c +3 -3
@@ -71,7 +71,7 @@ alloc_buf (size_t size)#ifdef DMALLOC buf.data =openvpn_dmalloc (file, line, size);#else - buf.data =calloc (1 , size); + buf.data = (uint8_t *)calloc (1 , size);#endif check_malloc_return (buf.data);
@@ -547,7 +547,7 @@ string_alloc (const char *str, struct gc_arena *gc) ret =openvpn_dmalloc (file, line, n);memset (ret,0 , n);#else - ret =calloc (1 , n); + ret = (char *)calloc (1 , n);#endif check_malloc_return (ret); }
@@ -1041,7 +1041,7 @@ buffer_list_aggregate (struct buffer_list *bl, const size_t max)struct buffer_entry *e = bl->head, *f; ALLOC_OBJ_CLEAR (f, struct buffer_entry); - f->buf.data =malloc (size); + f->buf.data = (uint8_t *)malloc (size);check_malloc_return (f->buf.data); f->buf.capacity = size;for (i =0 ; e && i < count; ++i)
src/openvpn/init.c +1 -1
@@ -115,7 +115,7 @@ update_options_ce_post (struct options *options)static bool management_callback_proxy_cmd (void *arg,const char **p) { -struct context *c = arg; +struct context *c = (struct context *) arg;struct connection_entry *ce = &c->options.ce;struct gc_arena *gc = &c->c2.gc;bool ret = false;
src/openvpn/list.c +1 -1
@@ -215,7 +215,7 @@ hash_remove_marked (struct hash *hash, struct hash_bucket *bucket)uint32_t void_ptr_hash_function (const void *key,uint32_t iv) { -return hash_func ((const void *)&key,sizeof (key), iv); +return hash_func ((const uint8_t *)&key,sizeof (key), iv); }bool
src/openvpn/misc.c +2 -2
@@ -1746,7 +1746,7 @@ argv_term (const char **f) {char *ret;ASSERT (termlen >0 ); - ret =malloc (termlen +1 ); + ret = (char *)malloc (termlen +1 );check_malloc_return (ret);memcpy (ret, term, termlen); ret[termlen] ='\0' ;
@@ -2007,7 +2007,7 @@ argv_test (void)const char *sanitize_control_message (const char *src,struct gc_arena *gc) { -char *ret =gc_malloc (strlen (src)+1 , false, gc); +char *ret = (char *)gc_malloc (strlen (src)+1 , false, gc);char *dest = ret;bool redact = false;int skip =0 ;
src/openvpn/options.c +4 -4
@@ -3083,7 +3083,7 @@ options_warning_extract_parm1 (const char *option_string, {struct gc_arena gc =gc_new ();struct buffer b =string_alloc_buf (option_string, &gc); -char *p =gc_malloc (OPTION_PARM_SIZE , false, &gc); +char *p = (char *)gc_malloc (OPTION_PARM_SIZE , false, &gc);const char *ret;buf_parse (&b,' ' , p,OPTION_PARM_SIZE );
@@ -3115,7 +3115,7 @@ options_warning_safe_scan2 (const int msglevel,struct gc_arena gc =gc_new ();struct buffer b2 = *b2_src;const char *p1_prefix =options_warning_extract_parm1 (p1, &gc); -char *p2 =gc_malloc (OPTION_PARM_SIZE , false, &gc); +char *p2 = (char *)gc_malloc (OPTION_PARM_SIZE , false, &gc);while (buf_parse (&b2, delim, p2,OPTION_PARM_SIZE )) {
@@ -3162,7 +3162,7 @@ options_warning_safe_scan1 (const int msglevel, {struct gc_arena gc =gc_new ();struct buffer b = *b1_src; -char *p =gc_malloc (OPTION_PARM_SIZE , true, &gc); +char *p = (char *)gc_malloc (OPTION_PARM_SIZE , true, &gc);while (buf_parse (&b, delim, p,OPTION_PARM_SIZE ))options_warning_safe_scan2 (msglevel, delim, report_inconsistent, p, b2_src, b1_name, b2_name);
@@ -3563,7 +3563,7 @@ parse_line (const char *line,if (state ==STATE_DONE ) {/* ASSERT (parm_len > 0); */ - p[ret] =gc_malloc (parm_len +1 , true, gc); + p[ret] = (char *)gc_malloc (parm_len +1 , true, gc);memcpy (p[ret], parm, parm_len); p[ret][parm_len] ='\0' ; state =STATE_INITIAL ;
src/openvpn/plugin.c +2 -2
@@ -230,7 +230,7 @@ plugin_init_item (struct plugin *p, const struct plugin_option *o)if (!p->handle)msg (M_ERR ,"PLUGIN_INIT: could not load plugin shared object %s: %s" , p->so_pathname,dlerror ()); -# define PLUGIN_SYM (var, name, flags) libdl_resolve_symbol (p->handle, (void*)&p->var, name, p->so_pathname, flags) +# define PLUGIN_SYM (var, name, flags) libdl_resolve_symbol (p->handle, (void**)&p->var, name, p->so_pathname, flags)#else
@@ -325,7 +325,7 @@ plugin_vlog (openvpn_plugin_log_flags_t flags, const char *name, const char *for msg_flags |=M_NOIPREFIX ;gc_init (&gc); - msg_fmt =gc_malloc (ERR_BUF_SIZE , false, &gc); + msg_fmt = (char *)gc_malloc (ERR_BUF_SIZE , false, &gc);openvpn_snprintf (msg_fmt,ERR_BUF_SIZE ,"PLUGIN %s: %s" , name, format);x_msg_va (msg_flags, msg_fmt, arglist);
src/openvpn/proxy.c +1 -1
@@ -737,7 +737,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,if (opaque) {const int len =strlen (opaque)+16 ; - opaque_kv =gc_malloc (len, false, &gc); + opaque_kv = (char * )gc_malloc (len, false, &gc);openvpn_snprintf (opaque_kv, len,", opaque=\"%s\"" , opaque); }
src/openvpn/route.c +2 -2
@@ -113,7 +113,7 @@ struct route_option_list * clone_route_option_list (const struct route_option_list *src, struct gc_arena *a) { const size_t rl_size = array_mult_safe (sizeof(struct route_option), src->capacity, sizeof(struct route_option_list)); -struct route_option_list *ret =gc_malloc (rl_size, false, a); +struct route_option_list *ret = (struct route_option_list *)gc_malloc (rl_size, false, a);memcpy (ret, src, rl_size);return ret; }
@@ -122,7 +122,7 @@ struct route_ipv6_option_list * clone_route_ipv6_option_list (const struct route_ipv6_option_list *src, struct gc_arena *a) { const size_t rl_size = array_mult_safe (sizeof(struct route_ipv6_option), src->capacity, sizeof(struct route_ipv6_option_list)); -struct route_ipv6_option_list *ret =gc_malloc (rl_size, false, a); +struct route_ipv6_option_list *ret = (struct route_ipv6_option_list *)gc_malloc (rl_size, false, a);memcpy (ret, src, rl_size);return ret; }
src/openvpn/ssl_openssl.c +1 -1
@@ -74,7 +74,7 @@ tls_init_lib()#endif OpenSSL_add_all_algorithms (); - mydata_index =SSL_get_ex_new_index (0 ,"struct session *" ,NULL ,NULL ,NULL ); + mydata_index =SSL_get_ex_new_index (0 , (void *)"struct session *" ,NULL ,NULL ,NULL );ASSERT (mydata_index >=0 ); }
src/openvpn/ssl_verify_openssl.c +4 -4
@@ -52,7 +52,7 @@ verify_callback (int preverify_ok, X509_STORE_CTX * ctx)struct gc_arena gc =gc_new ();/* get the tls_session pointer */ - ssl =X509_STORE_CTX_get_ex_data (ctx,SSL_get_ex_data_X509_STORE_CTX_idx ()); + ssl = (SSL *)X509_STORE_CTX_get_ex_data (ctx,SSL_get_ex_data_X509_STORE_CTX_idx ());ASSERT (ssl); session = (struct tls_session *)SSL_get_ex_data (ssl, mydata_index);ASSERT (session);
@@ -241,7 +241,7 @@ x509_get_serial (openvpn_x509_cert_t *cert, struct gc_arena *gc)unsigned char *x509_get_sha1_hash (X509 *cert,struct gc_arena *gc) { -char *hash =gc_malloc (SHA_DIGEST_LENGTH , false, gc); +unsigned char *hash = (unsigned char *)gc_malloc (SHA_DIGEST_LENGTH , false, gc);memcpy (hash, cert->sha1_hash,SHA_DIGEST_LENGTH );return hash; }
@@ -260,7 +260,7 @@ x509_get_subject (X509 *cert, struct gc_arena *gc)*/ if (compat_flag (COMPAT_FLAG_QUERY |COMPAT_NAMES )) { - subject =gc_malloc (256 , false, gc); + subject = (char *)gc_malloc (256 , false, gc);X509_NAME_oneline (X509_get_subject_name (cert), subject,256 ); subject[255 ] ='\0' ;return subject;
@@ -280,7 +280,7 @@ x509_get_subject (X509 *cert, struct gc_arena *gc)BIO_get_mem_ptr (subject_bio, &subject_mem); maxlen = subject_mem->length +1 ; - subject =gc_malloc (maxlen, false, gc); + subject = (char *)gc_malloc (maxlen, false, gc);memcpy (subject, subject_mem->data, maxlen); subject[maxlen -1 ] ='\0' ;
src/openvpn/ssl_verify_polarssl.c +2 -2
@@ -133,7 +133,7 @@ x509_get_serial (x509_cert *cert, struct gc_arena *gc)char *buf =NULL ;size_t len = cert->serial.len *3 +1 ; - buf =gc_malloc (len, true, gc); + buf = (char *)gc_malloc (len, true, gc);if (x509parse_serial_gets (buf, len-1 , &cert->serial) <0 ) buf =NULL ;
@@ -144,7 +144,7 @@ x509_get_serial (x509_cert *cert, struct gc_arena *gc)unsigned char *x509_get_sha1_hash (x509_cert *cert,struct gc_arena *gc) { -unsigned char *sha1_hash =gc_malloc (SHA_DIGEST_LENGTH , false, gc); +unsigned char *sha1_hash = (unsigned char *)gc_malloc (SHA_DIGEST_LENGTH , false, gc);sha1 (cert->tbs.p, cert->tbs.len, sha1_hash);return sha1_hash; }
src/openvpn/win32.c +2 -2
@@ -829,7 +829,7 @@ wide_cmd_line (const struct argv *a, struct gc_arena *gc) maxlen = len; } - work =gc_malloc (maxlen +1 , false, gc); + work = (char *)gc_malloc (maxlen +1 , false, gc);check_malloc_return (work); buf =alloc_buf_gc (nchars, gc);
@@ -914,7 +914,7 @@ WCHAR * wide_string (const char* utf8, struct gc_arena *gc) { int n = MultiByteToWideChar (CP_UTF8, 0, utf8, -1, NULL, 0); -WCHAR *ucs16 =gc_malloc (n *sizeof (WCHAR ), false, gc); +WCHAR *ucs16 = (WCHAR *)gc_malloc (n *sizeof (WCHAR ), false, gc);MultiByteToWideChar (CP_UTF8 ,0 , utf8,-1 , ucs16, n);return ucs16; }
Signature · 1 line
1.7.9.5
PATCH 3/4 Move static prototype definition from header into c file
In reply to Arne Schwabe--- src/openvpn/tun.c | 2 ++ src/openvpn/tun.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-)
src/openvpn/tun.c +2 -0
@@ -73,6 +73,8 @@ static void solaris_error_close (struct tuntap *tt, const struct env_set *es, co#include <stropts.h> #endif +static void clear_tuntap (struct tuntap *tuntap); +bool is_dev_type (const char *dev,const char *dev_type,const char *match_type) {
src/openvpn/tun.h +0 -2
@@ -203,8 +203,6 @@ tuntap_defined (const struct tuntap *tt)* Function prototypes */ -static void clear_tuntap (struct tuntap *tuntap); -void open_tun (const char *dev,const char *dev_type,const char *dev_node,struct tuntap *tt);
Signature · 1 line
1.7.9.5
PATCH 4/4 Remove unused function no_tap_ifconfig
In reply to Arne Schwabe--- src/openvpn/tun.c | 10 ---------- 1 file changed, 10 deletions(-)
src/openvpn/tun.c +0 -10
@@ -300,16 +300,6 @@ warn_on_use_of_common_subnets (void) }/* -* Complain if --dev tap and --ifconfig is used on an OS for which -* we don't have a custom tap ifconfig template below. -*/ -static void -no_tap_ifconfig () -{ -msg (M_FATAL ,"Sorry but you cannot use --dev tap and --ifconfig together on this OS because I have not yet been programmed to understand the appropriate ifconfig syntax to use for TAP-style devices on this OS. Your best alternative is to use an --up script and do the ifconfig command manually." ); -} - -/* * Return a string to be used for options compatibility check * between peers. */
Signature · 1 line
1.7.9.5
ACK.
Your patch has been applied to the master and release/2.3 branch.
commit 462b6d5228660d664c3158902ee50687edf3475d (master) commit 589ef656c8718c38bfd82717d183ee0206dabc9b (release/2.3)
Author: Arne Schwabe Date: Mon Mar 11 21:10:48 2013 +0100
Remove unused function xor
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/7390
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Move static prototype definition from header into c file
In reply to Arne SchwabeACK.
Your patch has been applied to the master and release/2.3 branch.
commit 46d402f6513a6745daeaf08e9b260258e912f184 (master) commit 08c3b839bf796293e938170d004392c7f1d5bf16 (release/2.3)
Author: Arne Schwabe Date: Mon Mar 11 21:10:50 2013 +0100
Move static prototype definition from header into c file
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/7389
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Remove unused function no_tap_ifconfig
In reply to Arne SchwabeACK.
Your patch has been applied to the master and release/2.3 branch.
commit dc63e06b2c366f74752c8baa61b0f173d62511ad (master) commit a8cd06ea5acc6881edd10f3e5dabdc3354decb96 (master)
Author: Arne Schwabe Date: Mon Mar 11 21:10:51 2013 +0100
Remove unused function no_tap_ifconfig
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/7388
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH 2/4] Use casts when assigning void* variables.
In reply to Arne SchwabeHi,
Quoted 1 line · Arne Schwabe
Clang in c mode warns about these. In C++ mode these are forbidden.
I'm not so sure about this chunk of changes. I can see why you want this, but OTOH, this is all perfectly correct C (freely converting pointers to and from "void *" without(!) warnings), and some of these...
Review
Quoted 8 lines
(quoted diff) +3
-3- char *p = gc_malloc (OPTION_PARM_SIZE, false, &gc); + char *p = (char *) gc_malloc (OPTION_PARM_SIZE, false, &gc); - p[ret] = gc_malloc (parm_len + 1, true, gc); + p[ret] = (char *) gc_malloc (parm_len + 1, true, gc); - struct route_option_list *ret = gc_malloc (rl_size, false, a); + struct route_option_list *ret = (struct route_option_list *) gc_malloc (rl_size, false, a);
... do not really improve readability, more to the contrary.
(Some of the other casts make the code more clear, so I'm not objecting to all of it, just wondering... mostly about the gc_malloc() stuff... this really should be "malloc() return can be assigned to any pointer")
But I'm not strongly objecting. If you (for some vague "you") feel strongly about having the casts, I'll accept that.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...