threads / bug / 36319

socket_perror() "bug"?

Subject: socket_perror() "bug"?

## tl;dr

4 messages between Mar 30, 2014 and Apr 3, 2014.

replies: 3people: 2as markdown or json

Thiago Farina· Mar 30, 2014, 19:32 UTC · lore
Hi,

In imap-send.c:socket_perror() we pass |func| as a parameter, which I think it is the name of the function that "called" socket_perror, or the name of the function which generated an error.

But at line 184 and 187 it always assume it was SSL_connect.
Should we instead call perror() and ssl_socket_error() with func?

-- Thiago Farina

Junio C Hamano· Mar 31, 2014, 20:50 UTC · re: Thiago Farina · lore

Re: socket_perror() "bug"?

Thiago Farina <tfransosi@gmail.com> writes:
Show 7 quoted lines
> In imap-send.c:socket_perror() we pass |func| as a parameter, which I
> think it is the name of the function that "called" socket_perror, or
> the name of the function which generated an error.
>
> But at line 184 and 187 it always assume it was SSL_connect.
>
> Should we instead call perror() and ssl_socket_error() with func?
Looks that way to me, at least from a cursory look.
Thiago Farina· Apr 2, 2014, 23:05 UTC · re: Junio C Hamano · lore

Re: socket_perror() "bug"?

On Mon, Mar 31, 2014 at 5:50 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 11 quoted lines
> Thiago Farina <tfransosi@gmail.com> writes:
>
>> In imap-send.c:socket_perror() we pass |func| as a parameter, which I
>> think it is the name of the function that "called" socket_perror, or
>> the name of the function which generated an error.
>>
>> But at line 184 and 187 it always assume it was SSL_connect.
>>
>> Should we instead call perror() and ssl_socket_error() with func?
>
> Looks that way to me, at least from a cursory look.
Would you accept such a patch?
diff --git a/imap-send.c b/imap-send.c
index 0bc6f7f..bb04768 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -181,10 +181,10 @@ static void socket_perror(const char *func,
struct imap_socket *sock, int ret)
                case SSL_ERROR_NONE:
                        break;
                case SSL_ERROR_SYSCALL:
-                       perror("SSL_connect");
+                       perror(func);
                        break;
                default:
-                       ssl_socket_perror("SSL_connect");
+                       ssl_socket_perror(func);
                        break;
                }
        } else

--
Thiago Farina
Junio C Hamano· Apr 3, 2014, 19:01 UTC · re: Thiago Farina · lore

Re: socket_perror() "bug"?

Thiago Farina <tfransosi@gmail.com> writes:
Show 13 quoted lines
> On Mon, Mar 31, 2014 at 5:50 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Thiago Farina <tfransosi@gmail.com> writes:
>>
>>> In imap-send.c:socket_perror() we pass |func| as a parameter, which I
>>> think it is the name of the function that "called" socket_perror, or
>>> the name of the function which generated an error.
>>>
>>> But at line 184 and 187 it always assume it was SSL_connect.
>>>
>>> Should we instead call perror() and ssl_socket_error() with func?
>>
>> Looks that way to me, at least from a cursory look.
> Would you accept such a patch?

This back-and-forth makes me wonder what is going on. Why not send a full patch with a proper proposed commit log message to the list and see what happens?

Show 21 quoted lines
> diff --git a/imap-send.c b/imap-send.c
> index 0bc6f7f..bb04768 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -181,10 +181,10 @@ static void socket_perror(const char *func,
> struct imap_socket *sock, int ret)
>                 case SSL_ERROR_NONE:
>                         break;
>                 case SSL_ERROR_SYSCALL:
> -                       perror("SSL_connect");
> +                       perror(func);
>                         break;
>                 default:
> -                       ssl_socket_perror("SSL_connect");
> +                       ssl_socket_perror(func);
>                         break;
>                 }
>         } else
>
> --
> Thiago Farina

← back to recent threads