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

Changed support OS and Fixed about cppcheck, etc #136

Merged
merged 1 commit into from
Mar 11, 2024
Merged
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
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
24 changes: 19 additions & 5 deletions .github/workflows/ostypevars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ 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"
INSTALL_PKG_LIST="git autoconf automake gcc gcc-c++ gdb make libtool pkgconfig redhat-rpm-config rpm-build ruby-devel rubygems procps libyaml-devel k2hash-devel nss-devel"
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 k2hash-devel nss-devel systemd"
INSTALLER_BIN="dnf"
UPDATE_CMD="update"
UPDATE_CMD_ARG=""
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 k2hash-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 k2hash-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 k2hash-dev openssl-dev"
Expand Down
46 changes: 37 additions & 9 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,58 @@ 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]
# Since knownConditionTrueFalse and badBitmaskCheck are output a
# lot in debugging macros, so we will exclude it.
#
CPPCHECK_NG_VER = -e \^0\\. -e \^1\\.[0-7]
CPPCHECK_CMD = cppcheck
CPPCHECK_TARGET = $(SUBDIRS)
CPPCHECK_BUILD_DIR = /tmp/cppcheck
CPPCHECK_BASE_OPT = --quiet \
--error-exitcode=1 \
--inline-suppr \
-j 4 \
-j 8 \
--std=c++03 \
--xml
CPPCHECK_ENABLE_OPT = --enable=warning,style,information,missingInclude
CPPCHECK_IGNORE_OPT = --suppress=unmatchedSuppression
CPPCHECK_INCDIR_OPT = -I . -I lib
CPPCHECK_DEFINE_OPT = -D SO_REUSEPORT

# [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_GT204_VER = 2004
CPPCHECK_GT204_ADD_OPT = --suppress=knownConditionTrueFalse
CPPCHECK_GE207_VER = 2007
CPPCHECK_GE207_ADD_OPT = --suppress=ctuOneDefinitionRuleViolation
CPPCHECK_GE211_VER = 2011
CPPCHECK_GE211_ADD_OPT = --check-level=exhaustive \
--suppress=missingIncludeSystem \
--suppress=badBitmaskCheck

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_GT204_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_GE207_VER); then \
$(CPPCHECK_CMD) $(CPPCHECK_BASE_OPT) $(CPPCHECK_DEFINE_OPT) $(CPPCHECK_INCDIR_OPT) $(CPPCHECK_ENABLE_OPT) $(CPPCHECK_IGNORE_OPT) $(CPPCHECK_GT204_ADD_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_GT204_ADD_OPT) $(CPPCHECK_GE207_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_GT204_ADD_OPT) $(CPPCHECK_GE207_ADD_OPT) $(CPPCHECK_GE211_ADD_OPT) --cppcheck-build-dir=$(CPPCHECK_BUILD_DIR) $(CPPCHECK_TARGET); \
fi; \
rm -rf $(CPPCHECK_BUILD_DIR); \
fi; \
else \
Expand All @@ -81,16 +108,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
8 changes: 4 additions & 4 deletions buildutils/chmpx.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ 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: k2hash%{?_isa} >= 1.0.92, libfullock%{?_isa} >= 1.0.57, nss-tools
Requires: k2hash%{?_isa} >= 1.0.93, libfullock%{?_isa} >= 1.0.59, nss-tools
%if 0%{?rhel} == 6
BuildRequires: git-core gcc-c++ make libtool k2hash-devel >= 1.0.92, libfullock-devel >= 1.0.57, libyaml-devel, nss-devel
BuildRequires: git-core gcc-c++ make libtool k2hash-devel >= 1.0.93, libfullock-devel >= 1.0.59, libyaml-devel, nss-devel
%else
BuildRequires: systemd git-core gcc-c++ make libtool k2hash-devel >= 1.0.92, libfullock-devel >= 1.0.57, libyaml-devel, nss-devel
BuildRequires: systemd git-core gcc-c++ make libtool k2hash-devel >= 1.0.93, libfullock-devel >= 1.0.59, libyaml-devel, nss-devel
%endif

%description
Expand Down Expand Up @@ -134,7 +134,7 @@ rm -rf %{buildroot}
#
%package devel
Summary: @SHORTDESC@ (development)
Requires: %{name}%{?_isa} = %{version}-%{release}, k2hash-devel%{?_isa} >= 1.0.92, libfullock-devel%{?_isa} >= 1.0.57, libyaml-devel, nss-devel
Requires: %{name}%{?_isa} = %{version}-%{release}, k2hash-devel%{?_isa} >= 1.0.93, libfullock-devel%{?_isa} >= 1.0.59, libyaml-devel, nss-devel

