Skip to content

Commit

Permalink
Rename function to simplify
Browse files Browse the repository at this point in the history
For consistency with sc_adb_parse_device(), do not include "from_output"
in the function name.
  • Loading branch information
rom1v committed Jun 9, 2022
1 parent 55e65fa commit b1d8c72
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/src/adb/adb.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,5 +710,5 @@ sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags) {
// It is parsed as a NUL-terminated string
buf[r] = '\0';

return sc_adb_parse_device_ip_from_output(buf);
return sc_adb_parse_device_ip(buf);
}
2 changes: 1 addition & 1 deletion app/src/adb/adb_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ sc_adb_parse_device_ip_from_line(char *line) {
}

char *
sc_adb_parse_device_ip_from_output(char *str) {
sc_adb_parse_device_ip(char *str) {
size_t idx_line = 0;
while (str[idx_line] != '\0') {
char *line = &str[idx_line];
Expand Down
2 changes: 1 addition & 1 deletion app/src/adb/adb_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ sc_adb_parse_devices(char *str, struct sc_vec_adb_devices *out_vec);
* Warning: this function modifies the buffer for optimization purposes.
*/
char *
sc_adb_parse_device_ip_from_output(char *str);
sc_adb_parse_device_ip(char *str);

#endif
16 changes: 8 additions & 8 deletions app/tests/test_adb_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static void test_get_ip_single_line(void) {
char ip_route[] = "192.168.1.0/24 dev wlan0 proto kernel scope link src "
"192.168.12.34\r\r\n";

char *ip = sc_adb_parse_device_ip_from_output(ip_route);
char *ip = sc_adb_parse_device_ip(ip_route);
assert(ip);
assert(!strcmp(ip, "192.168.12.34"));
free(ip);
Expand All @@ -177,7 +177,7 @@ static void test_get_ip_single_line_without_eol(void) {
char ip_route[] = "192.168.1.0/24 dev wlan0 proto kernel scope link src "
"192.168.12.34";

char *ip = sc_adb_parse_device_ip_from_output(ip_route);
char *ip = sc_adb_parse_device_ip(ip_route);
assert(ip);
assert(!strcmp(ip, "192.168.12.34"));
free(ip);
Expand All @@ -187,7 +187,7 @@ static void test_get_ip_single_line_with_trailing_space(void) {
char ip_route[] = "192.168.1.0/24 dev wlan0 proto kernel scope link src "
"192.168.12.34 \n";

char *ip = sc_adb_parse_device_ip_from_output(ip_route);
char *ip = sc_adb_parse_device_ip(ip_route);
assert(ip);
assert(!strcmp(ip, "192.168.12.34"));
free(ip);
Expand All @@ -199,7 +199,7 @@ static void test_get_ip_multiline_first_ok(void) {
"10.0.0.0/24 dev rmnet proto kernel scope link src "
"10.0.0.2\r\n";

char *ip = sc_adb_parse_device_ip_from_output(ip_route);
char *ip = sc_adb_parse_device_ip(ip_route);
assert(ip);
assert(!strcmp(ip, "192.168.1.2"));
free(ip);
Expand All @@ -211,7 +211,7 @@ static void test_get_ip_multiline_second_ok(void) {
"192.168.1.0/24 dev wlan0 proto kernel scope link src "
"192.168.1.3\r\n";

char *ip = sc_adb_parse_device_ip_from_output(ip_route);
char *ip = sc_adb_parse_device_ip(ip_route);
assert(ip);
assert(!strcmp(ip, "192.168.1.3"));
free(ip);
Expand All @@ -221,23 +221,23 @@ static void test_get_ip_no_wlan(void) {
char ip_route[] = "192.168.1.0/24 dev rmnet proto kernel scope link src "
"192.168.12.34\r\r\n";

char *ip = sc_adb_parse_device_ip_from_output(ip_route);
char *ip = sc_adb_parse_device_ip(ip_route);
assert(!ip);
}

static void test_get_ip_no_wlan_without_eol(void) {
char ip_route[] = "192.168.1.0/24 dev rmnet proto kernel scope link src "
"192.168.12.34";

char *ip = sc_adb_parse_device_ip_from_output(ip_route);
char *ip = sc_adb_parse_device_ip(ip_route);
assert(!ip);
}

static void test_get_ip_truncated(void) {
char ip_route[] = "192.168.1.0/24 dev rmnet proto kernel scope link src "
"\n";

char *ip = sc_adb_parse_device_ip_from_output(ip_route);
char *ip = sc_adb_parse_device_ip(ip_route);
assert(!ip);
}

Expand Down

0 comments on commit b1d8c72

Please sign in to comment.