Skip to content

Commit

Permalink
Fix check for KMS/FKMS
Browse files Browse the repository at this point in the history
sscanf returns the number of elements read, and the check
wasn't inserting any parameters into the format string.

If  no parameter is provided, do a strcmp instead.
  • Loading branch information
6by9 authored and popcornmix committed Jul 23, 2019
1 parent a7cda9b commit 5c7efb9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions revision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,21 @@ static int read_string_from_file(const char *filename, const char *format, unsig

while (fgets(str, sizeof(str), fin) != NULL)
{
if (sscanf(str, format, value) == 1)
if (value)
{
found = 1;
break;
if (sscanf(str, format, value) == 1)
{
found = 1;
break;
}
}
else
{
if (!strcmp(str, format))
{
found = 1;
break;
}
}
}

Expand Down Expand Up @@ -139,7 +150,6 @@ int get_processor_id(void)

int is_fkms_active()
{
unsigned int dummy;
return (read_string_from_file("/proc/device-tree/soc/v3d@7ec00000/status", "okay", &dummy) ||
read_string_from_file("/proc/device-tree/soc/firmwarekms@7e600000/status", "okay", &dummy));
return (read_string_from_file("/proc/device-tree/soc/v3d@7ec00000/status", "okay", NULL) ||
read_string_from_file("/proc/device-tree/soc/firmwarekms@7e600000/status", "okay", NULL));
}

0 comments on commit 5c7efb9

Please sign in to comment.