%description devel
Development package for building with @PACKAGE_NAME@ shared library.
Expand Down
6 changes: 3 additions & 3 deletions buildutils/control.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: @PACKAGE_NAME@
Section: net
Priority: optional
Maintainer: @DEV_NAME@ <@DEV_EMAIL@>
Build-Depends: @DEBHELPER_DEP@, k2hash-dev (>= 1.0.92), libfullock-dev (>= 1.0.57), libyaml-dev, gnutls-dev
Build-Depends: @DEBHELPER_DEP@, k2hash-dev (>= 1.0.93), libfullock-dev (>= 1.0.59), libyaml-dev, gnutls-dev
Standards-Version: 3.9.8
Homepage: https://@GIT_DOMAIN@/@GIT_ORG@/@GIT_REPO@
Vcs-Git: git://@GIT_DOMAIN@/@GIT_ORG@/@[email protected]
Expand All @@ -11,14 +11,14 @@ Vcs-Browser: https://@GIT_DOMAIN@/@GIT_ORG@/@GIT_REPO@
Package: @PACKAGE_NAME@-dev
Section: devel
Architecture: amd64
Depends: ${misc:Depends}, @PACKAGE_NAME@ (= ${binary:Version}), k2hash-dev (>= 1.0.92), libfullock-dev (>= 1.0.57), libyaml-dev, gnutls-dev
Depends: ${misc:Depends}, @PACKAGE_NAME@ (= ${binary:Version}), k2hash-dev (>= 1.0.93), libfullock-dev (>= 1.0.59), libyaml-dev, gnutls-dev
Description: @SHORTDESC@ (development)
Development package for building with @PACKAGE_NAME@ shared library.
This package has header files and symbols for it.

Package: @PACKAGE_NAME@
Section: net
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, init-system-helpers (>= 1.14), k2hash (>= 1.0.92), libfullock (>= 1.0.57)
Depends: ${shlibs:Depends}, ${misc:Depends}, init-system-helpers (>= 1.14), k2hash (>= 1.0.93), libfullock (>= 1.0.59)
Description: @SHORTDESC@
@DEBLONGDESC@
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ 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([k2hash], [libk2hash >= 1.0.92], [], [AC_MSG_ERROR(not found k2hash package)])])
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.93], [], [AC_MSG_ERROR(not found k2hash package)])])
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([fullock], [libfullock >= 1.0.59], [], [AC_MSG_ERROR(not found libfullock package)])])

#
# CFLAGS/CXXFLAGS
Expand Down
8 changes: 5 additions & 3 deletions lib/chmcntrl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ ChmEventBase* ChmCntrl::FindEventBaseObj(int fd)

ChmEventBase* pEvObj = NULL;
for(evobj_map_t::const_iterator iter = evobjmap.begin(); iter != evobjmap.end(); ++iter){
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress useStlAlgorithm
if((iter->second)->IsEventQueueFd(fd)){
pEvObj = iter->second;
break;
Expand All @@ -158,6 +160,8 @@ bool ChmCntrl::GetEventBaseObjType(const ChmEventBase* pEvObj, EVOBJTYPE& type)

bool result = false;
for(evobj_map_t::const_iterator iter = evobjmap.begin(); iter != evobjmap.end(); ++iter){
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress useStlAlgorithm
if(iter->second == pEvObj){
type = CVT_EVMAP_TO_EVOBJTYPE(iter->first);
result = true;
Expand Down Expand Up @@ -510,7 +514,6 @@ bool ChmCntrl::EventLoop(void)
if(0L == ImData.GetUpServerCount()){
// Check any server up
if(pEventSock->InitialAllServerStatus()){
// cppcheck-suppress knownConditionTrueFalse
if(0L < ImData.GetUpServerCount()){
// Try to connect servers
//MSG_CHMPRN("Try to connect servers on RING(mode is SLAVE).");
Expand All @@ -531,7 +534,6 @@ bool ChmCntrl::EventLoop(void)
// [NOTE]
// This case is that there are no other server node up.
if(pEventSock->InitialAllServerStatus()){
// cppcheck-suppress knownConditionTrueFalse
if(1L < ImData.GetUpServerCount()){
// Try to connect servers
//MSG_CHMPRN("Try to connect servers on RING(mode is SERVER).");
Expand Down Expand Up @@ -642,7 +644,7 @@ bool ChmCntrl::Processing(PCOMPKT pComPkt, EVOBJTYPE call_ev_type)
}else if(COM_C2PX == pComPkt->head.type || COM_PX2C == pComPkt->head.type){
// Input from MQ, so processing do on MQ
//
PPXCLT_ALL pCltAll = CVT_CLT_ALL_PTR_PXCOMPKT(pComPkt);
const PPXCLT_ALL pCltAll = CVT_CLT_ALL_PTR_PXCOMPKT(pComPkt);
if(IS_PXCLT_TYPE(pCltAll, CHMPX_CLT_JOIN_NOTIFY)){
// CHMPX_CLT_JOIN_NOTIFY type is processing by ChmEventSock.
pProcessObj = GetEventBaseObj(EVOBJ_TYPE_EVSOCK);
Expand Down
Loading
Loading