From d46e3322d66efef848271becc36ffdf1b34afc87 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 27 Dec 2017 11:21:21 -0600 Subject: Minor cleanup on setfattr.c --- toys/pending/setfattr.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/toys/pending/setfattr.c b/toys/pending/setfattr.c index 7e8bae24..efec9a53 100644 --- a/toys/pending/setfattr.c +++ b/toys/pending/setfattr.c @@ -27,21 +27,15 @@ GLOBALS( char *x, *v, *n; ) -static void do_setfattr(char *file) -{ - int h = toys.optflags & FLAG_h; - - if (toys.optflags&FLAG_x) { - if ((h ? lremovexattr : removexattr)(file, TT.x)) - perror_msg("removexattr failed"); - } else - if ((h ? lsetxattr : setxattr)(file, TT.n, TT.v, TT.v?strlen(TT.v):0, 0)) - perror_msg("setxattr failed"); -} - void setfattr_main(void) { + int h = toys.optflags & FLAG_h, rc; char **s; - for (s=toys.optargs; *s; s++) do_setfattr(*s); + for (s=toys.optargs; *s; s++) { + if (TT.x) rc = (h?lremovexattr:removexattr)(*s, TT.x); + else rc = (h?lsetxattr:setxattr)(*s, TT.n, TT.v, TT.v?strlen(TT.v):0, 0); + + if (rc) perror_msg("%s", *s); + } } -- cgit v1.2.3