Skip to content

Commit

Permalink
plugins: adrv9002: API version validation fix
Browse files Browse the repository at this point in the history
- validation failed if driver was "68.8.1" and profile gen was "v68.8.1"

Signed-off-by: Andrei Popa <[email protected]>
  • Loading branch information
andrei47w committed May 13, 2024
1 parent 12a9849 commit 0f1e1fb
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion plugins/adrv9002.c
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,25 @@ static char *profile_gen_cli_get_api(void)
return version;
}

static char *strip_nonnumeric_chars(char *string)
{
int i;
char *str = (char *)malloc(strlen(string) * sizeof(char));
strcpy(str, string);

while((str[0] < '0' || str[0] > '9') && str[0] != '\0') {
str++;
}

i = strlen(str) - 1;
while((str[i] < '0' || str[i] > '9') && i > 0) {
str[i] = '\0';
i--;
}

return str;
}

static bool profile_gen_check_api(gpointer data)
{
struct plugin_private *priv = data;
Expand All @@ -2281,7 +2300,7 @@ static bool profile_gen_check_api(gpointer data)
goto err;
}

if(strcmp(version, supported_version) != 0) {
if(strcmp(strip_nonnumeric_chars(supported_version), strip_nonnumeric_chars(version)) != 0) {
sprintf(message, "\nOnly API version %s is supported, the device uses %s!", supported_version, version);
profile_gen_set_debug_info(data, message);
free(supported_version);
Expand Down

0 comments on commit 0f1e1fb

Please sign in to comment.