Skip to content

Commit

Permalink
Merge pull request #73 from ggtakec/update_etc
Browse files Browse the repository at this point in the history
Changed support OS and Fixed about cppcheck, etc
  • Loading branch information
ggtakec authored Mar 12, 2024
2 parents 1b43bb3 + ab10e8b commit 65df79e
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 31 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,26 @@ jobs:
- rockylinux:9
- rockylinux:8
- centos:centos7
- fedora:39
- fedora:38
- fedora:37
- alpine:3.19
- alpine:3.18

container:
image: ${{ matrix.container }}

steps:
# [NOTE]
# actions/checkout@v3 uses nodejs v16 and will be deprecated.
# However, @v4 does not work on centos7 depending on the glibc version,
# so we will continue to use @v3.
#
# Checks-out your repository under $GITHUB_WORKSPACE, so your
# job can access it
#
- name: Checkout sources
- name: Checkout source code(other than centos7)
if: matrix.container != 'centos:centos7'
uses: actions/checkout@v4

- name: Checkout source code(only centos7)
if: matrix.container == 'centos:centos7'
uses: actions/checkout@v3

#
Expand Down Expand Up @@ -153,18 +160,18 @@ jobs:
# <default tag flag>: If you want to use the created Docker image as the default image, specify "default".
#
imageinfo:
- alpine:3.18,alpine:3.18,alpine,default
- alpine:3.19,alpine:3.19,alpine,default
- ubuntu:22.04,ubuntu:22.04,ubuntu

#
# Run building and pushing helper
#
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

#
# Login to avoid the Docker Hub rate limit
Expand All @@ -178,7 +185,7 @@ jobs:
#
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESSTOKEN }}
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/ostypevars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ elif [ "${CI_OSTYPE}" = "centos:7" ] || [ "${CI_OSTYPE}" = "centos:centos7" ]; t
PKG_EXT="rpm"
IS_OS_CENTOS=1

elif [ "${CI_OSTYPE}" = "fedora:38" ]; then
DIST_TAG="fedora/38"
elif [ "${CI_OSTYPE}" = "fedora:39" ]; then
DIST_TAG="fedora/39"
INSTALL_PKG_LIST="git autoconf automake gcc gcc-c++ gdb make libtool pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps libyaml-devel chmpx-devel nss-devel"
INSTALLER_BIN="dnf"
UPDATE_CMD="update"
Expand All @@ -242,8 +242,8 @@ elif [ "${CI_OSTYPE}" = "fedora:38" ]; then
PKG_EXT="rpm"
IS_OS_FEDORA=1

elif [ "${CI_OSTYPE}" = "fedora:37" ]; then
DIST_TAG="fedora/37"
elif [ "${CI_OSTYPE}" = "fedora:38" ]; then
DIST_TAG="fedora/38"
INSTALL_PKG_LIST="git autoconf automake gcc gcc-c++ gdb make libtool pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps libyaml-devel chmpx-devel nss-devel"
INSTALLER_BIN="dnf"
UPDATE_CMD="update"
Expand All @@ -256,6 +256,20 @@ elif [ "${CI_OSTYPE}" = "fedora:37" ]; then
PKG_EXT="rpm"
IS_OS_FEDORA=1

elif [ "${CI_OSTYPE}" = "alpine:3.19" ]; then
DIST_TAG="alpine/v3.19"
INSTALL_PKG_LIST="bash sudo alpine-sdk automake autoconf libtool groff util-linux-misc musl-locales ruby-dev procps yaml-dev chmpx-dev openssl-dev"
INSTALLER_BIN="apk"
UPDATE_CMD="update"
UPDATE_CMD_ARG="--no-progress"
INSTALL_CMD="add"
INSTALL_CMD_ARG="--no-progress --no-cache"
INSTALL_AUTO_ARG=""
INSTALL_QUIET_ARG="-q"
PKG_OUTPUT_DIR="apk_build"
PKG_EXT="apk"
IS_OS_ALPINE=1

elif [ "${CI_OSTYPE}" = "alpine:3.18" ]; then
DIST_TAG="alpine/v3.18"
INSTALL_PKG_LIST="bash sudo alpine-sdk automake autoconf libtool groff util-linux-misc musl-locales ruby-dev procps yaml-dev chmpx-dev openssl-dev"
Expand Down
36 changes: 28 additions & 8 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ EXTRA_DIST=RELEASE_VERSION @CONFIGURECUSTOM@
# Versions of cppcheck below 1.8 perform poorly and the test is
# skipped if those versions are installed.
#
CPPCHECK_NG_VERSION = -e \^0\\. -e \^1\\.[0-7]
CPPCHECK_NG_VER = -e \^0\\. -e \^1\\.[0-7]
CPPCHECK_CMD = cppcheck
CPPCHECK_TARGET = $(SUBDIRS)
CPPCHECK_BUILD_DIR = /tmp/cppcheck
Expand All @@ -39,19 +39,38 @@ CPPCHECK_BASE_OPT = --quiet \
--xml
CPPCHECK_ENABLE_OPT = --enable=warning,style,information,missingInclude
CPPCHECK_IGNORE_OPT = --suppress=unmatchedSuppression
CPPCHECK_INCDIR_OPT = -I . -I lib
CPPCHECK_DEFINE_OPT =

