diff options
author | Anatol Pomozov <anatol.pomozov@gmail.com> | 2020-03-06 21:00:15 +0100 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2020-03-09 07:34:17 +0100 |
commit | 80ae80149a956adec75df159f66a9cb88e91f5cc (patch) | |
tree | 38f9dd8c71bc43e8b70a1e3f34e5829686966257 | |
parent | 0deff63efa6310ab0a00365b876eb8632abd6ab4 (diff) | |
download | pacman-80ae80149a956adec75df159f66a9cb88e91f5cc.tar.gz pacman-80ae80149a956adec75df159f66a9cb88e91f5cc.tar.xz |
Add GOTO_ERR() macro to set error and then goto a label
This is a macro similar to RET_ERR but useful in the case when we need
to record an error and then jump to some cleanup section.
Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | lib/libalpm/util.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 9827b2c1..3aeb1b60 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -71,6 +71,11 @@ void _alpm_alloc_fail(size_t size); (handle)->pm_errno = (err); \ return (ret); } while(0) +#define GOTO_ERR(handle, err, label) do { \ + _alpm_log(handle, ALPM_LOG_DEBUG, "got error %d at %s (%s: %d) : %s\n", err, __func__, __FILE__, __LINE__, alpm_strerror(err)); \ + (handle)->pm_errno = (err); \ + goto label; } while(0) + #define RET_ERR_ASYNC_SAFE(handle, err, ret) do { \ (handle)->pm_errno = (err); \ return (ret); } while(0) |