summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaeyoung <ty317.kim@samsung.com>2016-09-23 19:03:05 +0900
committertaeyoung <ty317.kim@samsung.com>2016-09-23 19:03:32 +0900
commitf28463f3d87d0cbcf9a66647f455283c0d045a69 (patch)
tree5532908132f03086fca43c38e2ca40370eb446b2
parentd25dbaed77aeb19345d57af73f64989a1d5e6265 (diff)
downloadlibusbg-f28463f3d87d0cbcf9a66647f455283c0d045a69.tar.gz
libusbg-f28463f3d87d0cbcf9a66647f455283c0d045a69.tar.bz2
libusbg-f28463f3d87d0cbcf9a66647f455283c0d045a69.zip
Revert "common: fix minor issues."
This reverts commit d25dbaed77aeb19345d57af73f64989a1d5e6265. Change-Id: Ic6abcb23180f4b015b41a994b36f78607bd0081c Signed-off-by: taeyoung <ty317.kim@samsung.com>
-rw-r--r--examples/gadget-export.c2
-rw-r--r--examples/gadget-import.c2
-rw-r--r--include/usbg/usbg_internal.h6
-rw-r--r--src/usbg.c12
-rw-r--r--src/usbg_schemes_libconfig.c9
-rw-r--r--tests/usbg-test.c11
6 files changed, 18 insertions, 24 deletions
diff --git a/examples/gadget-export.c b/examples/gadget-export.c
index 15059fa..9d51e9e 100644
--- a/examples/gadget-export.c
+++ b/examples/gadget-export.c
@@ -43,7 +43,7 @@ int main(int argc, char **argv)
/* Prepare output file */
output = fopen(argv[2], "w");
if (!output) {
- fprintf(stderr, "Error on fopen. Error: %d\n", errno);
+ fprintf(stderr, "Error on fopen. Error: %s\n", strerror(errno));
goto out1;
}
diff --git a/examples/gadget-import.c b/examples/gadget-import.c
index a57e5da..e684fdb 100644
--- a/examples/gadget-import.c
+++ b/examples/gadget-import.c
@@ -42,7 +42,7 @@ int main(int argc, char **argv)
/* Prepare input file */
input = fopen(argv[2], "r");
if (!input) {
- fprintf(stderr, "Error on fopen. Error: %d\n", errno);
+ fprintf(stderr, "Error on fopen. Error: %s\n", strerror(errno));
goto out1;
}
diff --git a/include/usbg/usbg_internal.h b/include/usbg/usbg_internal.h
index 9331e46..30d3fcf 100644
--- a/include/usbg/usbg_internal.h
+++ b/include/usbg/usbg_internal.h
@@ -130,8 +130,8 @@ struct usbg_udc
} while (0)
#define ERRORNO(msg, ...) do {\
- fprintf(stderr, "%s() errno:%d: "msg" \n", \
- __func__, errno, ##__VA_ARGS__);\
+ fprintf(stderr, "%s() %s: "msg" \n", \
+ __func__, strerror(errno), ##__VA_ARGS__);\
fflush(stderr);\
} while (0)
@@ -168,7 +168,7 @@ static inline int file_select(const struct dirent *dent)
int usbg_translate_error(int error);
-char *usbg_ether_ntoa_r(const struct ether_addr *addr, char *buf, size_t len);
+char *usbg_ether_ntoa_r(const struct ether_addr *addr, char *buf);
#endif /* USBG_INTERNAL_H */
diff --git a/src/usbg.c b/src/usbg.c
index 5102443..b9c53e8 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -901,9 +901,9 @@ static int usbg_rm_all_dirs(const char *path)
return ret;
}
-char *usbg_ether_ntoa_r(const struct ether_addr *addr, char *buf, size_t len)
+char *usbg_ether_ntoa_r(const struct ether_addr *addr, char *buf)
{
- snprintf(buf, len, "%02x:%02x:%02x:%02x:%02x:%02x",
+ sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
addr->ether_addr_octet[0], addr->ether_addr_octet[1],
addr->ether_addr_octet[2], addr->ether_addr_octet[3],
addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
@@ -3090,12 +3090,12 @@ int usbg_set_function_net_attrs(usbg_function *f, const usbg_f_net_attrs *attrs)
goto out;
}
- addr = usbg_ether_ntoa_r(&attrs->dev_addr, addr_buf, sizeof(addr_buf));
+ addr = usbg_ether_ntoa_r(&attrs->dev_addr, addr_buf);
ret = usbg_write_string(f->path, f->name, "dev_addr", addr);
if (ret != USBG_SUCCESS)
goto out;
- addr = usbg_ether_ntoa_r(&attrs->host_addr, addr_buf, sizeof(addr_buf));
+ addr = usbg_ether_ntoa_r(&attrs->host_addr, addr_buf);
ret = usbg_write_string(f->path, f->name, "host_addr", addr);
if (ret != USBG_SUCCESS)
goto out;
@@ -3390,7 +3390,7 @@ int usbg_set_net_dev_addr(usbg_function *f, struct ether_addr *dev_addr)
if (f && dev_addr) {
char str_buf[USBG_MAX_STR_LENGTH];
- char *str_addr = usbg_ether_ntoa_r(dev_addr, str_buf, sizeof(str_buf));
+ char *str_addr = usbg_ether_ntoa_r(dev_addr, str_buf);
ret = usbg_write_string(f->path, f->name, "dev_addr", str_addr);
} else {
ret = USBG_ERROR_INVALID_PARAM;
@@ -3405,7 +3405,7 @@ int usbg_set_net_host_addr(usbg_function *f, struct ether_addr *host_addr)
if (f && host_addr) {
char str_buf[USBG_MAX_STR_LENGTH];
- char *str_addr = usbg_ether_ntoa_r(host_addr, str_buf, sizeof(str_buf));
+ char *str_addr = usbg_ether_ntoa_r(host_addr, str_buf);
ret = usbg_write_string(f->path, f->name, "host_addr", str_addr);
} else {
ret = USBG_ERROR_INVALID_PARAM;
diff --git a/src/usbg_schemes_libconfig.c b/src/usbg_schemes_libconfig.c
index 77638ce..c8944ed 100644
--- a/src/usbg_schemes_libconfig.c
+++ b/src/usbg_schemes_libconfig.c
@@ -326,7 +326,7 @@ static int usbg_export_f_net_attrs(usbg_f_net_attrs *attrs,
if (!node)
goto out;
- addr = usbg_ether_ntoa_r(&attrs->dev_addr, addr_buf, sizeof(addr_buf));
+ addr = usbg_ether_ntoa_r(&attrs->dev_addr, addr_buf);
cfg_ret = config_setting_set_string(node, addr);
if (cfg_ret != CONFIG_TRUE) {
ret = USBG_ERROR_OTHER_ERROR;
@@ -337,7 +337,7 @@ static int usbg_export_f_net_attrs(usbg_f_net_attrs *attrs,
if (!node)
goto out;
- addr = usbg_ether_ntoa_r(&attrs->host_addr, addr_buf, sizeof(addr_buf));
+ addr = usbg_ether_ntoa_r(&attrs->host_addr, addr_buf);
cfg_ret = config_setting_set_string(node, addr);
if (cfg_ret != CONFIG_TRUE) {
ret = USBG_ERROR_OTHER_ERROR;
@@ -1120,7 +1120,7 @@ static int usbg_import_f_ms_attrs(config_setting_t *root, usbg_function *f)
}
luns_node = config_setting_get_member(root, "luns");
- if (!luns_node) {
+ if (!node) {
ret = USBG_ERROR_INVALID_PARAM;
goto out;
}
@@ -1861,9 +1861,6 @@ static int usbg_import_gadget_strings(config_setting_t *root, usbg_gadget *g)
for (i = 0; i < count; ++i) {
node = config_setting_get_elem(root, i);
- if (!node)
- continue;
-
if (!config_setting_is_group(node)) {
ret = USBG_ERROR_INVALID_TYPE;
break;
diff --git a/tests/usbg-test.c b/tests/usbg-test.c
index e480ca9..c332795 100644
--- a/tests/usbg-test.c
+++ b/tests/usbg-test.c
@@ -1089,21 +1089,18 @@ static void pull_function_net_attrs(struct test_function *func, usbg_f_net_attrs
{
char *path;
char *content;
- size_t len;
safe_asprintf(&path, "%s/%s/dev_addr", func->path, func->name);
- len = ETHER_ADDR_STR_LEN * sizeof(char);
-
- content = safe_malloc(len);
- usbg_ether_ntoa_r(&attrs->dev_addr, content, len);
+ content = safe_malloc(ETHER_ADDR_STR_LEN * sizeof(char));
+ usbg_ether_ntoa_r(&attrs->dev_addr, content);
EXPECT_WRITE(path, content);
safe_asprintf(&path, "%s/%s/host_addr", func->path, func->name);
- content = safe_malloc(len);
- usbg_ether_ntoa_r(&attrs->host_addr, content, len);
+ content = safe_malloc(ETHER_ADDR_STR_LEN * sizeof(char));
+ usbg_ether_ntoa_r(&attrs->host_addr, content);
EXPECT_WRITE(path, content);