# [NOTE] Switch options
# The options available vary depending on the version.
# There are cases where you use options that do not exist in older
# versions.
#
CPPCHECK_GT207_VER = 2007
CPPCHECK_GT207_ADD_OPT = --suppress=ctuOneDefinitionRuleViolation
CPPCHECK_GE211_VER = 2011
CPPCHECK_GE211_ADD_OPT = --check-level=exhaustive \
--suppress=missingIncludeSystem

cppcheck:
@if command -v $(CPPCHECK_CMD) >/dev/null 2>&1; then \
if ($(CPPCHECK_CMD) --version | sed -e 's|Cppcheck[[:space:]]*||gi' | grep -q $(CPPCHECK_NG_VERSION)); then \
@set -e; \
if command -v $(CPPCHECK_CMD) >/dev/null 2>&1; then \
if ($(CPPCHECK_CMD) --version | sed -e 's|Cppcheck[[:space:]]*||gi' | grep -q $(CPPCHECK_NG_VER)); then \
echo "*** [INFO] cppcheck version below 1.8, so skip to run cppcheck."; \
else \
echo "*** Check all files with CppCheck"; \
if [ -d $(CPPCHECK_BUILD_DIR) ]; then \
rm -rf $(CPPCHECK_BUILD_DIR); \
fi; \
mkdir -p $(CPPCHECK_BUILD_DIR); \
$(CPPCHECK_CMD) $(CPPCHECK_BASE_OPT) $(CPPCHECK_DEFINE_OPT) $(CPPCHECK_ENABLE_OPT) $(CPPCHECK_IGNORE_OPT) --cppcheck-build-dir=$(CPPCHECK_BUILD_DIR) $(CPPCHECK_TARGET); \
if test `$(CPPCHECK_CMD) --version | sed -e 's/\./ /g' | awk '{print ($$2 * 1000 + $$3)}'` -le $(CPPCHECK_GT207_VER); then \
$(CPPCHECK_CMD) $(CPPCHECK_BASE_OPT) $(CPPCHECK_DEFINE_OPT) $(CPPCHECK_INCDIR_OPT) $(CPPCHECK_ENABLE_OPT) $(CPPCHECK_IGNORE_OPT) --cppcheck-build-dir=$(CPPCHECK_BUILD_DIR) $(CPPCHECK_TARGET); \
elif test `$(CPPCHECK_CMD) --version | sed -e 's/\./ /g' | awk '{print ($$2 * 1000 + $$3)}'` -lt $(CPPCHECK_GE211_VER); then \
$(CPPCHECK_CMD) $(CPPCHECK_BASE_OPT) $(CPPCHECK_DEFINE_OPT) $(CPPCHECK_INCDIR_OPT) $(CPPCHECK_ENABLE_OPT) $(CPPCHECK_IGNORE_OPT) $(CPPCHECK_GT207_ADD_OPT) --cppcheck-build-dir=$(CPPCHECK_BUILD_DIR) $(CPPCHECK_TARGET); \
else \
$(CPPCHECK_CMD) $(CPPCHECK_BASE_OPT) $(CPPCHECK_DEFINE_OPT) $(CPPCHECK_INCDIR_OPT) $(CPPCHECK_ENABLE_OPT) $(CPPCHECK_IGNORE_OPT) $(CPPCHECK_GT207_ADD_OPT) $(CPPCHECK_GE211_ADD_OPT) --cppcheck-build-dir=$(CPPCHECK_BUILD_DIR) $(CPPCHECK_TARGET); \
fi; \
rm -rf $(CPPCHECK_BUILD_DIR); \
fi; \
else \
Expand All @@ -75,16 +94,17 @@ SHELLCHECK_FILES_SH = `grep -ril '^\#!/bin/sh' . | grep '\.sh' | grep -v '\
SHELLCHECK_FILES_INCLUDE_SH = `grep -Lir '^\#!/bin/sh' . | grep '\.sh' | grep -v '\.log' | grep -v '/\.git/' | grep -v '/rpmbuild/' | grep -v '/debian_build/' | grep -v '/autom4te.cache/' | grep -v '/m4/' | grep -v '/install-sh' | grep -v '/ltmain.sh' | tr '\n' ' '`

shellcheck:
@if type shellcheck > /dev/null 2>&1; then \
@set -e; \
if type shellcheck > /dev/null 2>&1; then \
echo "*** Check all files with ShellCheck"; \
if [ -n "$(SHELLCHECK_FILES_NO_SH)" ]; then \
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_IGN_OPT) $(SHELLCHECK_FILES_NO_SH) || exit 1; \
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_IGN_OPT) $(SHELLCHECK_FILES_NO_SH); \
fi; \
if [ -n "$(SHELLCHECK_FILES_SH)" ]; then \
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_IGN_OPT) $(SHELLCHECK_FILES_SH) || exit 1; \
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_IGN_OPT) $(SHELLCHECK_FILES_SH); \
fi; \
if [ -n "$(SHELLCHECK_FILES_INCLUDE_SH)" ]; then \
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_INCLUDE_IGN_OPT) $(SHELLCHECK_FILES_INCLUDE_SH) || exit 1; \
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_INCLUDE_IGN_OPT) $(SHELLCHECK_FILES_INCLUDE_SH); \
fi; \
echo " -> No error was detected."; \
echo ""; \
Expand Down
4 changes: 2 additions & 2 deletions buildutils/control.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: @PACKAGE_NAME@
Section: libs
Priority: optional
Maintainer: @DEV_NAME@ <@DEV_EMAIL@>
Build-Depends: @DEBHELPER_DEP@, k2hash-dev (>= 1.0.92), libfullock-dev (>= 1.0.57), chmpx-dev (>= 1.0.104), libyaml-dev, gnutls-dev
Build-Depends: @DEBHELPER_DEP@, k2hash-dev (>= 1.0.93), libfullock-dev (>= 1.0.59), chmpx-dev (>= 1.0.105), libyaml-dev, gnutls-dev
Depends: ${misc:Depends}
Standards-Version: 3.9.8
Homepage: https://@GIT_DOMAIN@/@GIT_ORG@/@GIT_REPO@
Expand All @@ -12,6 +12,6 @@ Vcs-Browser: https://@GIT_DOMAIN@/@GIT_ORG@/@GIT_REPO@
Package: @PACKAGE_NAME@
Section: libs
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, k2hash (>= 1.0.92), libfullock (>= 1.0.57), chmpx (>= 1.0.104)
Depends: ${shlibs:Depends}, ${misc:Depends}, k2hash (>= 1.0.93), libfullock (>= 1.0.59), chmpx (>= 1.0.105)
Description: @SHORTDESC@
@DEBLONGDESC@
4 changes: 2 additions & 2 deletions buildutils/k2htpdtor.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ License: @PKGLICENSE@
@RPMPKG_GROUP@
URL: https://@GIT_DOMAIN@/@GIT_ORG@/@PACKAGE_NAME@
Source0: https://@GIT_DOMAIN@/@GIT_ORG@/@PACKAGE_NAME@/archive/%{gittag}/%{name}-%{version}.tar.gz
Requires: libfullock%{?_isa} >= 1.0.57, k2hash%{?_isa} >= 1.0.92, chmpx%{?_isa} >= 1.0.104
BuildRequires: git-core gcc-c++ make libtool libfullock-devel >= 1.0.57, k2hash-devel >= 1.0.92, chmpx-devel >= 1.0.104, libyaml-devel, nss-devel
Requires: libfullock%{?_isa} >= 1.0.59, k2hash%{?_isa} >= 1.0.93, chmpx%{?_isa} >= 1.0.105
BuildRequires: git-core gcc-c++ make libtool libfullock-devel >= 1.0.59, k2hash-devel >= 1.0.93, chmpx-devel >= 1.0.105, libyaml-devel, nss-devel

%description
@LONGDESC@
Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ AC_ARG_ENABLE(check-depend-libs,
esac]
)
AS_IF([test ${check_depend_libs} = 1], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([fullock], [libfullock >= 1.0.57], [], [AC_MSG_ERROR(not found libfullock package)])])
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([k2hash], [libk2hash >= 1.0.92], [], [AC_MSG_ERROR(not found k2hash package)])])
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([chmpx], [libchmpx >= 1.0.104], [], [AC_MSG_ERROR(not found chmpx package)])])
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([fullock], [libfullock >= 1.0.59], [], [AC_MSG_ERROR(not found libfullock package)])])
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([k2hash], [libk2hash >= 1.0.93], [], [AC_MSG_ERROR(not found k2hash package)])])
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([chmpx], [libchmpx >= 1.0.105], [], [AC_MSG_ERROR(not found chmpx package)])])

#
# CFLAGS/CXXFLAGS
Expand Down
16 changes: 14 additions & 2 deletions lib/k2htpdtorman.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ void* K2HtpDtorManager::WorkerThread(void* param)
}
// catch event
for(int cnt = 0; cnt < eventcnt; cnt++){
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress knownConditionTrueFalse
if(!pDtorMan->CheckWatch(events[cnt].data.fd)){
ERR_K2HPRN("Something error occurred in checking epoll event, but continue...");
}
Expand Down Expand Up @@ -348,6 +350,8 @@ bool K2HtpDtorManager::ReadIniFileContents(const char* filepath, dtorstrlst_t& l
// found include.
bool found_same_file = false;
for(dtorstrlst_t::const_iterator iter = allfiles.begin(); iter != allfiles.end(); ++iter){
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress useStlAlgorithm
if(value == (*iter)){
found_same_file = true;
break;
Expand Down Expand Up @@ -475,6 +479,8 @@ bool K2HtpDtorManager::LoadConfigurationIni(const char* filepath, string& chmpxc

}else if(line == INICFG_K2HTPDTOR_FILTER_STR){
// set except types
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress knownConditionTrueFalse
if(!parse_except_types(value.c_str(), excepttypes)){
WAN_K2HPRN("could not load except transaction type(%s) by %s key.", value.c_str(), line.c_str());
excepttypes.clear();
Expand Down Expand Up @@ -829,6 +835,8 @@ bool K2HtpDtorManager::LoadConfigurationYamlContents(yaml_parser_t& yparser, str

}else if(0 == strcasecmp(INICFG_K2HTPDTOR_FILTER_STR, key.c_str())){
// set except types
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress knownConditionTrueFalse
if(!parse_except_types(reinterpret_cast<const char*>(yevent.data.scalar.value), excepttypes)){
WAN_K2HPRN("could not load except transaction type(%s) by %s key.", reinterpret_cast<const char*>(yevent.data.scalar.value), key.c_str());
excepttypes.clear();
Expand Down Expand Up @@ -1185,7 +1193,9 @@ bool K2HtpDtorManager::CheckWatch(int inotifyfd)
//
string tgfile;
for(dtorlist_t::iterator iter = dtorlist.begin(); iter != dtorlist.end(); ++iter){
PDTORINFO pdtor = *iter;
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress constVariablePointer
const PDTORINFO pdtor = *iter;
if(pdtor && pdtor->inotify_fd == inotifyfd){
tgfile = pdtor->outputfile;
break;
Expand Down Expand Up @@ -1289,7 +1299,9 @@ bool K2HtpDtorManager::IsExceptKey(k2h_h k2hhandle, const unsigned char* pkey, s
if(dtormap.end() == dtormap.find(k2hhandle)){
ERR_K2HPRN("K2HTPDTOR does not have k2hash handle(0x%016" PRIx64 ") mapping.", k2hhandle);
}else{
PDTORINFO pdtor = dtormap[k2hhandle];
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress constVariablePointer
const PDTORINFO pdtor = dtormap[k2hhandle];
if(pdtor){
result = find_dtorpbylst(pdtor->excepts, pkey, length);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/k2htpdtorman.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ inline void free_dtorpbylst(dtorpbylst_t& pbylst)
}
}

inline bool find_dtorpbylst(dtorpbylst_t& pbylst, const unsigned char* pbin, size_t length)
inline bool find_dtorpbylst(const dtorpbylst_t& pbylst, const unsigned char* pbin, size_t length)
{
if(!pbin || 0 == length){
return false;
Expand Down
6 changes: 6 additions & 0 deletions src/k2htpdtorsvrfd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ void* K2htpSvrFd::WorkerThread(void* param)
// check removing/moving file
if(K2htpSvrFd::CheckInotifyEvents(events[cnt].data.fd, pSvrFdObj)){
// close fd
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress knownConditionTrueFalse
if(!pSvrFdObj->Close()){
ERR_K2HPRN("Failed to close file(%s), but continue...", pSvrFdObj->filepath.c_str());
}
Expand Down Expand Up @@ -276,6 +278,8 @@ K2htpSvrFd::~K2htpSvrFd(void)
ERR_K2HPRN("Could not stop thread, but continue...");
}
// close file
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress knownConditionTrueFalse
if(!Close()){
ERR_K2HPRN("Could not close file, but continue...");
}
Expand All @@ -284,6 +288,8 @@ K2htpSvrFd::~K2htpSvrFd(void)
bool K2htpSvrFd::Initialize(const char* path)
{
// open file
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress knownConditionTrueFalse
if(!Close() || !Open(path)){
ERR_K2HPRN("Could not initialize about file(%s).", path);
return false;
Expand Down

0 comments on commit 65df79e

Please sign in to comment.