system: increase memory field sizes to 64bit
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 15 Jan 2015 11:32:36 +0000 (12:32 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 15 Jan 2015 11:42:11 +0000 (12:42 +0100)
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>
system.c

index cdb54343885ee53c2521bea1882b6e4e72b90e85..77111f90cacac7f8d3b0e9a7bb147b7e0117493d 100644 (file)
--- 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);