diff --git a/src/ls/ls.h b/src/ls/ls.h index d8a3df4..6ae17fe 100644 --- a/src/ls/ls.h +++ b/src/ls/ls.h @@ -13,11 +13,6 @@ #define MIN_ALLOCATED_ENTRY (1024) -enum { - EXIT_OK = 0, - EXIT_KO = 84 -}; - enum { F_ALL_FILES = 1 << 0, F_LONG_FORM = 1 << 1, diff --git a/src/ls/main.c b/src/ls/main.c index 66a8516..f1cc724 100644 --- a/src/ls/main.c +++ b/src/ls/main.c @@ -59,10 +59,10 @@ int main(int argc, char **argv) db.entries = malloc(db.size * sizeof(*db.entries)); if (db.entries == NULL) - return EXIT_KO; + return EXIT_FAILURE; if (flags & F_DIRECTORY) flags &= ~F_RECURSIVE; err |= list_dirs(&db, argc, argv, flags); free(db.entries); - return err ? EXIT_KO : EXIT_OK; + return err ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/src/ls/print_info.c b/src/ls/print_info.c index d85cccd..060ff5e 100644 --- a/src/ls/print_info.c +++ b/src/ls/print_info.c @@ -15,18 +15,19 @@ static void get_file_right(char bits[], entry_t *entry) { + char *bitsp = bits; mode_t mode = entry->stat.st_mode; static const char *s = "-rwx"; - bits[0] = s[(unsigned char)ZERO_OR(mode & S_IRUSR, 1)]; - bits[1] = s[(unsigned char)ZERO_OR(mode & S_IWUSR, 2)]; - bits[2] = s[(unsigned char)ZERO_OR(mode & S_IXUSR, 3)]; - bits[3] = s[(unsigned char)ZERO_OR(mode & S_IRGRP, 1)]; - bits[4] = s[(unsigned char)ZERO_OR(mode & S_IWGRP, 2)]; - bits[5] = s[(unsigned char)ZERO_OR(mode & S_IXGRP, 3)]; - bits[6] = s[(unsigned char)ZERO_OR(mode & S_IROTH, 1)]; - bits[7] = s[(unsigned char)ZERO_OR(mode & S_IWOTH, 2)]; - bits[8] = s[(unsigned char)ZERO_OR(mode & S_IXOTH, 3)]; + *bitsp++ = s[(unsigned char)ZERO_OR(mode & S_IRUSR, 1)]; + *bitsp++ = s[(unsigned char)ZERO_OR(mode & S_IWUSR, 2)]; + *bitsp++ = s[(unsigned char)ZERO_OR(mode & S_IXUSR, 3)]; + *bitsp++ = s[(unsigned char)ZERO_OR(mode & S_IRGRP, 1)]; + *bitsp++ = s[(unsigned char)ZERO_OR(mode & S_IWGRP, 2)]; + *bitsp++ = s[(unsigned char)ZERO_OR(mode & S_IXGRP, 3)]; + *bitsp++ = s[(unsigned char)ZERO_OR(mode & S_IROTH, 1)]; + *bitsp++ = s[(unsigned char)ZERO_OR(mode & S_IWOTH, 2)]; + *bitsp++ = s[(unsigned char)ZERO_OR(mode & S_IXOTH, 3)]; if (mode & S_ISUID) bits[1] = (mode & S_IXUSR) ? 's' : 'S'; if (mode & S_ISGID)