local: Do not call local_init more times
This commit is contained in:
1 parent
8635ea66a7
commit
288726981a
1 file changed
+9
-2
+9
-2
@@ -30,6 +30,7 @@
|
||||
#include "image.h"
|
||||
|
||||
static enum device device = DEVICE_UNKNOWN;
|
||||
static int failed;
|
||||
|
||||
int local_init(void) {
|
||||
|
||||
@@ -38,10 +39,15 @@ int local_init(void) {
|
||||
char * ptr2;
|
||||
FILE * file;
|
||||
|
||||
file = fopen("/proc/cpuinfo", "r");
|
||||
if (!file)
|
||||
if ( failed )
|
||||
return -1;
|
||||
|
||||
file = fopen("/proc/cpuinfo", "r");
|
||||
if ( ! file ) {
|
||||
failed = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ( fgets(buf, sizeof(buf), file) ) {
|
||||
|
||||
if ( strncmp(buf, "Hardware", strlen("Hardware")) == 0 ) {
|
||||
@@ -100,6 +106,7 @@ int local_init(void) {
|
||||
|
||||
}
|
||||
|
||||
failed = 1;
|
||||
printf("Not a local device\n");
|
||||
fclose(file);
|
||||
return -1;
|
||||
|
||||
Reference in new issue
Block a user