Subject: recent gnutls.c changes broke build on Ubuntu 10.10

From: Paul Eggert <[email-masked]>
Date: Tue, 26 Apr 2011 00:18:16 -0700

bzr 103998 introduced a bug in emacs_gnutls_handshake: it has
a 'return;' statement in a function returning an integer, which
violates the C standard.  I plan to fix this with the following
patch, for lack of a better idea, but it would be nice if someone
with more expertise in gnutls could double-check this.

* gnutls.c (emacs_gnutls_handshake): Always return a 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.
=== modified file 'src/gnutls.c'
--- src/gnutls.c	2011-04-26 06:17:52 +0000
+++ src/gnutls.c	2011-04-26 07:05:42 +0000
@@ -73,9 +73,6 @@
   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 @@

   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);