Change usbg_add_config_function() to return usbg_error instead of returning 0 or -1. Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx> --- include/usbg/usbg.h | 2 +- src/usbg.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index ae53d22..249b40f 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -557,7 +557,7 @@ extern int usbg_set_config_string(usbg_config *c, int lang, char *string); * @param c Pointer to config * @param name Name of configuration function binding * @param f Pointer to function - * @return 0 on success, -1 on failure. + * @return 0 on success, usbg_error on failure. */ extern int usbg_add_config_function(usbg_config *c, char *name, usbg_function *f); diff --git a/src/usbg.c b/src/usbg.c index b14e917..860960a 100644 --- a/src/usbg.c +++ b/src/usbg.c @@ -1417,21 +1417,21 @@ int usbg_add_config_function(usbg_config *c, char *name, usbg_function *f) char bpath[USBG_MAX_PATH_LENGTH]; char fpath[USBG_MAX_PATH_LENGTH]; usbg_binding *b; - int ret = -1; + int ret = USBG_SUCCESS; if (!c || !f) - return ret; + return USBG_ERROR_INVALID_PARAM; b = usbg_get_binding(c, name); if (b) { ERROR("duplicate binding name\n"); - return ret; + return USBG_ERROR_EXIST; } b = usbg_get_link_binding(c, f); if (b) { ERROR("duplicate binding link\n"); - return ret; + return USBG_ERROR_EXIST; } sprintf(bpath, "%s/%s/%s", c->path, c->name, name); @@ -1440,13 +1440,15 @@ int usbg_add_config_function(usbg_config *c, char *name, usbg_function *f) b = malloc(sizeof(usbg_binding)); if (!b) { ERRORNO("allocating binding\n"); - return -1; + return USBG_ERROR_NO_MEM; } ret = symlink(fpath, bpath); if (ret < 0) { ERRORNO("%s -> %s\n", bpath, fpath); return ret; + } else { + ret = USBG_SUCCESS; } strcpy(b->name, name); @@ -1456,7 +1458,7 @@ int usbg_add_config_function(usbg_config *c, char *name, usbg_function *f) INSERT_TAILQ_STRING_ORDER(&c->bindings, bhead, name, b, bnode); - return 0; + return ret; } usbg_function *usbg_get_binding_target(usbg_binding *b) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html