From 943835a0e708226f8edfe9d1adffccde69e8762d Mon Sep 17 00:00:00 2001
From: Pawel Szewczyk
Date: Mon, 6 Jul 2015 13:13:57 +0200
Subject: [PATCH] libusbgx: Add USBG_ERROR_NOT_EMPTY error code
ENOTEMPTY error is common when removing configfs objects. This commit
adds proper error message and internal usbg error code for this
situation.
Signed-off-by: Pawel Szewczyk
[Update description]
Signed-off-by: Krzysztof Opasiak
---
include/usbg/usbg.h | 1 +
src/usbg.c | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h
index dc16c41..913ffa9 100644
--- a/include/usbg/usbg.h
+++ b/include/usbg/usbg.h
@@ -312,6 +312,7 @@ typedef enum {
USBG_ERROR_MISSING_TAG = -12,
USBG_ERROR_INVALID_TYPE = -13,
USBG_ERROR_INVALID_VALUE = -14,
+ USBG_ERROR_NOT_EMPTY = -15,
USBG_ERROR_OTHER_ERROR = -99
} usbg_error;
diff --git a/src/usbg.c b/src/usbg.c
index 720da9a..0ae82ec 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -104,6 +104,9 @@ int usbg_translate_error(int error)
case EBUSY:
ret = USBG_ERROR_BUSY;
break;
+ case ENOTEMPTY:
+ ret = USBG_ERROR_NOT_EMPTY;
+ break;
default:
ret = USBG_ERROR_OTHER_ERROR;
}
@@ -161,6 +164,9 @@ const char *usbg_error_name(usbg_error e)
case USBG_ERROR_INVALID_VALUE:
ret = "USBG_ERROR_INVALID_VALUE";
break;
+ case USBG_ERROR_NOT_EMPTY:
+ ret = "USBG_ERROR_NOT_EMPTY";
+ break;
case USBG_ERROR_OTHER_ERROR:
ret = "USBG_ERROR_OTHER_ERROR";
break;
@@ -219,6 +225,9 @@ const char *usbg_strerror(usbg_error e)
case USBG_ERROR_INVALID_VALUE:
ret = "Incorrect value provided as attribute.";
break;
+ case USBG_ERROR_NOT_EMPTY:
+ ret = "Entity is not empty.";
+ break;
case USBG_ERROR_OTHER_ERROR:
ret = "Other error";
break;
--
2.7.4