Functions which provides user length of some internal strings should return usbg_error instead of -1. Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx> --- include/usbg/usbg.h | 12 ++++++------ src/usbg.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index ffef084..ad52a5f 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -208,7 +208,7 @@ extern void usbg_cleanup(usbg_state *s); /** * @brief Get ConfigFS path length * @param s Pointer to state - * @return Length of path or -1 if error occurred. + * @return Length of path or usbg_error if error occurred. */ extern size_t usbg_get_configfs_path_len(usbg_state *s); @@ -293,7 +293,7 @@ extern usbg_gadget_attrs *usbg_get_gadget_attrs(usbg_gadget *g, /** * @brief Get gadget name length * @param g Gadget which name length should be returned - * @return Length of name string or -1 if error occurred. + * @return Length of name string or usbg_error if error occurred. */ extern size_t usbg_get_gadget_name_len(usbg_gadget *g); @@ -427,7 +427,7 @@ extern usbg_function *usbg_create_function(usbg_gadget *g, usbg_function_type ty /** * @brief Get function name length * @param f Config which name length should be returned - * @return Length of name string or -1 if error occurred. + * @return Length of name string or usbg_error if error occurred. */ extern size_t usbg_get_function_name_len(usbg_function *f); @@ -456,7 +456,7 @@ extern usbg_config *usbg_create_config(usbg_gadget *g, char *name, /** * @brief Get config name length * @param c Config which name length should be returned - * @return Length of name string or -1 if error occurred. + * @return Length of name string or usbg_error if error occurred. */ extern size_t usbg_get_config_name_len(usbg_config *c); @@ -546,7 +546,7 @@ extern usbg_function *usbg_get_binding_target(usbg_binding *b); /** * @brief Get binding name length * @param b Binding which name length should be returned - * @return Length of name string or -1 if error occurred. + * @return Length of name string or usbg_error if error occurred. */ extern size_t usbg_get_binding_name_len(usbg_binding *b); @@ -584,7 +584,7 @@ extern void usbg_disable_gadget(usbg_gadget *g); /** * @brief Get gadget name length * @param g Gadget which name length should be returned - * @return Length of name string or -1 if error occurred. + * @return Length of name string or usbg_error if error occurred. * @note If gadget isn't enabled on any udc returned size is 0. */ extern size_t usbg_get_gadget_udc_len(usbg_gadget *g); diff --git a/src/usbg.c b/src/usbg.c index 5cc5975..69cf367 100644 --- a/src/usbg.c +++ b/src/usbg.c @@ -737,7 +737,7 @@ void usbg_cleanup(usbg_state *s) size_t usbg_get_configfs_path_len(usbg_state *s) { - return s ? strlen(s->path) : -1; + return s ? strlen(s->path) : USBG_ERROR_INVALID_PARAM; } char *usbg_get_configfs_path(usbg_state *s, char *buf, size_t len) @@ -905,7 +905,7 @@ usbg_gadget_attrs *usbg_get_gadget_attrs(usbg_gadget *g, size_t usbg_get_gadget_name_len(usbg_gadget *g) { - return g ? strlen(g->name) : -1; + return g ? strlen(g->name) : USBG_ERROR_INVALID_PARAM; } char *usbg_get_gadget_name(usbg_gadget *g, char *buf, size_t len) @@ -915,7 +915,7 @@ char *usbg_get_gadget_name(usbg_gadget *g, char *buf, size_t len) size_t usbg_get_gadget_udc_len(usbg_gadget *g) { - return g ? strlen(g->udc) : -1; + return g ? strlen(g->udc) : USBG_ERROR_INVALID_PARAM; } char *usbg_get_gadget_udc(usbg_gadget *g, char *buf, size_t len) @@ -1135,7 +1135,7 @@ usbg_config *usbg_create_config(usbg_gadget *g, char *name, size_t usbg_get_config_name_len(usbg_config *c) { - return c ? strlen(c->name) : -1; + return c ? strlen(c->name) : USBG_ERROR_INVALID_PARAM; } char *usbg_get_config_name(usbg_config *c, char *buf, size_t len) @@ -1145,7 +1145,7 @@ char *usbg_get_config_name(usbg_config *c, char *buf, size_t len) size_t usbg_get_function_name_len(usbg_function *f) { - return f ? strlen(f->name) : -1; + return f ? strlen(f->name) : USBG_ERROR_INVALID_PARAM; } char *usbg_get_function_name(usbg_function *f, char *buf, size_t len) @@ -1265,7 +1265,7 @@ usbg_function *usbg_get_binding_target(usbg_binding *b) size_t usbg_get_binding_name_len(usbg_binding *b) { - return b ? strlen(b->name) : -1; + return b ? strlen(b->name) : USBG_ERROR_INVALID_PARAM; } char *usbg_get_binding_name(usbg_binding *b, char *buf, size_t len) -- 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