cc -Wextra

This commit is contained in:
Connor Lane Smith 2011-06-21 05:05:37 +01:00
parent 04162bd7b0
commit d7f9bda740
8 changed files with 22 additions and 19 deletions

View File

@ -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);

View File

@ -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

11
fold.c
View File

@ -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;

3
kill.c
View File

@ -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) {

8
nl.c
View File

@ -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;

8
sort.c
View File

@ -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;

View File

@ -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:");

View File

@ -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:");