# [PATCH] imap-send.c: fix pointer to be const

3 messages from 2009-10-28 to 2009-10-28. Participants: Vietor Liu, Junio C Hamano.
Thread: https://gitlist.dev/t/21396

## Vietor Liu, 2009-10-28 07:24

Subject: [PATCH] imap-send.c: fix pointer to be const
Message-ID: <1256714677-3659-1-git-send-email-vietor@vxwo.org>
URL: https://gitlist.dev/e/1256714677-3659-1-git-send-email-vietor%40vxwo.org

```
Fixes some compiler warnings:
imap-send.c: In function ‘ssl_socket_connect’:
warning: assignment discards qualifiers from pointer target type

====================================================
OpenSSL Changes between 0.9.8k and 1.0:

*) Let the TLSv1_method() etc. functions return a 'const' SSL_METHOD
     pointer and make the SSL_METHOD parameter in SSL_CTX_new,
     SSL_CTX_set_ssl_version and SSL_set_ssl_method 'const'.

Signed-off-by: Vietor Liu <vietor@vxwo.org>
---
 imap-send.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index 3847fd1..10dd025 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -273,7 +273,7 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve
 	fprintf(stderr, "SSL requested but SSL support not compiled in\n");
 	return -1;
 #else
-	SSL_METHOD *meth;
+	const SSL_METHOD *meth;
 	SSL_CTX *ctx;
 	int ret;
 
-- 
1.6.5.2

```

## Junio C Hamano, 2009-10-28 07:25

Subject: Re: [PATCH] imap-send.c: fix pointer to be const
Message-ID: <7vljiwq8tc.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vljiwq8tc.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1256714677-3659-1-git-send-email-vietor@vxwo.org>

```
Vietor Liu <vietor@vxwo.org> writes:

> Fixes some compiler warnings:
> imap-send.c: In function ‘ssl_socket_connect’:
> warning: assignment discards qualifiers from pointer target type
>
> ====================================================
> OpenSSL Changes between 0.9.8k and 1.0:
>
> *) Let the TLSv1_method() etc. functions return a 'const' SSL_METHOD
>      pointer and make the SSL_METHOD parameter in SSL_CTX_new,
>      SSL_CTX_set_ssl_version and SSL_set_ssl_method 'const'.
>
> Signed-off-by: Vietor Liu <vietor@vxwo.org>

This is much easier to understand.

Thanks.

> ---
>  imap-send.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/imap-send.c b/imap-send.c
> index 3847fd1..10dd025 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -273,7 +273,7 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve
>  	fprintf(stderr, "SSL requested but SSL support not compiled in\n");
>  	return -1;
>  #else
> -	SSL_METHOD *meth;
> +	const SSL_METHOD *meth;
>  	SSL_CTX *ctx;
>  	int ret;
>  
> -- 
> 1.6.5.2

```

## Junio C Hamano, 2009-10-28 07:48

Subject: Re: [PATCH] imap-send.c: fix pointer to be const
Message-ID: <7v8wewq7rb.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v8wewq7rb.fsf%40alter.siamese.dyndns.org
In-Reply-To: <7vljiwq8tc.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> Vietor Liu <vietor@vxwo.org> writes:
>
>> Fixes some compiler warnings:
>> imap-send.c: In function ‘ssl_socket_connect’:
>> warning: assignment discards qualifiers from pointer target type
>>
>> ====================================================
>> OpenSSL Changes between 0.9.8k and 1.0:
>>
>> *) Let the TLSv1_method() etc. functions return a 'const' SSL_METHOD
>>      pointer and make the SSL_METHOD parameter in SSL_CTX_new,
>>      SSL_CTX_set_ssl_version and SSL_set_ssl_method 'const'.
>>
>> Signed-off-by: Vietor Liu <vietor@vxwo.org>
>
> This is much easier to understand.

This indeed _is_ easier to understand, but what this means is that making
"meth" const will break the compilation for people with 0.9.8k.

Their SSL_CTX_new() does not promise the callers that it won't modify the
object its parameter points at, so SSL_CTX_new(meth) will now see exactly
the same issue.  You will be discarding "const" qualifier by passing it.

```
