libbb: more compact API for bb_parse_mode()
[oweals/busybox.git] / coreutils / chmod.c
index 5ee45b94206fa9ad5a6451090234900d078ba44f..a21c6d501871e9d1ddfb44a7580f38fc3f6d6d45 100644 (file)
@@ -69,9 +69,9 @@ static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void
                if (S_ISLNK(statbuf->st_mode))
                        return TRUE;
        }
-       newmode = statbuf->st_mode;
 
-       if (!bb_parse_mode((char *)param, &newmode))
+       newmode = bb_parse_mode((char *)param, statbuf->st_mode);
+       if (newmode == (mode_t)-1)
                bb_error_msg_and_die("invalid mode '%s'", (char *)param);
 
        if (chmod(fileName, newmode) == 0) {