diff options
| author | Rob Landley <rob@landley.net> | 2017-12-27 11:21:21 -0600 | 
|---|---|---|
| committer | Rob Landley <rob@landley.net> | 2017-12-27 11:21:21 -0600 | 
| commit | d46e3322d66efef848271becc36ffdf1b34afc87 (patch) | |
| tree | bf2c630199a0f1d05773b7382a8919fca986a9ca | |
| parent | 215a6af5f83e7866751f24fc61f709b444e61c1d (diff) | |
| download | toybox-d46e3322d66efef848271becc36ffdf1b34afc87.tar.gz | |
Minor cleanup on setfattr.c
| -rw-r--r-- | toys/pending/setfattr.c | 20 | 
1 files 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); +  }  } | 
