summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-01-15 12:32:36 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-01-15 12:42:11 +0100
commit1791dc06ea8458bb54e723a320b0ee87098ab498 (patch)
tree55083b3fa4ab5db1583bee3df556908095baa7d1
parentc48b19bbe127551ffb2b6d02b33ef78865341cfc (diff)
downloadunitd-1791dc06ea8458bb54e723a320b0ee87098ab498.tar
unitd-1791dc06ea8458bb54e723a320b0ee87098ab498.zip
system: increase memory field sizes to 64bit
On an Alix APU board with 4GB of available ram, the total memory is reported as "-179417088" bytes. Increase the ubus field sizes to 64bit integers in order to avoid overflows. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
-rw-r--r--system.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/system.c b/system.c
index cdb5434..77111f9 100644
--- a/system.c
+++ b/system.c
@@ -206,15 +206,15 @@ static int system_info(struct ubus_context *ctx, struct ubus_object *obj,
blobmsg_close_array(&b, c);
c = blobmsg_open_table(&b, "memory");
- blobmsg_add_u32(&b, "total", info.mem_unit * info.totalram);
- blobmsg_add_u32(&b, "free", info.mem_unit * info.freeram);
- blobmsg_add_u32(&b, "shared", info.mem_unit * info.sharedram);
- blobmsg_add_u32(&b, "buffered", info.mem_unit * info.bufferram);
+ blobmsg_add_u64(&b, "total", info.mem_unit * info.totalram);
+ blobmsg_add_u64(&b, "free", info.mem_unit * info.freeram);
+ blobmsg_add_u64(&b, "shared", info.mem_unit * info.sharedram);
+ blobmsg_add_u64(&b, "buffered", info.mem_unit * info.bufferram);
blobmsg_close_table(&b, c);
c = blobmsg_open_table(&b, "swap");
- blobmsg_add_u32(&b, "total", info.mem_unit * info.totalswap);
- blobmsg_add_u32(&b, "free", info.mem_unit * info.freeswap);
+ blobmsg_add_u64(&b, "total", info.mem_unit * info.totalswap);
+ blobmsg_add_u64(&b, "free", info.mem_unit * info.freeswap);
blobmsg_close_table(&b, c);
ubus_send_reply(ctx, req, b.head);