~rcr/rirc

d30a3f0cce8366dcacad8e8924d9ad5f1007a2af — Richard Robbins 10 months ago e4febc1 + ae6c5dd
Merge branch 'dev' into static_analysis
M Makefile => Makefile +13 -13
@@ 46,24 46,24 @@ OBJS_T += $(DIR_B)/utils/tree.t # Header only file
OBJS_G := $(patsubst %.gperf, %.gperf.out, $(SRC_G))

# Release build executable
$(BIN_R): $(TLS_LIBS) $(OBJS_G) $(OBJS_R)
	@echo cc $@
$(BIN_R): libs $(OBJS_G) $(OBJS_R)
	@echo " CC  $@"
	@$(CC) $(LDFLAGS) -o $@ $(OBJS_R) $(TLS_LIBS)

# Debug build executable
$(BIN_D): $(TLS_LIBS) $(OBJS_G) $(OBJS_D)
	@echo cc $@
$(BIN_D): libs $(OBJS_G) $(OBJS_D)
	@echo " CC  $@"
	@$(CC) $(LDFLAGS) -o $@ $(OBJS_D) $(TLS_LIBS)

# Release build objects
$(DIR_B)/%.o: $(DIR_S)/%.c config.h | $(DIR_B)
	@echo "cc $<..."
	@echo " CC  $<"
	@$(PP) $(CFLAGS_R) -MM -MP -MT $@ -MF $(@:.o=.o.d) $<
	@$(CC) $(CFLAGS_R) -c -o $@ $<

# Debug build objects
$(DIR_B)/%.db.o: $(DIR_S)/%.c config.h | $(DIR_B)
	@echo "cc $<..."
	@echo " CC  $<"
	@$(PP) $(CFLAGS_D) -MM -MP -MT $@ -MF $(@:.o=.o.d) $<
	@$(CC) $(CFLAGS_D) -c -o $@ $<



@@ 74,11 74,9 @@ $(DIR_B)/%.t: $(DIR_T)/%.c $(OBJS_G) | $(DIR_B)
	@$(CC) $(CFLAGS_D) -o $@ $(@:.t=.t.o)
	@$(TEST_EXT) ./$@

# Default config file
config.h:
	cp config.def.h config.h

# Gperf generated source
%.gperf.out: %.gperf
	gperf --output-file=$@ $<



@@ 91,8 89,7 @@ $(TLS_LIBS): $(TLS_CONF)
	@CFLAGS="$(TLS_INCL)" $(MAKE) --silent -C ./lib/mbedtls clean
	@CFLAGS="$(TLS_INCL)" $(MAKE) --silent -C ./lib/mbedtls lib

all:
	@$(MAKE) --silent $(TLS_LIBS)
all: libs
	@$(MAKE) --silent $(BIN_R)
	@$(MAKE) --silent $(BIN_D)



@@ 100,8 97,11 @@ check:
	@$(MAKE) --silent $(OBJS_T)

clean:
	rm -rf $(DIR_B) $(BIN_R) $(BIN_D)
	@find . -name "*gperf.out" -print0 | xargs -0 -I % rm -rfv %
	@rm -rf $(DIR_B)
	@rm -vf $(BIN_R) $(BIN_D) $(OBJS_G)

libs:
	@$(MAKE) --silent $(TLS_LIBS)

install: $(BIN_R)
	@echo installing executable to $(BIN_DIR)


@@ 120,6 120,6 @@ uninstall:
-include $(OBJS_D:.o=.o.d)
-include $(OBJS_T:.t=.t.d)

.PHONY: all check clean install uninstall
.PHONY: all check clean libs install uninstall

.PRECIOUS: $(OBJS_T)

M scripts/sa_coverity_get.sh => scripts/sa_coverity_get.sh +8 -4
@@ 12,14 12,18 @@ if [[ -z "${COVERITY_TOKEN}" ]]; then
	fail "missing env COVERITY_TOKEN"
