From 2f0948b18d0d5652ba66534b6462dc085afc550d Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 16 Nov 2011 12:04:52 +0100 Subject: prlimit: replace lims[i] with pointer Signed-off-by: Karel Zak --- sys-utils/prlimit.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'sys-utils/prlimit.c') diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c index c60ba7b3d..ead8bd40e 100644 --- a/sys-utils/prlimit.c +++ b/sys-utils/prlimit.c @@ -319,22 +319,23 @@ static void do_prlimit(struct prlimit lims[], size_t n, int tt_flags) for (i = 0; i < n; i++) { struct rlimit *new = NULL; + struct prlimit *lim = &lims[i]; - if (lims[i].modify) { - if (lims[i].modify != (PRLIMIT_HARD | PRLIMIT_SOFT)) - get_unknown_hardsoft(&lims[i]); + if (lim->modify) { + if (lim->modify != (PRLIMIT_HARD | PRLIMIT_SOFT)) + get_unknown_hardsoft(lim); - if ((lims[i].rlim.rlim_cur > lims[i].rlim.rlim_max) && - (lims[i].rlim.rlim_cur != RLIM_INFINITY || - lims[i].rlim.rlim_max != RLIM_INFINITY)) + if ((lim->rlim.rlim_cur > lim->rlim.rlim_max) && + (lim->rlim.rlim_cur != RLIM_INFINITY || + lim->rlim.rlim_max != RLIM_INFINITY)) errx(EXIT_FAILURE, _("the soft limit %s cannot exceed the hard limit"), - lims[i].desc->name); - new = &lims[i].rlim; + lim->desc->name); + new = &lim->rlim; } else nshows++; if (verbose && new) { - printf(_("New %s limit: "), lims[i].desc->name); + printf(_("New %s limit: "), lim->desc->name); if (new->rlim_cur == RLIM_INFINITY) printf("<%s", _("unlimited")); else @@ -346,11 +347,11 @@ static void do_prlimit(struct prlimit lims[], size_t n, int tt_flags) printf(":%ju>\n", new->rlim_max); } - if (prlimit(pid, lims[i].desc->resource, new, &lims[i].rlim) == -1) - err(EXIT_FAILURE, lims[i].modify ? + if (prlimit(pid, lim->desc->resource, new, &lim->rlim) == -1) + err(EXIT_FAILURE, lim->modify ? _("failed to set the %s resource limit") : _("failed to get the %s resource limit"), - lims[i].desc->name); + lim->desc->name); } if (nshows) -- cgit v1.2.3-55-g7522