On Fri, Jan 15, 2021 at 03:00:11PM +0100, Vasilis Liaskovitis wrote: > sys-utils/ipcs.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) ... > + if (unit == IPC_UNIT_KB || unit == IPC_UNIT_DEFAULT) { > + ipc_print_size(IPC_UNIT_DEFAULT, > + _("max total shared memory (kbytes)"), (pgsz / 1024) * > + (uint64_t) lim.shmall, "\n", 0); I have small disadvantage in this code. There is still possible that (pgsz / 1024) * lim.shmall is greater than UINT64_MAX. It means, we still need to check it. I have added: tmp = (uint64_t) lim.shmall * (pgsz / 1024); if (lim.shmall != 0 && tmp / lim.shmall != pgsz / 1024) tmp = UINT64_MAX - (UINT64_MAX % (pgsz / 1024)); So, now we have separate overflow handling for "kbytes" and for "bytes". Karel > + } > + else { > + tmp = (uint64_t) lim.shmall * pgsz; > + /* overflow handling, at least we don't print > ridiculous small values */ > + if (lim.shmall != 0 && tmp / lim.shmall != > pgsz) { > + tmp = UINT64_MAX - (UINT64_MAX % pgsz); > + } > + ipc_print_size(unit, _("max total shared > memory"), tmp, "\n", 0); > } > - ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_KB : > unit, > - _("max total shared memory"), tmp, "\n", > 0); > ipc_print_size(unit == IPC_UNIT_DEFAULT ? > IPC_UNIT_BYTES : unit, > _("min seg size"), lim.shmmin, "\n", 0); > return; > -- > 2.28.0 > > -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com