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