fi

COVERITY_MD5="$1/coverity_tool.md5"
COVERITY_TGZ="$1/coverity_tool.tgz"
DIR="$1"

mkdir "$1"
COVERITY_MD5="$DIR/coverity_tool.md5"
COVERITY_TGZ="$DIR/coverity_tool.tgz"

mkdir -p "$DIR"

echo "*" > "$DIR/.gitignore"

curl -fs --show-error https://scan.coverity.com/download/linux64 -o "$COVERITY_MD5" --data "token=$COVERITY_TOKEN&project=rcr%2Frirc&md5=1"
curl -fs --show-error https://scan.coverity.com/download/linux64 -o "$COVERITY_TGZ" --data "token=$COVERITY_TOKEN&project=rcr%2Frirc"

printf "%s\t$COVERITY_TGZ" "$(cat "$COVERITY_MD5")" | md5sum --quiet -c -

tar xzf "$COVERITY_TGZ" -C "$1" --strip-components 1
tar xzf "$COVERITY_TGZ" -C "$DIR" --strip-components 1

M scripts/sa_coverity_run.sh => scripts/sa_coverity_run.sh +14 -7
@@ 16,18 16,25 @@ if [[ -z "${COVERITY_TOKEN}" ]]; then
	fail "missing env COVERITY_TOKEN"
fi

COVERITY_OUT="cov-int"
COVERITY_TAR="cov-int.tgz"
DIR="$1"

COVERITY_OUT="$DIR/cov-int"
COVERITY_TAR="$DIR/cov-int.tgz"

VERSION=$(git rev-parse --short HEAD)

PATH=$(pwd)/$1/bin:$PATH cov-build --dir "$COVERITY_OUT" make clean all check
export PATH="$PWD/$DIR/bin:$PATH"

make clean
make libs

cov-build --dir "$COVERITY_OUT" make all check

tar czf "$COVERITY_TAR" "$COVERITY_OUT"

curl \
	--form file=@"$COVERITY_TAR" \
curl https://scan.coverity.com/builds?project=rcr%2Frirc \
	--form description="$VERSION" \
	--form email="$COVERITY_EMAIL" \
	--form file=@"$COVERITY_TAR" \
	--form token="$COVERITY_TOKEN" \
	--form version="$VERSION" \
	https://scan.coverity.com/builds?project=rcr%2Frirc
	--form version="$VERSION"

M scripts/sa_sonarcloud_get.sh => scripts/sa_sonarcloud_get.sh +3 -1
@@ 18,7 18,9 @@ BUILD_ZIP_URL="https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip"
SONAR_ZIP_URL="https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_VER-linux.zip"
SONAR_MD5_URL="https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_VER-linux.zip.md5"

mkdir "$1"
mkdir -p "$1"

echo "*" > "$1/.gitignore"

curl -fs --show-error "$BUILD_ZIP_URL" -o "$BUILD_ZIP"
curl -fs --show-error "$SONAR_ZIP_URL" -o "$SONAR_ZIP"

M scripts/sa_sonarcloud_run.sh => scripts/sa_sonarcloud_run.sh +15 -25
@@ 1,8 1,5 @@
#!/bin/bash

# FIXME: undo the long live branch pattern in 
# https://sonarcloud.io/project/branches?id=rirc

set -e

fail() { >&2 printf "%s\n" "$*"; exit 1; }


@@ 11,14 8,14 @@ if [[ -z $1 ]]; then
	fail "Usage: '$0 dir'"
fi

SONAR_VER="4.5.0.2216"

BUILD_WRAPPER_BIN="$1/build-wrapper-linux-x86/build-wrapper-linux-x86-64"
SONAR_SCANNER_BIN="$1/sonar-scanner-$SONAR_VER-linux/bin/sonar-scanner"
DIR="$1"

BUILD_WRAPPER_OUT="$1/bw-out"
SONAR_VERSION="4.5.0.2216"
SONAR_CONFIG="$DIR/sonar-project.properties"

