Remove all trailing whitespace from source files
[gpgme.git] / src / sign.c
index 3d860da4647d6ec1c4e305ff4103634bc30c0971..15092049a4f89cbfa8bc25e785999ac64767cebe 100644 (file)
@@ -3,17 +3,17 @@
    Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH
 
    This file is part of GPGME.
    Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH
 
    This file is part of GPGME.
+
    GPGME is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.
    GPGME is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.
-   
+
    GPGME is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
    GPGME is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
-   
+
    You should have received a copy of the GNU Lesser General Public
    License along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    You should have received a copy of the GNU Lesser General Public
    License along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -149,7 +149,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
 
   sig = malloc (sizeof (*sig));
   if (!sig)
 
   sig = malloc (sizeof (*sig));
   if (!sig)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   sig->next = NULL;
   switch (*args)
 
   sig->next = NULL;
   switch (*args)
@@ -179,7 +179,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
       return gpg_error (GPG_ERR_INV_ENGINE);
     }
 
       return gpg_error (GPG_ERR_INV_ENGINE);
     }
 
-  errno = 0;
+  gpg_err_set_errno (0);
   sig->pubkey_algo = strtol (args, &tail, 0);
   if (errno || args == tail || *tail != ' ')
     {
   sig->pubkey_algo = strtol (args, &tail, 0);
   if (errno || args == tail || *tail != ' ')
     {
@@ -273,7 +273,7 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)
 
     case GPGME_STATUS_INV_RECP:
       if (opd->inv_sgnr_seen && opd->ignore_inv_recp)
 
     case GPGME_STATUS_INV_RECP:
       if (opd->inv_sgnr_seen && opd->ignore_inv_recp)
-        break; 
+        break;
       /* FALLTROUGH */
     case GPGME_STATUS_INV_SGNR:
       if (code == GPGME_STATUS_INV_SGNR)
       /* FALLTROUGH */
     case GPGME_STATUS_INV_SGNR:
       if (code == GPGME_STATUS_INV_SGNR)
@@ -393,6 +393,10 @@ gpgme_op_sign_start (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig,
   gpg_error_t err;
   TRACE_BEG3 (DEBUG_CTX, "gpgme_op_sign_start", ctx,
              "plain=%p, sig=%p, mode=%i", plain, sig, mode);
   gpg_error_t err;
   TRACE_BEG3 (DEBUG_CTX, "gpgme_op_sign_start", ctx,
              "plain=%p, sig=%p, mode=%i", plain, sig, mode);
+
+  if (!ctx)
+    return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+
   err = sign_start (ctx, 0, plain, sig, mode);
   return TRACE_ERR (err);
 }
   err = sign_start (ctx, 0, plain, sig, mode);
   return TRACE_ERR (err);
 }
@@ -407,6 +411,10 @@ gpgme_op_sign (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig,
 
   TRACE_BEG3 (DEBUG_CTX, "gpgme_op_sign", ctx,
              "plain=%p, sig=%p, mode=%i", plain, sig, mode);
 
   TRACE_BEG3 (DEBUG_CTX, "gpgme_op_sign", ctx,
              "plain=%p, sig=%p, mode=%i", plain, sig, mode);
+
+  if (!ctx)
+    return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+
   err = sign_start (ctx, 1, plain, sig, mode);
   if (!err)
     err = _gpgme_wait_one (ctx);
   err = sign_start (ctx, 1, plain, sig, mode);
   if (!err)
     err = _gpgme_wait_one (ctx);