diff options
author | Werner Koch <[email protected]> | 2013-02-06 16:35:40 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2013-02-06 16:35:40 +0000 |
commit | 51fd6d8292cb41d743407e6ac9d86a5ab8e68d8c (patch) | |
tree | d431a193f5eece63dba5aa6485416e79f67396cb /src/data-compat.c | |
parent | Improve parsing of the GIT revision number. (diff) | |
download | gpgme-51fd6d8292cb41d743407e6ac9d86a5ab8e68d8c.tar.gz gpgme-51fd6d8292cb41d743407e6ac9d86a5ab8e68d8c.zip |
Use gpg_error_from_syserror instead of directly accessing errno.
--
Also fixed a couple of minor thing; e.g. save the error before calling
cleanup functions. Do not save the errno if only free is called
in between.
Diffstat (limited to 'src/data-compat.c')
-rw-r--r-- | src/data-compat.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/data-compat.c b/src/data-compat.c index b3b88672..e9ca90a9 100644 --- a/src/data-compat.c +++ b/src/data-compat.c @@ -60,7 +60,7 @@ gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname, if (fname) stream = fopen (fname, "rb"); if (!stream) - return TRACE_ERR (gpg_error_from_errno (errno)); + return TRACE_ERR (gpg_error_from_syserror ()); #ifdef HAVE_FSEEKO res = fseeko (stream, offset, SEEK_SET); @@ -71,31 +71,31 @@ gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname, if (res) { - int saved_errno = errno; + int saved_err = gpg_error_from_syserror (); if (fname) fclose (stream); - return TRACE_ERR (gpg_error_from_errno (saved_errno)); + return TRACE_ERR (saved_err); } buf = malloc (length); if (!buf) { - int saved_errno = errno; + int saved_err = gpg_error_from_syserror (); if (fname) fclose (stream); - return TRACE_ERR (gpg_error_from_errno (saved_errno)); + return TRACE_ERR (saved_err); } while (fread (buf, length, 1, stream) < 1 && ferror (stream) && errno == EINTR); if (ferror (stream)) { - int saved_errno = errno; + int saved_err = gpg_error_from_syserror (); if (buf) free (buf); if (fname) fclose (stream); - return TRACE_ERR (gpg_error_from_errno (saved_errno)); + return TRACE_ERR (saved_err); } if (fname) @@ -135,7 +135,7 @@ gpgme_data_new_from_file (gpgme_data_t *r_dh, const char *fname, int copy) return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); if (stat (fname, &statbuf) < 0) - return TRACE_ERR (gpg_error_from_errno (errno)); + return TRACE_ERR (gpg_error_from_syserror ()); err = gpgme_data_new_from_filepart (r_dh, fname, NULL, 0, statbuf.st_size); return TRACE_ERR (err); @@ -247,8 +247,8 @@ gpgme_data_rewind (gpgme_data_t dh) gpgme_error_t err; TRACE_BEG (DEBUG_DATA, "gpgme_data_rewind", dh); - err = (gpgme_data_seek (dh, 0, SEEK_SET) == -1) - ? gpg_error_from_errno (errno) : 0; + err = ((gpgme_data_seek (dh, 0, SEEK_SET) == -1) + ? gpg_error_from_syserror () : 0); return TRACE_ERR (err); } |