summaryrefslogtreecommitdiff
path: root/util-linux/setpriv.c
diff options
context:
space:
mode:
authorDenys Vlasenko2017-08-20 20:21:31 +0200
committerDenys Vlasenko2017-08-20 20:21:31 +0200
commitec2482e966c505d9076cf8581dabc4925c4c8bfe (patch)
tree1f6d7f1bded5446cbb5324fa5db28ff73efed437 /util-linux/setpriv.c
parent20c0d07e952ab764b6d8d46bfe30c30efcba005c (diff)
downloadbusybox-ec2482e966c505d9076cf8581dabc4925c4c8bfe.zip
busybox-ec2482e966c505d9076cf8581dabc4925c4c8bfe.tar.gz
setpriv: code shrink
function old new delta parse_cap 125 117 -8 setpriv_main 949 933 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-24) Total: -24 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/setpriv.c')
-rw-r--r--util-linux/setpriv.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c
index 76fb62c..c549bca 100644
--- a/util-linux/setpriv.c
+++ b/util-linux/setpriv.c
@@ -211,7 +211,7 @@ static void getcaps(struct caps *caps)
bb_simple_perror_msg_and_die("capget");
}
-static void parse_cap(unsigned long *index, const char *cap)
+static unsigned long parse_cap(const char *cap)
{
unsigned long i;
@@ -229,8 +229,7 @@ static void parse_cap(unsigned long *index, const char *cap)
if ((sscanf(cap, "cap_%lu", &i)) == 1) {
if (!cap_valid(i))
bb_error_msg_and_die("unsupported capability '%s'", cap);
- *index = i;
- return;
+ return i;
}
# if ENABLE_FEATURE_SETPRIV_CAPABILITY_NAMES
@@ -240,8 +239,7 @@ static void parse_cap(unsigned long *index, const char *cap)
if (!cap_valid(i))
bb_error_msg_and_die("unsupported capability '%s'", cap);
- *index = i;
- return;
+ return i;
}
# endif
@@ -258,7 +256,7 @@ static void set_inh_caps(char *capstring)
while (capstring) {
unsigned long cap;
- parse_cap(&cap, capstring);
+ cap = parse_cap(capstring);
if (CAP_TO_INDEX(cap) >= caps.u32s)
bb_error_msg_and_die("invalid capability cap");
@@ -284,7 +282,7 @@ static void set_ambient_caps(char *string)
while (cap) {
unsigned long index;
- parse_cap(&index, cap);
+ index = parse_cap(cap);
if (cap[0] == '+') {
if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, index, 0, 0) < 0)
bb_perror_msg("cap_ambient_raise");
@@ -421,8 +419,8 @@ int setpriv_main(int argc UNUSED_PARAM, char **argv)
int opts;
IF_FEATURE_SETPRIV_CAPABILITIES(char *inh_caps, *ambient_caps;)
- opts = getopt32long(argv,
- "+"IF_FEATURE_SETPRIV_DUMP("d")
+ opts = getopt32long(argv, "+"
+ IF_FEATURE_SETPRIV_DUMP("d")
IF_FEATURE_SETPRIV_CAPABILITIES("\xfe:\xfd:"),
setpriv_longopts
IF_FEATURE_SETPRIV_CAPABILITIES(, &inh_caps, &ambient_caps)