1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

revise code to check the boot process

This commit is contained in:
Stefan Lankes 2016-03-13 10:28:25 +01:00
parent 0e681c8695
commit 4cb7e65dc8

View file

@ -142,33 +142,20 @@ static int init_env(void)
exit(1);
}
if (str)
result = (char*) malloc(strlen(str)+128);
else
result = (char*) malloc(128);
result = NULL;
ret = fscanf(file, "%ms", &result);
fclose(file);
if (!result)
{
perror("malloc");
if (ret <= 0) {
fprintf(stderr, "Unable to check the boot process!\n");
exit(1);
}
fscanf(file, "%s", result);
fclose(file);
if (str) {
if (strcmp(result, str) != 0) {
free(result);
fprintf(stderr, "Unable to boot cores %s\n", result);
exit(1);
}
} else {
if (strcmp(result, "1") != 0) {
free(result);
fprintf(stderr, "Unable to boot core 1");
exit(1);
}
if (strcmp(result, "-1") == 0) {
free(result);
fprintf(stderr, "Unable to boot cores %s\n", str ? str : "1");
exit(1);
}
free(result);