From 943486f573ea5395d8b38735dbe019d2a3dfc5dd Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 13 Feb 2020 22:09:37 +0100 Subject: Add a "sequence error" to libsquashfs error codes Signed-off-by: David Oberhollenzer --- include/sqfs/error.h | 12 ++++++++++++ lib/common/perror.c | 3 +++ 2 files changed, 15 insertions(+) diff --git a/include/sqfs/error.h b/include/sqfs/error.h index 77e33ed..055e98f 100644 --- a/include/sqfs/error.h +++ b/include/sqfs/error.h @@ -133,6 +133,18 @@ typedef enum { * @brief An invalid argument was passed to a library function. */ SQFS_ERROR_ARG_INVALID = -16, + + /** + * @brief Library functions were called an a nonsensical order. + * + * Some libsquashfs functions operate on an object with an internal + * state. Depending on the state, calling a function might not make + * sense at all (e.g. calling foo_end before foo_begin). In that case, + * this error is returned, signifying to the caller that the sequence + * makes not sense, but the object itself is unchanged, no action was + * performed and the object can still be used. + */ + SQFS_ERROR_SEQUENCE = -17, } E_SQFS_ERROR; #endif /* SQFS_ERROR_H */ diff --git a/lib/common/perror.c b/lib/common/perror.c index a0a86aa..c7dab08 100644 --- a/lib/common/perror.c +++ b/lib/common/perror.c @@ -61,6 +61,9 @@ void sqfs_perror(const char *file, const char *action, int error_code) case SQFS_ERROR_ARG_INVALID: errstr = "invalid argument"; break; + case SQFS_ERROR_SEQUENCE: + errstr = "illegal oder of operations"; + break; default: errstr = "libsquashfs returned an unknown error code"; break; -- cgit v1.2.3