sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit d7f9bda740158ff87340798b06ebf412b90ceda1
parent 04162bd7b044c4c88ad92add61599bafc0d1ece4
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Tue, 21 Jun 2011 05:05:37 +0100

cc -Wextra
Diffstat:
Mchown.c | 3++-
Mconfig.mk | 2+-
Mfold.c | 11++++++-----
Mkill.c | 3++-
Mnl.c | 8++++----
Msort.c | 8++++----
Mutil/agetcwd.c | 4++--
Mutil/enmasse.c | 2+-
8 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/chown.c b/chown.c @@ -58,7 +58,8 @@ main(int argc, char *argv[]) void chownpwgr(const char *path) { - if(chown(path, pw ? pw->pw_uid : -1, gr ? gr->gr_gid : -1) == -1) + if(chown(path, pw ? pw->pw_uid : (uid_t)-1, + gr ? gr->gr_gid : (gid_t)-1) == -1) eprintf("chown %s:", path); if(rflag) recurse(path, chownpwgr); diff --git a/config.mk b/config.mk @@ -9,7 +9,7 @@ MANPREFIX = $(PREFIX)/share/man #CC = musl-gcc LD = $(CC) CPPFLAGS = -D_POSIX_C_SOURCE=200112L -CFLAGS = -Os -ansi -Wall -pedantic $(CPPFLAGS) +CFLAGS = -Os -ansi -Wall -Wextra -pedantic $(CPPFLAGS) LDFLAGS = -static #-s #CC = tcc diff --git a/fold.c b/fold.c @@ -7,7 +7,7 @@ #include "text.h" #include "util.h" -static void fold(FILE *, const char *, long); +static void fold(FILE *, long); static void foldline(const char *, long); static bool bflag = false; @@ -35,18 +35,18 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } if(optind == argc) - fold(stdin, "<stdin>", width); + fold(stdin, width); else for(; optind < argc; optind++) { if(!(fp = fopen(argv[optind], "r"))) eprintf("fopen %s:", argv[optind]); - fold(fp, argv[optind], width); + fold(fp, width); fclose(fp); } return EXIT_SUCCESS; } void -fold(FILE *fp, const char *str, long width) +fold(FILE *fp, long width) { char *buf = NULL; size_t size = 0; @@ -60,7 +60,8 @@ void foldline(const char *str, long width) { bool space; - long col, j, i = 0, n = 0; + long col, j; + size_t i = 0, n = 0; do { space = false; diff --git a/kill.c b/kill.c @@ -26,8 +26,9 @@ main(int argc, char *argv[]) { bool lflag = false; char c, *end; - int i, sig = SIGTERM; + int sig = SIGTERM; pid_t pid; + size_t i; while((c = getopt(argc, argv, "ls:")) != -1) switch(c) { diff --git a/nl.c b/nl.c @@ -7,7 +7,7 @@ #include "text.h" #include "util.h" -static void nl(FILE *, const char *); +static void nl(FILE *); static char mode = 't'; static const char *sep = "\t"; @@ -39,18 +39,18 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } if(optind == argc) - nl(stdin, "<stdin>"); + nl(stdin); else for(; optind < argc; optind++) { if(!(fp = fopen(argv[optind], "r"))) eprintf("fopen %s:", argv[optind]); - nl(fp, argv[optind]); + nl(fp); fclose(fp); } return EXIT_SUCCESS; } void -nl(FILE *fp, const char *str) +nl(FILE *fp) { char *buf = NULL; long n = 0; diff --git a/sort.c b/sort.c @@ -8,7 +8,7 @@ #include "util.h" static int linecmp(const char **, const char **); -static void getlines(FILE *, const char *); +static void getlines(FILE *); static bool rflag = false; static bool uflag = false; @@ -34,11 +34,11 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } if(optind == argc) - getlines(stdin, "<stdin>"); + getlines(stdin); else for(; optind < argc; optind++) { if(!(fp = fopen(argv[optind], "r"))) eprintf("fopen %s:", argv[optind]); - getlines(fp, argv[optind]); + getlines(fp); fclose(fp); } qsort(lines, nlines, sizeof *lines, (int (*)(const void *, const void *))linecmp); @@ -50,7 +50,7 @@ main(int argc, char *argv[]) } void -getlines(FILE *fp, const char *str) +getlines(FILE *fp) { char *line = NULL; size_t size = 0; diff --git a/util/agetcwd.c b/util/agetcwd.c @@ -8,9 +8,9 @@ char * agetcwd(void) { char *buf; - size_t size; + long size; - if((size = pathconf(".", _PC_PATH_MAX)) < 0) + if((size = pathconf(".", _PC_PATH_MAX)) == -1) size = BUFSIZ; if(!(buf = malloc(size))) eprintf("malloc:"); diff --git a/util/enmasse.c b/util/enmasse.c @@ -25,7 +25,7 @@ enmasse(int argc, char **argv, int (*fn)(const char *, const char *)) else dir = argv[--argc]; - if((size = pathconf(dir, _PC_PATH_MAX)) < 0) + if((size = pathconf(dir, _PC_PATH_MAX)) == -1) size = BUFSIZ; if(!(buf = malloc(size))) eprintf("malloc:");