Fixed little bug in cache print and changed message when no cache level was found

This commit is contained in:
Dr-Noob
2018-03-29 23:35:42 +02:00
parent 978f283e1a
commit 720457f4ac
2 changed files with 26 additions and 12 deletions

4
main.c
View File

@@ -51,8 +51,8 @@ int main() {
printf(TITLE_AES"%s\n",aes); printf(TITLE_AES"%s\n",aes);
printf(TITLE_SHA"%s\n",sha); printf(TITLE_SHA"%s\n",sha);
printf(TITLE_L1"%s\n",l1); printf(TITLE_L1"%s\n",l1);
printf(TITLE_L3"%s\n",l2); printf(TITLE_L2"%s\n",l2);
printf(TITLE_L2"%s\n",l3); printf(TITLE_L3"%s\n",l3);
printf(TITLE_PEAK"%s\n","??? GFLOP/s"); printf(TITLE_PEAK"%s\n","??? GFLOP/s");
free(cpuName); free(cpuName);

14
udev.c
View File

@@ -115,19 +115,33 @@ char* getString_L1(struct cache* cach) {
} }
char* getString_L2(struct cache* cach) { char* getString_L2(struct cache* cach) {
if(cach->L2 == NO_CACHE) {
char* string = malloc(sizeof(char)*5);
snprintf(string,5,"None");
return string;
}
else {
//Max 4 digits and 2 for 'KB' //Max 4 digits and 2 for 'KB'
int size = (4+2+1); int size = (4+2+1);
char* string = malloc(sizeof(char)*size); char* string = malloc(sizeof(char)*size);
snprintf(string,size,"%dKB",cach->L2/1024); snprintf(string,size,"%dKB",cach->L2/1024);
return string; return string;
}
} }
char* getString_L3(struct cache* cach) { char* getString_L3(struct cache* cach) {
if(cach->L3 == NO_CACHE) {
char* string = malloc(sizeof(char)*5);
snprintf(string,5,"None");
return string;
}
else {
//Max 4 digits and 2 for 'KB' //Max 4 digits and 2 for 'KB'
int size = (4+2+1); int size = (4+2+1);
char* string = malloc(sizeof(char)*size); char* string = malloc(sizeof(char)*size);
snprintf(string,size,"%dKB",cach->L3/1024); snprintf(string,size,"%dKB",cach->L3/1024);
return string; return string;
}
} }
char* getString_MaxFrequency(struct frequency* freq) { char* getString_MaxFrequency(struct frequency* freq) {