Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup / warnings: #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 63 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,71 @@
CFLAGS?=-O2 -g -Wall -W $(shell pkg-config --cflags librtlsdr)
LDLIBS+=$(shell pkg-config --libs librtlsdr) -lpthread -lm
CC?=gcc
# warn about (roughly):
# * deviations from standard
# * global functions that are not exported
# * empty argument list in declarations
COM_WARNS= -Wall \
-Wextra \
-Wpedantic \
-Wmissing-declarations \
-Wdouble-promotion \
-Wnull-dereference \
-Wmissing-include-dirs \
-Wswitch-default \
-Wunused-parameter \
-Wuninitialized \
-Wshadow \
-Wbad-function-cast \
-Wcast-qual \
-Wcast-align \
-Wwrite-strings \
-Wstrict-prototypes \
-Wredundant-decls \
-Wnested-externs \
-Wincompatible-pointer-types
# TODO: These require some work.
# -Wconversion \
# -Wfloat-equal
GCC_WARNS= -Wchkp \
-Walloc-zero \
-Wduplicated-branches \
-Wduplicated-cond \
-Wc99-c11-compat \
-Wjump-misses-init \
-Wlogical-op \
-Wrestrict
CLANG_WARNS=


COM_OFLGS= -fstrict-aliasing \
-fstack-protector
GCC_OFLGS= -fdelete-null-pointer-checks \
-ftree-vrp \
-funsafe-loop-optimizations \
-flto-odr-type-merging
CLANG_OFLGS=


CC ?= gcc
CID=$(shell $(CC) -v 2>&1 | grep "version" | cut -d' ' -f1)

CFLAGS ?= -std=gnu99 -O2 -g
CFLAGS += $(COM_WARNS) $(COM_OFLGS)
ifeq "$(CID)" "gcc"
CFLAGS += $(GCC_WARNS) $(GCC_OFLGS)
else
CFLAGS += $(CLANG_WARNS) $(CLANG_OFLGS)
endif

CFLAGS += $(shell pkg-config --cflags librtlsdr)
LDLIBS += $(shell pkg-config --libs librtlsdr) -lpthread -lm
PROGNAME=dump1090

all: dump1090
all: $(PROGNAME)

%.o: %.c
$(CC) $(CFLAGS) -c $<

dump1090: dump1090.o anet.o
$(CC) -g -o dump1090 dump1090.o anet.o $(LDFLAGS) $(LDLIBS)
$(PROGNAME): dump1090.o anet.o
$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)

clean:
rm -f *.o dump1090
@$(RM) -v *.o $(PROGNAME)
4 changes: 2 additions & 2 deletions anet.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ int anetTcpNonBlockConnect(char *err, char *addr, int port)
return anetTcpGenericConnect(err,addr,port,ANET_CONNECT_NONBLOCK);
}

int anetUnixGenericConnect(char *err, char *path, int flags)
static int anetUnixGenericConnect(char *err, char *path, int flags)
{
int s;
struct sockaddr_un sa;
Expand Down Expand Up @@ -366,7 +366,7 @@ int anetPeerToString(int fd, char *ip, int *port) {
return 0;
}

int anetSockName(int fd, char *ip, int *port) {
static int __attribute__((__unused__)) anetSockName(int fd, char *ip, int *port) {
struct sockaddr_in sa;
socklen_t salen = sizeof(sa);

Expand Down
Loading