diff options
author | Elliott Hughes | 2015-04-03 18:12:15 -0500 |
---|---|---|
committer | Elliott Hughes | 2015-04-03 18:12:15 -0500 |
commit | 09a45a1927415de1540ad9c94ed0052ef2eb2184 (patch) | |
tree | e9fb67f2c373585aa4824222f75bc7965d0f9d74 | |
parent | ea975880112c27293800ede36e0323ff2a7b9322 (diff) | |
download | platform-system-core-09a45a1927415de1540ad9c94ed0052ef2eb2184.tar.gz platform-system-core-09a45a1927415de1540ad9c94ed0052ef2eb2184.tar.xz platform-system-core-09a45a1927415de1540ad9c94ed0052ef2eb2184.zip |
Fix "adb devices -l".
Change 055f1aa4ff58ba71133d506b202ad46612758ded switched to using isalnum(3)
but didn't take into account that isalnum has the opposite sense to the
function it replaced, so the tests should have been inverted.
Bug: http://b/20056546
Change-Id: I90630c0bea69ddbb4a95dc09f79f49d23fd497de
-rw-r--r-- | adb/transport.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/adb/transport.cpp b/adb/transport.cpp index 0a960ff44..4b9eeeb7b 100644 --- a/adb/transport.cpp +++ b/adb/transport.cpp | |||
@@ -772,7 +772,7 @@ void remove_transport_disconnect(atransport* t, adisconnect* dis) | |||
772 | } | 772 | } |
773 | 773 | ||
774 | static int qual_match(const char *to_test, | 774 | static int qual_match(const char *to_test, |
775 | const char *prefix, const char *qual, int sanitize_qual) | 775 | const char *prefix, const char *qual, bool sanitize_qual) |
776 | { | 776 | { |
777 | if (!to_test || !*to_test) | 777 | if (!to_test || !*to_test) |
778 | /* Return true if both the qual and to_test are null strings. */ | 778 | /* Return true if both the qual and to_test are null strings. */ |
@@ -790,7 +790,7 @@ static int qual_match(const char *to_test, | |||
790 | 790 | ||
791 | while (*qual) { | 791 | while (*qual) { |
792 | char ch = *qual++; | 792 | char ch = *qual++; |
793 | if (sanitize_qual && isalnum(ch)) | 793 | if (sanitize_qual && !isalnum(ch)) |
794 | ch = '_'; | 794 | ch = '_'; |
795 | if (ch != *to_test++) | 795 | if (ch != *to_test++) |
796 | return 0; | 796 | return 0; |
@@ -823,9 +823,9 @@ retry: | |||
823 | if (serial) { | 823 | if (serial) { |
824 | if ((t->serial && !strcmp(serial, t->serial)) || | 824 | if ((t->serial && !strcmp(serial, t->serial)) || |
825 | (t->devpath && !strcmp(serial, t->devpath)) || | 825 | (t->devpath && !strcmp(serial, t->devpath)) || |
826 | qual_match(serial, "product:", t->product, 0) || | 826 | qual_match(serial, "product:", t->product, false) || |
827 | qual_match(serial, "model:", t->model, 1) || | 827 | qual_match(serial, "model:", t->model, true) || |
828 | qual_match(serial, "device:", t->device, 0)) { | 828 | qual_match(serial, "device:", t->device, false)) { |
829 | if (result) { | 829 | if (result) { |
830 | if (error_out) | 830 | if (error_out) |
831 | *error_out = "more than one device"; | 831 | *error_out = "more than one device"; |
@@ -918,20 +918,17 @@ static const char *statename(atransport *t) | |||
918 | } | 918 | } |
919 | 919 | ||
920 | static void add_qual(char **buf, size_t *buf_size, | 920 | static void add_qual(char **buf, size_t *buf_size, |
921 | const char *prefix, const char *qual, int sanitize_qual) | 921 | const char *prefix, const char *qual, bool sanitize_qual) |
922 | { | 922 | { |
923 | size_t len; | ||
924 | int prefix_len; | ||
925 | |||
926 | if (!buf || !*buf || !buf_size || !*buf_size || !qual || !*qual) | 923 | if (!buf || !*buf || !buf_size || !*buf_size || !qual || !*qual) |
927 | return; | 924 | return; |
928 | 925 | ||
929 | len = snprintf(*buf, *buf_size, "%s%n%s", prefix, &prefix_len, qual); | 926 | int prefix_len; |
927 | size_t len = snprintf(*buf, *buf_size, "%s%n%s", prefix, &prefix_len, qual); | ||
930 | 928 | ||
931 | if (sanitize_qual) { | 929 | if (sanitize_qual) { |
932 | char *cp; | 930 | for (char* cp = *buf + prefix_len; cp < *buf + len; cp++) { |
933 | for (cp = *buf + prefix_len; cp < *buf + len; cp++) { | 931 | if (!isalnum(*cp)) |
934 | if (isalnum(*cp)) | ||
935 | *cp = '_'; | 932 | *cp = '_'; |
936 | } | 933 | } |
937 | } | 934 | } |
@@ -956,10 +953,10 @@ static size_t format_transport(atransport *t, char *buf, size_t bufsize, | |||
956 | remaining -= len; | 953 | remaining -= len; |
957 | buf += len; | 954 | buf += len; |
958 | 955 | ||
959 | add_qual(&buf, &remaining, " ", t->devpath, 0); | 956 | add_qual(&buf, &remaining, " ", t->devpath, false); |
960 | add_qual(&buf, &remaining, " product:", t->product, 0); | 957 | add_qual(&buf, &remaining, " product:", t->product, false); |
961 | add_qual(&buf, &remaining, " model:", t->model, 1); | 958 | add_qual(&buf, &remaining, " model:", t->model, true); |
962 | add_qual(&buf, &remaining, " device:", t->device, 0); | 959 | add_qual(&buf, &remaining, " device:", t->device, false); |
963 | 960 | ||
964 | len = snprintf(buf, remaining, "\n"); | 961 | len = snprintf(buf, remaining, "\n"); |
965 | remaining -= len; | 962 | remaining -= len; |