Skip to content

Commit

Permalink
fix memory reporting with bad cast
Browse files Browse the repository at this point in the history
  • Loading branch information
an-prata committed Jun 10, 2023
1 parent b8635d4 commit fd595eb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ int main(int argc, char** argv) {

// This is every variable outputted as part of the fetch.
unsigned long stor_capacity, stor_used;
unsigned int longest_entry_len, mem_capacity_u;
unsigned int longest_entry_len;
long mem_capacity_u;
double stor_capacity_dec, stor_used_dec, mem_capacity;
char * stor_unit, * mem_unit, * kern_version, * host_name, cpu_model[1024];
const char* pac_man = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/sysinf.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sysinf_err_t get_root_size(unsigned long* size, unsigned long* usage) {
return SI_ERR_NONE;
}

sysinf_err_t get_memory_capacity(unsigned int* mem_cap) {
sysinf_err_t get_memory_capacity(long* mem_cap) {
char mem_capacity_str[64];
FILE* meminfo = fopen("/proc/meminfo", "r");

Expand Down Expand Up @@ -85,7 +85,7 @@ sysinf_err_t get_memory_capacity(unsigned int* mem_cap) {
return SI_ERR_COULD_NOT_READ;
}

*mem_cap = (unsigned int)atol(mem_capacity_str) * 1000;
*mem_cap = atol(mem_capacity_str) * 1000;
return SI_ERR_NONE;
}

2 changes: 1 addition & 1 deletion src/sysinf.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ sysinf_err_t get_root_size(unsigned long* size, unsigned long* usage);
///
/// @returns
/// sysinf_err_t
sysinf_err_t get_memory_capacity(unsigned int* mem_cap);
sysinf_err_t get_memory_capacity(long* mem_cap);

#endif // SYSINF_H

0 comments on commit fd595eb

Please sign in to comment.