Compile with Werror flag. Found bug in xargs

This commit is contained in:
Your Name 2023-12-10 11:24:18 +03:00
parent abdb5a8f03
commit d5fddf4dcf
8 changed files with 13 additions and 8 deletions

4
TODO
View File

@ -1,7 +1,6 @@
With "micro-" prefix
*Todo:
*echo
tail
expr
uniq
@ -54,7 +53,7 @@ Modutils (linux only):
Findutils:
grep
find
*xargs (-r flag)
Shell:
rc - run command (1 2 3 ~ | <> <<>> & * " parsing) (sig handler)
@ -63,3 +62,4 @@ Init:
BUGS:
ls (unicode strlen, -l flag col)
xargs (getopt with glibc)

View File

@ -31,6 +31,8 @@
/* Max args (xargs) */
#define NARGS 1024
/* Arg size (xargs) */
#define ARG_SIZE 1024
/* Default cmd (xargs) */

View File

@ -19,7 +19,10 @@ int cat(const char *path) {
char buf[BUF_SIZE + 1];
off_t len = 0;
while ((len = read(fd, buf, sizeof(buf))) > 0)
write(STDOUT_FILENO, buf, len);
if (write(STDOUT_FILENO, buf, len) != len) {
fprintf(stderr, "cat: %s\n", strerror(errno));
return 1;
}
if (strcmp(path, "-"))
close(fd);

View File

@ -15,7 +15,7 @@ int main(const int argc, char **argv) {
return 1;
}
chdir("/");
(void)chdir("/");
if (execvp(argv[2], argv + 2) < 0) {
fprintf(stderr, "chroot: %s\n", strerror(errno));
return 1;

View File

@ -26,7 +26,7 @@ int shred(int rand_fd, int fd) {
}
for (unsigned int n = 0; n < n_loops; n++) {
read(rand_fd, buf, size);
(void)read(rand_fd, buf, size);
fsync(fd);
}

View File

@ -42,10 +42,10 @@ int main(int argc, char **argv) {
char buf[BUF_SIZE + 1];
off_t bytes = 0;
while ((bytes = read(STDIN_FILENO, buf, sizeof(buf)))) {
write(STDOUT_FILENO, buf, bytes);
(void)write(STDOUT_FILENO, buf, bytes);
if (argc > 0)
write(fd, buf, bytes);
(void)write(fd, buf, bytes);
}
if (argc > 0)

View File

@ -57,7 +57,7 @@ int main(int argc, char **argv) {
/* Print */
write(STDOUT_FILENO, buf, n);
(void)write(STDOUT_FILENO, buf, n);
putchar('\n');
free(buf);