From 4cb7e65dc891e6319608b79fcb1e29e4622f65d1 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 13 Mar 2016 10:28:25 +0100 Subject: [PATCH] revise code to check the boot process --- hermit/tools/proxy.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/hermit/tools/proxy.c b/hermit/tools/proxy.c index c47a53666..0c560d61c 100644 --- a/hermit/tools/proxy.c +++ b/hermit/tools/proxy.c @@ -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);