From 080e5a8d90830c0d5c9d365e429f748e938a9485 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 26 Apr 2011 00:12:16 -0700 Subject: [PATCH] * gnutls.c (emacs_gnutls_handshake): Don't return a garbage value. Expect the caller to check whether GNUTLS_STAGE_HANDSHAKE_CANDO <= proc->gnutls_initstage, if the check is needed. The check isn't needed for one caller, Fgnutls_boot. (emacs_gnutls_read): Do that check. This is the other caller. --- src/ChangeLog | 6 ++++++ src/gnutls.c | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 6614375a7c6..8bdc3861f9b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2011-04-26 Paul Eggert + * gnutls.c (emacs_gnutls_handshake): Don't return a garbage value. + Expect the caller to check whether GNUTLS_STAGE_HANDSHAKE_CANDO <= + proc->gnutls_initstage, if the check is needed. The check isn't + needed for one caller, Fgnutls_boot. + (emacs_gnutls_read): Do that check. This is the other caller. + lisp.h: Fix a problem with aliasing and vector headers. GCC 4.6.0 optimizes based on type-based alias analysis. For example, if b is of type struct buffer * and v of type struct diff --git a/src/gnutls.c b/src/gnutls.c index ea0a9857035..e75d8e71757 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -73,9 +73,6 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) gnutls_session_t state = proc->gnutls_state; int ret; - if (proc->gnutls_initstage < GNUTLS_STAGE_HANDSHAKE_CANDO) - return; - if (proc->gnutls_initstage < GNUTLS_STAGE_TRANSPORT_POINTERS_SET) { #ifdef WINDOWSNT @@ -179,7 +176,8 @@ emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf, if (proc->gnutls_initstage != GNUTLS_STAGE_READY) { - emacs_gnutls_handshake (proc); + if (GNUTLS_STAGE_HANDSHAKE_CANDO <= proc->gnutls_initstage) + emacs_gnutls_handshake (proc); return -1; } rtnval = gnutls_read (state, buf, nbyte); -- 2.39.2