diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2016-12-14 13:03:26 +0100 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2016-12-14 13:03:26 +0100 |
commit | 3749ccec3d73284b869d458e4832616adfae31e3 (patch) | |
tree | 5afbc144e5a2a7e54c622199c7c401a6bf663060 | |
parent | a23dee0c86fb7e35f721e3bc17096d3138015ff4 (diff) | |
download | libusbg-3749ccec3d73284b869d458e4832616adfae31e3.tar.gz libusbg-3749ccec3d73284b869d458e4832616adfae31e3.tar.bz2 libusbg-3749ccec3d73284b869d458e4832616adfae31e3.zip |
libusbgx: Remove typedefs for public structures
Let's remove typedefs from public structures to clearly
indicate users which structures can be accessed and which
should be used only as handles.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
-rw-r--r-- | examples/gadget-acm-ecm.c | 6 | ||||
-rw-r--r-- | examples/gadget-ffs.c | 6 | ||||
-rw-r--r-- | examples/gadget-midi.c | 6 | ||||
-rw-r--r-- | examples/gadget-ms.c | 6 | ||||
-rw-r--r-- | examples/gadget-vid-pid-remove.c | 2 | ||||
-rw-r--r-- | examples/show-gadgets.c | 8 | ||||
-rw-r--r-- | include/usbg/usbg.h | 46 | ||||
-rw-r--r-- | src/usbg.c | 37 | ||||
-rw-r--r-- | src/usbg_schemes_libconfig.c | 12 | ||||
-rw-r--r-- | tests/test.c | 38 | ||||
-rw-r--r-- | tests/usbg-test.c | 40 | ||||
-rw-r--r-- | tests/usbg-test.h | 42 |
12 files changed, 137 insertions, 112 deletions
diff --git a/examples/gadget-acm-ecm.c b/examples/gadget-acm-ecm.c index b73135f..a531ca9 100644 --- a/examples/gadget-acm-ecm.c +++ b/examples/gadget-acm-ecm.c @@ -41,7 +41,7 @@ int main(void) int ret = -EINVAL; int usbg_ret; - usbg_gadget_attrs g_attrs = { + struct usbg_gadget_attrs g_attrs = { .bcdUSB = 0x0200, .bDeviceClass = USB_CLASS_PER_INTERFACE, .bDeviceSubClass = 0x00, @@ -52,13 +52,13 @@ int main(void) .bcdDevice = 0x0001, /* Verson of device */ }; - usbg_gadget_strs g_strs = { + struct usbg_gadget_strs g_strs = { .str_ser = "0123456789", /* Serial number */ .str_mnf = "Foo Inc.", /* Manufacturer */ .str_prd = "Bar Gadget" /* Product string */ }; - usbg_config_strs c_strs = { + struct usbg_config_strs c_strs = { .configuration = "CDC 2xACM+ECM" }; diff --git a/examples/gadget-ffs.c b/examples/gadget-ffs.c index 6ba10c6..289be3b 100644 --- a/examples/gadget-ffs.c +++ b/examples/gadget-ffs.c @@ -42,7 +42,7 @@ int main(void) int ret = -EINVAL; int usbg_ret; - usbg_gadget_attrs g_attrs = { + struct usbg_gadget_attrs g_attrs = { .bcdUSB = 0x0200, .bDeviceClass = USB_CLASS_PER_INTERFACE, .bDeviceSubClass = 0x00, @@ -53,13 +53,13 @@ int main(void) .bcdDevice = 0x0001, /* Verson of device */ }; - usbg_gadget_strs g_strs = { + struct usbg_gadget_strs g_strs = { .str_ser = "0123456789", /* Serial number */ .str_mnf = "Foo Inc.", /* Manufacturer */ .str_prd = "Bar Gadget" /* Product string */ }; - usbg_config_strs c_strs = { + struct usbg_config_strs c_strs = { .configuration = "2xFFS" }; diff --git a/examples/gadget-midi.c b/examples/gadget-midi.c index 2d56c0d..2e5e5a0 100644 --- a/examples/gadget-midi.c +++ b/examples/gadget-midi.c @@ -31,7 +31,7 @@ int main() { int ret = -EINVAL; int usbg_ret; - usbg_gadget_attrs g_attrs = { + struct usbg_gadget_attrs g_attrs = { .bcdUSB = 0x0200, .bDeviceClass = USB_CLASS_PER_INTERFACE, .bDeviceSubClass = 0x00, @@ -42,13 +42,13 @@ int main() { .bcdDevice = 0x0001, /* Verson of device */ }; - usbg_gadget_strs g_strs = { + struct usbg_gadget_strs g_strs = { .str_ser = "0123456789", /* Serial number */ .str_mnf = "Foo Inc.", /* Manufacturer */ .str_prd = "Bar Gadget" /* Product string */ }; - usbg_config_strs c_strs = { + struct usbg_config_strs c_strs = { .configuration = "1xMIDI" }; diff --git a/examples/gadget-ms.c b/examples/gadget-ms.c index 36b0847..699d56f 100644 --- a/examples/gadget-ms.c +++ b/examples/gadget-ms.c @@ -39,7 +39,7 @@ int main(int argc, char **argv) int ret = -EINVAL; int usbg_ret; - usbg_gadget_attrs g_attrs = { + struct usbg_gadget_attrs g_attrs = { .bcdUSB = 0x0200, .bDeviceClass = USB_CLASS_PER_INTERFACE, .bDeviceSubClass = 0x00, @@ -50,7 +50,7 @@ int main(int argc, char **argv) .bcdDevice = 0x0001, /* Verson of device */ }; - usbg_gadget_strs g_strs = { + struct usbg_gadget_strs g_strs = { .str_ser = "0123456789", /* Serial number */ .str_mnf = "Foo Inc.", /* Manufacturer */ .str_prd = "Bar Gadget" /* Product string */ @@ -90,7 +90,7 @@ int main(int argc, char **argv) .luns = f_ms_luns, }; - usbg_config_strs c_strs = { + struct usbg_config_strs c_strs = { "1xMass Storage" }; diff --git a/examples/gadget-vid-pid-remove.c b/examples/gadget-vid-pid-remove.c index c3f9c9b..f6b950b 100644 --- a/examples/gadget-vid-pid-remove.c +++ b/examples/gadget-vid-pid-remove.c @@ -66,7 +66,7 @@ int main(void) int ret = -EINVAL; usbg_state *s; usbg_gadget *g; - usbg_gadget_attrs g_attrs; + struct usbg_gadget_attrs g_attrs; usbg_ret = usbg_init("/sys/kernel/config", &s); if (usbg_ret != USBG_SUCCESS) { diff --git a/examples/show-gadgets.c b/examples/show-gadgets.c index dcac7d5..4fd7d40 100644 --- a/examples/show-gadgets.c +++ b/examples/show-gadgets.c @@ -42,8 +42,8 @@ void show_gadget(usbg_gadget *g) const char *name, *udc; usbg_udc *u; int usbg_ret; - usbg_gadget_attrs g_attrs; - usbg_gadget_strs g_strs; + struct usbg_gadget_attrs g_attrs; + struct usbg_gadget_strs g_strs; name = usbg_get_gadget_name(g); if (!name) { @@ -204,8 +204,8 @@ void show_config(usbg_config *c) usbg_function *f; const char *label, *instance, *bname; usbg_function_type type; - usbg_config_attrs c_attrs; - usbg_config_strs c_strs; + struct usbg_config_attrs c_attrs; + struct usbg_config_strs c_strs; int usbg_ret, id; label = usbg_get_config_label(c); diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index 8a3578d..4626fd0 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -120,10 +120,9 @@ typedef enum { } usbg_gadget_attr; /** - * @typedef usbg_gadget_attrs * @brief USB gadget device attributes */ -typedef struct +struct usbg_gadget_attrs { uint16_t bcdUSB; uint8_t bDeviceClass; @@ -133,7 +132,7 @@ typedef struct uint16_t idVendor; uint16_t idProduct; uint16_t bcdDevice; -} usbg_gadget_attrs; +}; typedef enum { USBG_GADGET_STR_MIN = 0, @@ -144,34 +143,31 @@ typedef enum { } usbg_gadget_str; /** - * @typedef usbg_gadget_strs * @brief USB gadget device strings */ -typedef struct +struct usbg_gadget_strs { char str_ser[USBG_MAX_STR_LENGTH]; char str_mnf[USBG_MAX_STR_LENGTH]; char str_prd[USBG_MAX_STR_LENGTH]; -} usbg_gadget_strs; +}; /** - * @typedef usbg_config_attrs * @brief USB configuration attributes */ -typedef struct +struct usbg_config_attrs { uint8_t bmAttributes; uint8_t bMaxPower; -} usbg_config_attrs; +}; /** - * @typedef usbg_config_strs * @brief USB configuration strings */ -typedef struct +struct usbg_config_strs { char configuration[USBG_MAX_STR_LENGTH]; -} usbg_config_strs; +}; /** * @typedef usbg_function_type @@ -392,7 +388,8 @@ extern int usbg_create_gadget_vid_pid(usbg_state *s, const char *name, * @return 0 on success usbg_error if error occurred */ extern int usbg_create_gadget(usbg_state *s, const char *name, - const usbg_gadget_attrs *g_attrs, const usbg_gadget_strs *g_strs, + const struct usbg_gadget_attrs *g_attrs, + const struct usbg_gadget_strs *g_strs, usbg_gadget **g); /** @@ -453,7 +450,7 @@ extern int usbg_get_gadget_attr(usbg_gadget *g, usbg_gadget_attr attr); * @return 0 on success usbg_error if error occurred */ extern int usbg_set_gadget_attrs(usbg_gadget *g, - const usbg_gadget_attrs *g_attrs); + const struct usbg_gadget_attrs *g_attrs); /** * @brief Get the USB gadget strings @@ -461,7 +458,8 @@ extern int usbg_set_gadget_attrs(usbg_gadget *g, * @param g_attrs Structure to be filled * @return 0 on success usbg_error if error occurred */ -extern int usbg_get_gadget_attrs(usbg_gadget *g, usbg_gadget_attrs *g_attrs); +extern int usbg_get_gadget_attrs(usbg_gadget *g, + struct usbg_gadget_attrs *g_attrs); /** * @brief Get gadget name @@ -561,7 +559,7 @@ extern int usbg_set_gadget_device_bcd_usb(usbg_gadget *g, uint16_t bcdUSB); * @return 0 on success usbg_error if error occurred */ extern int usbg_get_gadget_strs(usbg_gadget *g, int lang, - usbg_gadget_strs *g_strs); + struct usbg_gadget_strs *g_strs); /** * @brief Set selected string @@ -581,7 +579,7 @@ extern int usbg_set_gadget_str(usbg_gadget *g, usbg_gadget_str str, int lang, * @return 0 on success usbg_error if error occurred */ extern int usbg_set_gadget_strs(usbg_gadget *g, int lang, - const usbg_gadget_strs *g_strs); + const struct usbg_gadget_strs *g_strs); /** * @brief Set the serial number for a gadget @@ -716,8 +714,9 @@ extern int usbg_set_function_attrs(usbg_function *f, void *f_attrs); * @return 0 on success usbg_error if error occurred */ extern int usbg_create_config(usbg_gadget *g, int id, const char *label, - const usbg_config_attrs *c_attrs, const usbg_config_strs *c_strs, - usbg_config **c); + const struct usbg_config_attrs *c_attrs, + const struct usbg_config_strs *c_strs, + usbg_config **c); /** * @brief Get config label @@ -754,7 +753,7 @@ extern int usbg_get_config_id(usbg_config *c); * @return 0 on success or usbg_error if error occurred. */ extern int usbg_set_config_attrs(usbg_config *c, - const usbg_config_attrs *c_attrs); + const struct usbg_config_attrs *c_attrs); /** * @brief Get the USB configuration strings @@ -762,7 +761,8 @@ extern int usbg_set_config_attrs(usbg_config *c, * @param c_attrs Structure to be filled * @return 0 on success or usbg_error if error occurred. */ -extern int usbg_get_config_attrs(usbg_config *c, usbg_config_attrs *c_attrs); +extern int usbg_get_config_attrs(usbg_config *c, + struct usbg_config_attrs *c_attrs); /** * @brief Set the configuration maximum power @@ -788,7 +788,7 @@ extern int usbg_set_config_bm_attrs(usbg_config *c, int bmAttributes); * @return 0 on success or usbg_error if error occurred. */ extern int usbg_get_config_strs(usbg_config *c, int lang, - usbg_config_strs *c_strs); + struct usbg_config_strs *c_strs); /** * @brief Set the USB configuration strings @@ -798,7 +798,7 @@ extern int usbg_get_config_strs(usbg_config *c, int lang, * @return 0 on success, usbg_error on failure. */ extern int usbg_set_config_strs(usbg_config *c, int lang, - const usbg_config_strs *c_strs); + const struct usbg_config_strs *c_strs); /** * @brief Set the configuration string @@ -495,7 +495,7 @@ out: } static int usbg_parse_config_attrs(const char *path, const char *name, - usbg_config_attrs *c_attrs) + struct usbg_config_attrs *c_attrs) { int buf, ret; @@ -512,7 +512,7 @@ static int usbg_parse_config_attrs(const char *path, const char *name, } static int usbg_parse_config_strs(const char *path, const char *name, - int lang, usbg_config_strs *c_strs) + int lang, struct usbg_config_strs *c_strs) { DIR *dir; int ret; @@ -692,7 +692,7 @@ out: } static int usbg_parse_gadget_attrs(const char *path, const char *name, - usbg_gadget_attrs *g_attrs) + struct usbg_gadget_attrs *g_attrs) { int buf, ret; @@ -751,7 +751,7 @@ out: } static int usbg_parse_gadget_strs(const char *path, const char *name, int lang, - usbg_gadget_strs *g_strs) + struct usbg_gadget_strs *g_strs) { int ret; int nmb; @@ -1365,8 +1365,8 @@ out: } int usbg_create_gadget(usbg_state *s, const char *name, - const usbg_gadget_attrs *g_attrs, - const usbg_gadget_strs *g_strs, usbg_gadget **g) + const struct usbg_gadget_attrs *g_attrs, + const struct usbg_gadget_strs *g_strs, usbg_gadget **g) { usbg_gadget *gad; int ret; @@ -1410,7 +1410,8 @@ out: return ret; } -int usbg_get_gadget_attrs(usbg_gadget *g, usbg_gadget_attrs *g_attrs) +int usbg_get_gadget_attrs(usbg_gadget *g, + struct usbg_gadget_attrs *g_attrs) { return g && g_attrs ? usbg_parse_gadget_attrs(g->path, g->name, g_attrs) : USBG_ERROR_INVALID_PARAM; @@ -1534,7 +1535,8 @@ out: return g; } -int usbg_set_gadget_attrs(usbg_gadget *g, const usbg_gadget_attrs *g_attrs) +int usbg_set_gadget_attrs(usbg_gadget *g, + const struct usbg_gadget_attrs *g_attrs) { int ret; if (!g || !g_attrs) @@ -1630,7 +1632,7 @@ int usbg_set_gadget_device_bcd_usb(usbg_gadget *g, uint16_t bcdUSB) } int usbg_get_gadget_strs(usbg_gadget *g, int lang, - usbg_gadget_strs *g_strs) + struct usbg_gadget_strs *g_strs) { return g && g_strs ? usbg_parse_gadget_strs(g->path, g->name, lang, g_strs) : USBG_ERROR_INVALID_PARAM; @@ -1669,7 +1671,7 @@ out: } int usbg_set_gadget_strs(usbg_gadget *g, int lang, - const usbg_gadget_strs *g_strs) + const struct usbg_gadget_strs *g_strs) { char path[USBG_MAX_PATH_LENGTH]; int nmb; @@ -1840,8 +1842,9 @@ out: } int usbg_create_config(usbg_gadget *g, int id, const char *label, - const usbg_config_attrs *c_attrs, const usbg_config_strs *c_strs, - usbg_config **c) + const struct usbg_config_attrs *c_attrs, + const struct usbg_config_strs *c_strs, + usbg_config **c) { char cpath[USBG_MAX_PATH_LENGTH]; usbg_config *conf = NULL; @@ -1948,7 +1951,8 @@ int usbg_get_function_instance_s(usbg_function *f, char *buf, int len) return snprintf(buf, len, "%s", f->instance); } -int usbg_set_config_attrs(usbg_config *c, const usbg_config_attrs *c_attrs) +int usbg_set_config_attrs(usbg_config *c, + const struct usbg_config_attrs *c_attrs) { int ret = USBG_ERROR_INVALID_PARAM; @@ -1969,7 +1973,7 @@ out: } int usbg_get_config_attrs(usbg_config *c, - usbg_config_attrs *c_attrs) + struct usbg_config_attrs *c_attrs) { return c && c_attrs ? usbg_parse_config_attrs(c->path, c->name, c_attrs) : USBG_ERROR_INVALID_PARAM; @@ -1987,14 +1991,15 @@ int usbg_set_config_bm_attrs(usbg_config *c, int bmAttributes) : USBG_ERROR_INVALID_PARAM; } -int usbg_get_config_strs(usbg_config *c, int lang, usbg_config_strs *c_strs) +int usbg_get_config_strs(usbg_config *c, int lang, + struct usbg_config_strs *c_strs) { return c && c_strs ? usbg_parse_config_strs(c->path, c->name, lang, c_strs) : USBG_ERROR_INVALID_PARAM; } int usbg_set_config_strs(usbg_config *c, int lang, - const usbg_config_strs *c_strs) + const struct usbg_config_strs *c_strs) { return usbg_set_config_string(c, lang, c_strs->configuration); } diff --git a/src/usbg_schemes_libconfig.c b/src/usbg_schemes_libconfig.c index cd51d58..84006f5 100644 --- a/src/usbg_schemes_libconfig.c +++ b/src/usbg_schemes_libconfig.c @@ -99,7 +99,7 @@ static int usbg_export_config_strs_lang(usbg_config *c, char *lang_str, config_setting_t *root) { config_setting_t *node; - usbg_config_strs strs; + struct usbg_config_strs strs; int lang; int usbg_ret, cfg_ret, ret2; int ret = USBG_ERROR_NO_MEM; @@ -191,7 +191,7 @@ out: static int usbg_export_config_attrs(usbg_config *c, config_setting_t *root) { config_setting_t *node; - usbg_config_attrs attrs; + struct usbg_config_attrs attrs; int usbg_ret, cfg_ret; int ret = USBG_ERROR_NO_MEM; @@ -408,7 +408,7 @@ static int usbg_export_gadget_strs_lang(usbg_gadget *g, const char *lang_str, config_setting_t *root) { config_setting_t *node; - usbg_gadget_strs strs; + struct usbg_gadget_strs strs; int lang; int usbg_ret, cfg_ret; int ret; @@ -510,7 +510,7 @@ out: static int usbg_export_gadget_attrs(usbg_gadget *g, config_setting_t *root) { config_setting_t *node; - usbg_gadget_attrs attrs; + struct usbg_gadget_attrs attrs; int usbg_ret, cfg_ret; int ret = USBG_ERROR_NO_MEM; @@ -945,7 +945,7 @@ static int usbg_import_config_strs_lang(config_setting_t *root, usbg_config *c) config_setting_t *node; int lang; const char *str; - usbg_config_strs c_strs = {{0}}; + struct usbg_config_strs c_strs = {{0}}; int ret = USBG_ERROR_INVALID_TYPE; node = config_setting_get_member(root, USBG_LANG_TAG); @@ -1236,7 +1236,7 @@ static int usbg_import_gadget_strs_lang(config_setting_t *root, usbg_gadget *g) config_setting_t *node; int lang; const char *str; - usbg_gadget_strs g_strs = {{0}}; + struct usbg_gadget_strs g_strs = {{0}}; int ret = USBG_ERROR_INVALID_TYPE; node = config_setting_get_member(root, USBG_LANG_TAG); diff --git a/tests/test.c b/tests/test.c index 865aa0a..33760b0 100644 --- a/tests/test.c +++ b/tests/test.c @@ -43,7 +43,7 @@ .bound_funcs = b \ } -static usbg_gadget_attrs min_gadget_attrs = { +static struct usbg_gadget_attrs min_gadget_attrs = { .bcdUSB = 0x0000, .bDeviceClass = 0x0, .bDeviceSubClass = 0x0, @@ -54,7 +54,7 @@ static usbg_gadget_attrs min_gadget_attrs = { .bcdDevice = 0x0000 }; -static usbg_gadget_attrs max_gadget_attrs = { +static struct usbg_gadget_attrs max_gadget_attrs = { .bcdUSB = 0xffff, .bDeviceClass = 0xff, .bDeviceSubClass = 0xff, @@ -72,16 +72,16 @@ static char long_path_str[] = FILLED_STR(LONG_PATH_LEN, 'x'); /* NAME_MAX is limit for filename length */ static char long_usbg_string[] = FILLED_STR(NAME_MAX, 'x'); -static usbg_config_strs simple_config_strs= { +static struct usbg_config_strs simple_config_strs= { .configuration = "configuration string" }; -static usbg_config_attrs max_config_attrs = { +static struct usbg_config_attrs max_config_attrs = { .bmAttributes = 0xff, .bMaxPower = 0xff }; -static usbg_config_attrs min_config_attrs = { +static struct usbg_config_attrs min_config_attrs = { .bmAttributes = 0x00, .bMaxPower = 0x00 }; @@ -226,7 +226,7 @@ static char *writable_ffs_attrs = ""; struct test_gadget_strs_data { struct test_state *state; - usbg_gadget_strs *strs; + struct usbg_gadget_strs *strs; }; #define STATE(p, g, u) { \ @@ -249,9 +249,9 @@ static struct test_state long_path_state = STATE(long_path_str, simple_gadgets, static struct test_state long_udc_state = STATE("simple_path", long_udc_gadgets, long_udcs); -static usbg_config_attrs *get_random_config_attrs() +static struct usbg_config_attrs *get_random_config_attrs() { - usbg_config_attrs *ret; + struct usbg_config_attrs *ret; ret = safe_malloc(sizeof(*ret)); @@ -262,9 +262,9 @@ static usbg_config_attrs *get_random_config_attrs() return ret; } -static usbg_gadget_attrs *get_random_gadget_attrs() +static struct usbg_gadget_attrs *get_random_gadget_attrs() { - usbg_gadget_attrs *ret; + struct usbg_gadget_attrs *ret; ret = safe_malloc(sizeof(*ret)); @@ -286,7 +286,7 @@ static usbg_gadget_attrs *get_random_gadget_attrs() * @return Prepared state where configs has given attributes */ static void *prepare_state_with_config_attrs(struct test_state *state, - usbg_config_attrs *attrs) + struct usbg_config_attrs *attrs) { struct test_gadget *tg; struct test_config *tc; @@ -421,7 +421,7 @@ static int setup_long_udc_state(void **state) */ static int setup_random_len_gadget_strs_data(void **state) { - usbg_gadget_strs *strs; + struct usbg_gadget_strs *strs; struct test_gadget_strs_data *data; /* will fill memory with zeros */ @@ -1189,10 +1189,10 @@ static void test_get_config_id(void **state) * virtual filesystem for writting by usbg */ static void try_get_gadget_attrs(usbg_state *s, struct test_state *ts, - usbg_gadget_attrs *attrs) + struct usbg_gadget_attrs *attrs) { usbg_gadget *g = NULL; - usbg_gadget_attrs actual; + struct usbg_gadget_attrs actual; struct test_gadget *tg; int ret; @@ -1231,7 +1231,7 @@ static void test_get_gadget_attrs(void **state) * @param[in] attrs Pointer to gadget attributes to be set */ static void try_set_gadget_attrs(usbg_state *s, struct test_state *ts, - usbg_gadget_attrs *attrs) + struct usbg_gadget_attrs *attrs) { usbg_gadget *g = NULL; struct test_gadget *tg; @@ -1271,7 +1271,7 @@ static void test_set_gadget_attrs(void **state) * @param[in] attrs Pointer to gadget attributes to be set */ static void try_set_specific_gadget_attr(usbg_state *s, struct test_state *ts, - usbg_gadget_attrs *attrs) + struct usbg_gadget_attrs *attrs) { usbg_gadget *g = NULL; struct test_gadget *tg; @@ -1452,7 +1452,7 @@ static void test_get_gadget_strs(void **data) struct test_gadget *tg; usbg_state *s = NULL; usbg_gadget *g = NULL; - usbg_gadget_strs strs; + struct usbg_gadget_strs strs; ts = (struct test_gadget_strs_data *)(*data); *data = NULL; @@ -1615,7 +1615,7 @@ static void test_set_config_string(void **state) */ static void try_get_config_strs(usbg_config *c, struct test_config *tc) { - usbg_config_strs strs; + struct usbg_config_strs strs; push_config_strs(tc, LANG_US_ENG, tc->strs); usbg_get_config_strs(c, LANG_US_ENG, &strs); assert_string_equal(tc->strs->configuration, strs.configuration); @@ -1645,7 +1645,7 @@ static void test_get_config_strs(void **state) */ static void try_get_config_attrs(usbg_config *c, struct test_config *tc) { - usbg_config_attrs attrs; + struct usbg_config_attrs attrs; push_config_attrs(tc, tc->attrs); usbg_get_config_attrs(c, &attrs); diff --git a/tests/usbg-test.c b/tests/usbg-test.c index 078ed96..c8fabf9 100644 --- a/tests/usbg-test.c +++ b/tests/usbg-test.c @@ -662,7 +662,7 @@ void push_init(struct test_state *state) push_gadget(g); } -int get_gadget_attr(usbg_gadget_attrs *attrs, usbg_gadget_attr attr) +int get_gadget_attr(struct usbg_gadget_attrs *attrs, usbg_gadget_attr attr) { int ret = -1; @@ -726,7 +726,8 @@ void push_gadget_attribute(struct test_gadget *gadget, PUSH_FILE(path, content); } -void push_gadget_attrs(struct test_gadget *gadget, usbg_gadget_attrs *attrs) +void push_gadget_attrs(struct test_gadget *gadget, + struct usbg_gadget_attrs *attrs) { int i; @@ -734,7 +735,8 @@ void push_gadget_attrs(struct test_gadget *gadget, usbg_gadget_attrs *attrs) push_gadget_attribute(gadget, i, get_gadget_attr(attrs, i)); } -void pull_gadget_attrs(struct test_gadget *gadget, usbg_gadget_attrs *attrs) +void pull_gadget_attrs(struct test_gadget *gadget, + struct usbg_gadget_attrs *attrs) { int i; @@ -760,7 +762,7 @@ void safe_init_with_state(void **state, struct test_state **ts, usbg_state **s) *state = *s; } -static int get_config_attr(usbg_config_attrs *attrs, config_attr attr) +static int get_config_attr(struct usbg_config_attrs *attrs, config_attr attr) { int ret; @@ -800,7 +802,8 @@ void push_config_attribute(struct test_config *config, config_attr attr, } -void push_config_attrs(struct test_config *config, usbg_config_attrs *attrs) +void push_config_attrs(struct test_config *config, + struct usbg_config_attrs *attrs) { int i; @@ -835,7 +838,8 @@ void pull_config_attribute(struct test_config *config, config_attr attr, } } -void pull_config_attrs(struct test_config *config, usbg_config_attrs *attrs) +void pull_config_attrs(struct test_config *config, + struct usbg_config_attrs *attrs) { int i; @@ -843,7 +847,7 @@ void pull_config_attrs(struct test_config *config, usbg_config_attrs *attrs) pull_config_attribute(config, i, get_config_attr(attrs, i)); } -const char *get_gadget_str(usbg_gadget_strs *strs, gadget_str str) +const char *get_gadget_str(struct usbg_gadget_strs *strs, gadget_str str) { const char *ret = NULL; @@ -901,7 +905,8 @@ void pull_gadget_string(struct test_gadget *gadget, int lang, pull_gadget_str(gadget, gadget_str_names[str], lang, content); } -void pull_gadget_strs(struct test_gadget *gadget, int lang, usbg_gadget_strs *strs) +void pull_gadget_strs(struct test_gadget *gadget, int lang, + struct usbg_gadget_strs *strs) { int i; @@ -930,7 +935,8 @@ static void push_gadget_str(struct test_gadget *gadget, const char *attr_name, PUSH_FILE(path, content); } -void push_gadget_strs(struct test_gadget *gadget, int lang, usbg_gadget_strs *strs) +void push_gadget_strs(struct test_gadget *gadget, int lang, + struct usbg_gadget_strs *strs) { int i; @@ -963,7 +969,8 @@ void pull_config_string(struct test_config *config, int lang, const char *str) EXPECT_WRITE(path, str); } -void pull_config_strs(struct test_config *config, int lang, usbg_config_strs *strs) +void pull_config_strs(struct test_config *config, int lang, + struct usbg_config_strs *strs) { pull_config_string(config, lang, strs->configuration); } @@ -982,12 +989,14 @@ void push_config_string(struct test_config *config, int lang, const char *str) PUSH_FILE(path, str); } -void push_config_strs(struct test_config *config, int lang, usbg_config_strs *strs) +void push_config_strs(struct test_config *config, int lang, + struct usbg_config_strs *strs) { push_config_string(config, lang, strs->configuration); } -void assert_config_attrs_equal(usbg_config_attrs *actual, usbg_config_attrs *expected) +void assert_config_attrs_equal(struct usbg_config_attrs *actual, + struct usbg_config_attrs *expected) { assert_int_equal(actual->bmAttributes, expected->bmAttributes); assert_int_equal(actual->bMaxPower, expected->bMaxPower); @@ -1256,8 +1265,8 @@ int hex_str_equal_display_error(const LargestIntegralType actual, const LargestI return 0; } -void assert_gadget_attrs_equal(usbg_gadget_attrs *actual, - usbg_gadget_attrs *expected) +void assert_gadget_attrs_equal(struct usbg_gadget_attrs *actual, + struct usbg_gadget_attrs *expected) { int i; @@ -1265,7 +1274,8 @@ void assert_gadget_attrs_equal(usbg_gadget_attrs *actual, assert_int_equal(get_gadget_attr(actual, i), get_gadget_attr(expected, i)); } -void assert_gadget_strs_equal(usbg_gadget_strs *actual, usbg_gadget_strs *expected) +void assert_gadget_strs_equal(struct usbg_gadget_strs *actual, + struct usbg_gadget_strs *expected) { int i; for (i = 0; i < GADGET_STR_MAX; i++) diff --git a/tests/usbg-test.h b/tests/usbg-test.h index f7890ab..3748bf7 100644 --- a/tests/usbg-test.h +++ b/tests/usbg-test.h @@ -45,8 +45,8 @@ struct test_config char *path; char *name; int writable; - usbg_config_strs *strs; - usbg_config_attrs *attrs; + struct usbg_config_strs *strs; + struct usbg_config_attrs *attrs; }; struct test_gadget @@ -174,21 +174,23 @@ void push_init(struct test_state *state); * @param[in] config Configuration from which attributes will be get * @param[in] attrs Attributes which will be present in virtual filesystem */ -void push_config_attrs(struct test_config *config, usbg_config_attrs *attrs); +void push_config_attrs(struct test_config *config, + struct usbg_config_attrs *attrs); /** * @brief Preapre for setting config attributes * @param[in] config Configuration on which attributes will be set * @param[in] attrs Attributes which will be set on given config */ -void pull_config_attrs(struct test_config *config, usbg_config_attrs *attrs); +void pull_config_attrs(struct test_config *config, + struct usbg_config_attrs *attrs); /** * @brief Get gadget attribute * @param[in] attrs * @param[in] attr */ -int get_gadget_attr(usbg_gadget_attrs *attrs, usbg_gadget_attr attr); +int get_gadget_attr(struct usbg_gadget_attrs *attrs, usbg_gadget_attr attr); /** * @brief Prepare to write given attribute by libusbg @@ -217,7 +219,8 @@ void pull_gadget_attribute(struct test_gadget *gadget, * @warning Calling usbg_get_gadget_attrs function whithout this * preparation and with wrapped i/o may fail. */ -void push_gadget_attrs(struct test_gadget *gadget, usbg_gadget_attrs *attrs); +void push_gadget_attrs(struct test_gadget *gadget, + struct usbg_gadget_attrs *attrs); /** * @brief Prepare fake filesystem for attributes setting attempt. @@ -228,7 +231,8 @@ void push_gadget_attrs(struct test_gadget *gadget, usbg_gadget_attrs *attrs); * @warning Calling usbg_get_gadget_attrs function whithout this * preparation and with wrapped i/o may fail. */ -void pull_gadget_attrs(struct test_gadget *gadget, usbg_gadget_attrs *attrs); +void pull_gadget_attrs(struct test_gadget *gadget, + struct usbg_gadget_attrs *attrs); /** * @brief Prepare fake filesystem to get given function attributes @@ -254,7 +258,7 @@ void pull_function_attrs(struct test_function *func, void *attrs); * @param[in] str Identifier of string which should be returned * @return Selected string from given set of strings */ -const char *get_gadget_str(usbg_gadget_strs *strs, gadget_str str); +const char *get_gadget_str(struct usbg_gadget_strs *strs, gadget_str str); /** * @brief Prepare filesystem to set selected gadget string @@ -272,12 +276,14 @@ void pull_gadget_string(struct test_gadget *gadget, int lang, * @param[in] lang Language of strings * @param[in] strs Strings expected to be set */ -void pull_gadget_strs(struct test_gadget *gadget, int lang, usbg_gadget_strs *strs); +void pull_gadget_strs(struct test_gadget *gadget, int lang, + struct usbg_gadget_strs *strs); /** * @brief prepare for reading gadget's strings */ -void push_gadget_strs(struct test_gadget *gadget, int lang, usbg_gadget_strs *strs); +void push_gadget_strs(struct test_gadget *gadget, int lang, + struct usbg_gadget_strs *strs); /** * @brief Prepare for /ref usbg_set_config_string calling @@ -294,7 +300,8 @@ void pull_config_string(struct test_config *config, int lang, const char *str); * @param[in] lang Language of strings * @param[in] strs Strings expected to be set */ -void pull_config_strs(struct test_config *config, int lang, usbg_config_strs *strs); +void pull_config_strs(struct test_config *config, int lang, + struct usbg_config_strs *strs); /** * @brief Prepare for /ref usbg_get_config_string calling @@ -311,7 +318,8 @@ void push_config_string(struct test_config *config, int lang, const char *str); * @param[in] lang Language of strings * @param[in] strs Strings which should be returned */ -void push_config_strs(struct test_config *config, int lang, usbg_config_strs *strs); +void push_config_strs(struct test_config *config, int lang, + struct usbg_config_strs *strs); /** * @brief Prepare for creating config @@ -364,7 +372,8 @@ void safe_init_with_state(void **state, struct test_state **ts, usbg_state **s); /** * @brief Assert that given config attributes are equal */ -void assert_config_attrs_equal(usbg_config_attrs *actual, usbg_config_attrs *expected); +void assert_config_attrs_equal(struct usbg_config_attrs *actual, + struct usbg_config_attrs *expected); /** * @brief Assert that given usbg binding matches given test binding @@ -443,8 +452,8 @@ void assert_path_equal(const char *actual, const char *expected); * @param[in] actual Pointer to actual gadget attributes structure * @param[in] expected Pointer to expeced gadget attributes structure */ -void assert_gadget_attrs_equal(usbg_gadget_attrs *actual, - usbg_gadget_attrs *expected); +void assert_gadget_attrs_equal(struct usbg_gadget_attrs *actual, + struct usbg_gadget_attrs *expected); /** * @brief Assert that given function attributes are the same. @@ -457,7 +466,8 @@ void assert_function_attrs_equal(void *actual, void *expected, usbg_function_typ /** * @brief Assert that given gadget strings are equal */ -void assert_gadget_strs_equal(usbg_gadget_strs *actual, usbg_gadget_strs *expected); +void assert_gadget_strs_equal(struct usbg_gadget_strs *actual, + struct usbg_gadget_strs *expected); /** * @brief Function that performs some test on given usbg function |