From 20dbc3be276f622e2ecfba799fc576e052d6fa8a Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Thu, 26 Nov 2020 10:43:42 +0100 Subject: [PATCH] [v0.90][ARM] Print bug message if SoC string is found but not detected. This is maybe too verbose, but I would like to increase the support for more ARM SoC, and I hope this message is useful for this purpose --- src/arm/soc.c | 39 +++++++++++++++++++-------------------- src/common/global.c | 6 +++++- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/arm/soc.c b/src/arm/soc.c index ba392b7..8973b63 100644 --- a/src/arm/soc.c +++ b/src/arm/soc.c @@ -269,14 +269,12 @@ static inline int android_property_get(const char* key, char* value) { return __system_property_get(key, value); } -struct system_on_chip* guess_soc_from_android() { - struct system_on_chip* soc = NULL; +struct system_on_chip* guess_soc_from_android(struct system_on_chip* soc) { char tmp[100]; int property_len = 0; property_len = android_property_get("ro.mediatek.platform", (char *) &tmp); if(property_len > 0) { - soc = malloc(sizeof(struct system_on_chip)); soc->raw_name = malloc(sizeof(char) * (property_len + 1)); strncpy(soc->raw_name, tmp, property_len + 1); soc->raw_name[property_len] = '\0'; @@ -286,7 +284,6 @@ struct system_on_chip* guess_soc_from_android() { property_len = android_property_get("ro.product.board", (char *) &tmp); if(property_len > 0) { - soc = malloc(sizeof(struct system_on_chip)); soc->raw_name = malloc(sizeof(char) * (property_len + 1)); strncpy(soc->raw_name, tmp, property_len + 1); soc->raw_name[property_len] = '\0'; @@ -298,36 +295,38 @@ struct system_on_chip* guess_soc_from_android() { } #endif -struct system_on_chip* guess_soc_from_cpuinfo() { - struct system_on_chip* soc = NULL; - +struct system_on_chip* guess_soc_from_cpuinfo(struct system_on_chip* soc) { char* tmp = get_hardware_from_cpuinfo(&strlen); + if(tmp != NULL) { - soc = malloc(sizeof(struct system_on_chip)); soc->raw_name = tmp; - soc->soc_vendor = SOC_UNKNOWN; return parse_soc_from_string(soc); } - return NULL; + return soc; } struct system_on_chip* get_soc() { - struct system_on_chip* soc = NULL; + struct system_on_chip* soc = malloc(sizeof(struct system_on_chip)); + soc->raw_name = NULL; + soc->soc_vendor = SOC_UNKNOWN; - soc = guess_soc_from_cpuinfo(); - if(soc == NULL) { - printWarn("SoC detection failed using /proc/cpuinfo"); + soc = guess_soc_from_cpuinfo(soc); + if(soc->soc_vendor == SOC_UNKNOWN) { + if(soc->raw_name != NULL) + printBug("SoC detection failed using /proc/cpuinfo: Found '%s' string", soc->raw_name); + else + printWarn("SoC detection failed using /proc/cpuinfo: No string found"); #ifdef __ANDROID__ - soc = guess_soc_from_android(); - if(soc == NULL) { - printWarn("SoC detection failed using Android"); - } + soc = guess_soc_from_android(soc); + if(soc->raw_name == NULL) + printWarn("SoC detection failed using Android: No string found"); + else if(soc->soc_vendor == SOC_UNKNOWN) + printBug("SoC detection failed using Android: Found '%s' string", soc->raw_name); #endif } - if(soc == NULL) { - soc = malloc(sizeof(struct system_on_chip)); + if(soc->raw_name == NULL) { soc->raw_name = malloc(sizeof(char) * (strlen(STRING_UNKNOWN)+1)); snprintf(soc->raw_name, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN); } diff --git a/src/common/global.c b/src/common/global.c index bfaa787..41c212c 100644 --- a/src/common/global.c +++ b/src/common/global.c @@ -53,7 +53,11 @@ void printBug(const char *fmt, ...) { vsnprintf(buffer,buffer_size, fmt, args); va_end(args); fprintf(stderr,RED "[ERROR]: "RESET "%s\n",buffer); - fprintf(stderr,"Please, create a new issue with this error message the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues\n"); +#ifdef ARCH_X86 + fprintf(stderr,"Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues\n"); +#elif ARCH_ARM + fprintf(stderr,"Please, create a new issue with this error message, your smartphone/computer model and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues\n"); +#endif } void set_log_level(bool verbose) {