[v0.88][ARM][BUGFIX] Fix bugs in single CPU SoCs and small bugs related to strings

This commit is contained in:
Dr-Noob
2020-11-24 10:27:33 +01:00
parent 71d660d7b1
commit 685e78f2b7
4 changed files with 6 additions and 7 deletions

View File

@@ -150,12 +150,15 @@ char* get_str_freq(struct frequency* freq) {
uint32_t size = (4+3+1);
assert(strlen(STRING_UNKNOWN)+1 <= size);
char* string = malloc(sizeof(char)*size);
memset(string, 0, sizeof(char)*size);
if(freq->max == UNKNOWN_FREQ)
snprintf(string,strlen(STRING_UNKNOWN)+1,STRING_UNKNOWN);
else if(freq->max >= 1000)
snprintf(string,size,"%.2f"STRING_GIGAHERZ,(float)(freq->max)/1000);
else
snprintf(string,size,"%.2f"STRING_MEGAHERZ,(float)(freq->max));
snprintf(string,size,"%lld"STRING_MEGAHERZ,freq->max);
return string;
}

View File

@@ -563,13 +563,7 @@ bool print_cpufetch_arm(struct ascii* art, struct cpuInfo* cpu, struct colors* c
setAttribute(art,ATTRIBUTE_L2,l2);
if(l3 != NULL) {
setAttribute(art,ATTRIBUTE_L3,l3);
free(l3);
}
free(max_frequency);
free(l1i);
free(l1d);
free(l2);
}
else {
struct cpuInfo* ptr = cpu;

View File

@@ -129,6 +129,7 @@ int get_ncores_from_cpuinfo() {
char* tmp1 = strstr(buf, "-") + 1;
char* tmp2 = strstr(buf, "\n");
char ncores_str[offset];
memset(ncores_str, 0, sizeof(char) * offset);
memcpy(ncores_str, tmp1, tmp2-tmp1);
char* end;