[git commit] libpwdgrp: use a better estimate of max struct size
Denys Vlasenko
vda.linux at googlemail.com
Sat Jan 3 16:53:49 UTC 2015
commit: http://git.busybox.net/busybox/commit/?id=5e62a3d016633d4d97906f0f73298dc8e8b6a42b
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master
Previous code's trick with bitwise OR was giving this on 32-bit x86:
sizeof(struct passwd):28
sizeof(struct group):16
sizeof(struct spwd):36
sizeof(struct_result):60
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
libpwdgrp/pwd_grp.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c
index 539d2b0..f3fcec8 100644
--- a/libpwdgrp/pwd_grp.c
+++ b/libpwdgrp/pwd_grp.c
@@ -45,11 +45,10 @@ struct passdb {
uint8_t numfields;
FILE *fp;
char *malloced;
- char struct_result[0
- | sizeof(struct passwd)
- | sizeof(struct group)
- IF_USE_BB_SHADOW( | sizeof(struct spwd) )
- /* bitwise OR above is poor man's max(a,b,c) */
+ char struct_result[
+ /* Should be max(sizeof passwd,group,spwd), but this will do: */
+ IF_NOT_USE_BB_SHADOW(sizeof(struct passwd))
+ IF_USE_BB_SHADOW(sizeof(struct spwd))
];
};
More information about the busybox-cvs
mailing list