[c-host] update to use new option validator and tidy up output

This commit is contained in:
Geoffrey McRae 2019-05-11 11:35:42 +10:00
parent 86c7286aad
commit 2ddae623b8
3 changed files with 12 additions and 6 deletions

View File

@ -1 +1 @@
a12-173-g9886316e07+1
a12-174-g86c7286aad+1

View File

@ -121,19 +121,19 @@ static int shmOpenDev(const char * shmDevice)
return fd;
}
static bool shmDeviceValidator(struct OptionValue * value)
static bool shmDeviceValidator(struct OptionValue * value, const char ** error)
{
char * name = uioGetName(value->v.x_string);
if (!name)
{
printf("Failed to get the uio device name for: %s\n", value->v.x_string);
*error = "Failed to get the uio device name";
return false;
}
if (strcmp(name, "KVMFR") != 0)
{
free(name);
printf("Device is not a KVMFR device \"%s\" reports as: %s\n", value->v.x_string, name);
*error = "Device is not a KVMFR device";
return false;
}
@ -143,7 +143,7 @@ static bool shmDeviceValidator(struct OptionValue * value)
static void shmDevicePrintHelp()
{
printf("Valid devices are:\n");
printf("Valid devices are:\n\n");
DIR * d = opendir("/sys/class/uio");
if (!d)
return;
@ -159,7 +159,7 @@ static void shmDevicePrintHelp()
continue;
if (strcmp(name, "KVMFR") == 0)
printf(" %s\n", dir->d_name);
printf(" * %s\n", dir->d_name);
free(name);
}

View File

@ -276,6 +276,12 @@ int app_main(int argc, char * argv[])
return -1;
}
if (!option_validate())
{
option_free();
return -1;
}
// perform platform specific initialization
if (!app_init())
return -1;