diff options
author | Hung-ying Tyan <tyanh@google.com> | 2020-01-03 02:17:28 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-01-03 02:17:28 +0000 |
commit | 42f47b581b4728c66b496cec67f359f8cff2153e (patch) | |
tree | 2d29ccd895e25e03eab083732f2618703e8b91da | |
parent | 73a4a7243fcbb6a18f3608e3bfd3ddc3f0d47437 (diff) | |
parent | a8b838cd67c31d11f921bf674638ecdc391cf5e1 (diff) | |
download | tinyalsa-android10-gsi.tar.gz |
Merge "Merge branch android10-qpr1-release" into android10-gsiandroid10-gsi
-rw-r--r-- | tinymix.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -125,6 +125,16 @@ int main(int argc, char **argv) return ret; } +static int isnumber(const char *str) { + char *end; + + if (str == NULL || strlen(str) == 0) + return 0; + + strtol(str, &end, 0); + return strlen(end) == 0; +} + static void tinymix_list_controls(struct mixer *mixer) { struct mixer_ctl *ctl; @@ -195,7 +205,7 @@ static int tinymix_detail_control(struct mixer *mixer, const char *control, unsigned int tlv_header_size = 0; const char *space = g_tabs_only ? "\t" : " "; - if (isdigit(control[0])) + if (isnumber(control)) ctl = mixer_get_ctl(mixer, atoi(control)); else ctl = mixer_get_ctl_by_name(mixer, control); @@ -339,7 +349,7 @@ static int tinymix_set_value(struct mixer *mixer, const char *control, unsigned int num_ctl_values; unsigned int i; - if (isdigit(control[0])) + if (isnumber(control)) ctl = mixer_get_ctl(mixer, atoi(control)); else ctl = mixer_get_ctl_by_name(mixer, control); @@ -357,7 +367,7 @@ static int tinymix_set_value(struct mixer *mixer, const char *control, return ENOENT; } - if (isdigit(values[0][0])) { + if (isnumber(values[0])) { if (num_values == 1) { /* Set all values the same */ int value = atoi(values[0]); |