From f7d1014795fd0993c16ab44d45981b386d681424 Mon Sep 17 00:00:00 2001 From: Jinguang Dong Date: Thu, 1 Jun 2017 19:42:22 +0800 Subject: [PATCH] fs_mgr: Fix ZRAM error when ZRAM disk size beyond (2^31-1) bytes Because the zram_size type is unsigned int.so if ZRAM size great than 2^31 -1, zram_fp will receive a negtive integer, while the ZRAM driver only accept natural number.We need to use printf formatting %u instand of %d. Test: 1. Config the zramdisk size 2348810240 and build a ramdisk 2. Reflash device and check below command: $adb shell dumpsys meminfo $ adb shell cat /sys/block/zram0/disksize ZRAM info display will be abnormal 3. Config the zramdisk size 2348810240 and apply with this patch. 4. Retest to step 2 and the ZRAM info will be ok. Change-Id: I473de33fbd0b66cf13eac3172684e9fef11b6ef0 --- fs_mgr/fs_mgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp index 73bdc7a43..84981bfae 100644 --- a/fs_mgr/fs_mgr.cpp +++ b/fs_mgr/fs_mgr.cpp @@ -1195,7 +1195,7 @@ int fs_mgr_swapon_all(struct fstab *fstab) ret = -1; continue; } - fprintf(zram_fp, "%d\n", fstab->recs[i].zram_size); + fprintf(zram_fp, "%u\n", fstab->recs[i].zram_size); fclose(zram_fp); }