SONAR_SCANNER_CONF="sonar-project.properties"
SONAR_SCANNER_BIN="$DIR/sonar-scanner-$SONAR_VERSION-linux/bin/sonar-scanner"
BUILD_WRAPPER_BIN="$DIR/build-wrapper-linux-x86/build-wrapper-linux-x86-64"
BUILD_WRAPPER_OUT="$DIR/bw-out"

if [[ ! -f "$BUILD_WRAPPER_BIN" ]]; then
	fail "missing build-wrapper binary"


@@ 28,14 25,7 @@ if [[ ! -f "$SONAR_SCANNER_BIN" ]]; then
	fail "missing sonar-scanner binary"
fi

# FIXME:
# "the branch or pull request parameter is missing"

# FIXME: just forget about coverage until it works properly with llvm or something
#        ive wasted enough time on this...
#        add test coverage to README or something? or use something else like coveralls?

cat << EOF >> "$SONAR_SCANNER_CONF"
cat << EOF >> "$SONAR_CONFIG"
# Server
sonar.host.url = https://sonarcloud.io



@@ 44,23 34,23 @@ sonar.organization   = rirc
sonar.projectKey     = rirc
sonar.projectName    = rirc
sonar.projectVersion = $(git rev-parse --short HEAD)
sonar.branch.name    = $(git rev-parse --symbolic-full-name HEAD)
sonar.branch.name    = $(git name-rev --name-only HEAD)
sonar.links.homepage = https://rcr.io/rirc/
sonar.links.scm      = https://git.sr.ht/~rcr/rirc/
sonar.links.ci       = https://builds.sr.ht/~rcr/rirc/

# Source
sonar.sources = src,test

# C
# C, Sources
sonar.cfamily.build-wrapper-output = $BUILD_WRAPPER_OUT
sonar.cfamily.cache.enabled        = false
sonar.cfamily.threads              = $(nproc)
sonar.sources                      = src,test

# Output
sonar.working.directory = $DIR/scannerwork
EOF

make clean
make libs

eval "$BUILD_WRAPPER_BIN --out-dir $BUILD_WRAPPER_OUT make all check"
eval "$SONAR_SCANNER_BIN"

rm -f "$SONAR_SCANNER_CONF"
eval "$SONAR_SCANNER_BIN --define project.settings=$SONAR_CONFIG"

M src/state.c => src/state.c +7 -3
@@ 354,6 354,7 @@ state_channel_close(int action_confirm)
{
	/* Close the current channel */

	int ret;
	struct channel *c = current_channel();
	struct server *s = c->server;



@@ 376,8 377,10 @@ state_channel_close(int action_confirm)

	if (c->type == CHANNEL_T_CHANNEL || c->type == CHANNEL_T_PRIVATE) {

		if (s->connected && c->type == CHANNEL_T_CHANNEL && !c->parted)
			io_sendf(s->connection, "PART %s :%s", c->name, DEFAULT_PART_MESG);
		if (s->connected && c->type == CHANNEL_T_CHANNEL && !c->parted) {
			if ((ret = io_sendf(s->connection, "PART %s :%s", c->name, DEFAULT_PART_MESG)))
				newlinef(s->channel, 0, "-!!-", "sendf fail: %s", io_err(ret));
		}

		channel_set_current(c->next);
		channel_list_del(&(s->clist), c);


@@ 388,7 391,8 @@ state_channel_close(int action_confirm)
	if (c->type == CHANNEL_T_SERVER) {

		if (s->connected) {
			io_sendf(s->connection, "QUIT :%s", DEFAULT_QUIT_MESG);
			if ((ret = io_sendf(s->connection, "QUIT :%s", DEFAULT_QUIT_MESG)))
				newlinef(s->channel, 0, "-!!-", "sendf fail: %s", io_err(ret));
			io_dx(s->connection);
		}