Skip to content

Commit 65df79e

Browse files
authored
Merge pull request #73 from ggtakec/update_etc
Changed support OS and Fixed about cppcheck, etc
2 parents 1b43bb3 + ab10e8b commit 65df79e

File tree

9 files changed

+90
-31
lines changed

9 files changed

+90
-31
lines changed

.github/workflows/ci.yml

+16-9
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,26 @@ jobs:
6969
- rockylinux:9
7070
- rockylinux:8
7171
- centos:centos7
72+
- fedora:39
7273
- fedora:38
73-
- fedora:37
74+
- alpine:3.19
7475
- alpine:3.18
7576

7677
container:
7778
image: ${{ matrix.container }}
7879

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

8794
#
@@ -153,18 +160,18 @@ jobs:
153160
# <default tag flag>: If you want to use the created Docker image as the default image, specify "default".
154161
#
155162
imageinfo:
156-
- alpine:3.18,alpine:3.18,alpine,default
163+
- alpine:3.19,alpine:3.19,alpine,default
157164
- ubuntu:22.04,ubuntu:22.04,ubuntu
158165

159166
#
160167
# Run building and pushing helper
161168
#
162169
steps:
163170
- name: Checkout sources
164-
uses: actions/checkout@v3
171+
uses: actions/checkout@v4
165172

166173
- name: Set up Docker Buildx
167-
uses: docker/setup-buildx-action@v2
174+
uses: docker/setup-buildx-action@v3
168175

169176
#
170177
# Login to avoid the Docker Hub rate limit
@@ -178,7 +185,7 @@ jobs:
178185
#
179186
- name: Login to DockerHub
180187
if: ${{ github.event_name != 'pull_request' }}
181-
uses: docker/login-action@v2
188+
uses: docker/login-action@v3
182189
with:
183190
username: ${{ secrets.DOCKER_HUB_USERNAME }}
184191
password: ${{ secrets.DOCKER_HUB_ACCESSTOKEN }}

.github/workflows/ostypevars.sh

+18-4
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ elif [ "${CI_OSTYPE}" = "centos:7" ] || [ "${CI_OSTYPE}" = "centos:centos7" ]; t
228228
PKG_EXT="rpm"
229229
IS_OS_CENTOS=1
230230

231-
elif [ "${CI_OSTYPE}" = "fedora:38" ]; then
232-
DIST_TAG="fedora/38"
231+
elif [ "${CI_OSTYPE}" = "fedora:39" ]; then
232+
DIST_TAG="fedora/39"
233233
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"
234234
INSTALLER_BIN="dnf"
235235
UPDATE_CMD="update"
@@ -242,8 +242,8 @@ elif [ "${CI_OSTYPE}" = "fedora:38" ]; then
242242
PKG_EXT="rpm"
243243
IS_OS_FEDORA=1
244244

245-
elif [ "${CI_OSTYPE}" = "fedora:37" ]; then
246-
DIST_TAG="fedora/37"
245+
elif [ "${CI_OSTYPE}" = "fedora:38" ]; then
246+
DIST_TAG="fedora/38"
247247
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"
248248
INSTALLER_BIN="dnf"
249249
UPDATE_CMD="update"
@@ -256,6 +256,20 @@ elif [ "${CI_OSTYPE}" = "fedora:37" ]; then
256256
PKG_EXT="rpm"
257257
IS_OS_FEDORA=1
258258

259+
elif [ "${CI_OSTYPE}" = "alpine:3.19" ]; then
260+
DIST_TAG="alpine/v3.19"
261+
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"
262+
INSTALLER_BIN="apk"
263+
UPDATE_CMD="update"
264+
UPDATE_CMD_ARG="--no-progress"
265+
INSTALL_CMD="add"
266+
INSTALL_CMD_ARG="--no-progress --no-cache"
267+
INSTALL_AUTO_ARG=""
268+
INSTALL_QUIET_ARG="-q"
269+
PKG_OUTPUT_DIR="apk_build"
270+
PKG_EXT="apk"
271+
IS_OS_ALPINE=1
272+
259273
elif [ "${CI_OSTYPE}" = "alpine:3.18" ]; then
260274
DIST_TAG="alpine/v3.18"
261275
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"

Makefile.am

+28-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ EXTRA_DIST=RELEASE_VERSION @CONFIGURECUSTOM@
2727
# Versions of cppcheck below 1.8 perform poorly and the test is
2828
# skipped if those versions are installed.
2929
#
30-
CPPCHECK_NG_VERSION = -e \^0\\. -e \^1\\.[0-7]
30+
CPPCHECK_NG_VER = -e \^0\\. -e \^1\\.[0-7]
3131
CPPCHECK_CMD = cppcheck
3232
CPPCHECK_TARGET = $(SUBDIRS)
3333
CPPCHECK_BUILD_DIR = /tmp/cppcheck
@@ -39,19 +39,38 @@ CPPCHECK_BASE_OPT = --quiet \
3939
--xml
4040
CPPCHECK_ENABLE_OPT = --enable=warning,style,information,missingInclude
4141
CPPCHECK_IGNORE_OPT = --suppress=unmatchedSuppression
42+
CPPCHECK_INCDIR_OPT = -I . -I lib
4243
CPPCHECK_DEFINE_OPT =
4344

45+
# [NOTE] Switch options
46+
# The options available vary depending on the version.
47+
# There are cases where you use options that do not exist in older
48+
# versions.
49+
#
50+
CPPCHECK_GT207_VER = 2007
51+
CPPCHECK_GT207_ADD_OPT = --suppress=ctuOneDefinitionRuleViolation
52+
CPPCHECK_GE211_VER = 2011
53+
CPPCHECK_GE211_ADD_OPT = --check-level=exhaustive \
54+
--suppress=missingIncludeSystem
55+
4456
cppcheck:
45-
@if command -v $(CPPCHECK_CMD) >/dev/null 2>&1; then \
46-
if ($(CPPCHECK_CMD) --version | sed -e 's|Cppcheck[[:space:]]*||gi' | grep -q $(CPPCHECK_NG_VERSION)); then \
57+
@set -e; \
58+
if command -v $(CPPCHECK_CMD) >/dev/null 2>&1; then \
59+
if ($(CPPCHECK_CMD) --version | sed -e 's|Cppcheck[[:space:]]*||gi' | grep -q $(CPPCHECK_NG_VER)); then \
4760
echo "*** [INFO] cppcheck version below 1.8, so skip to run cppcheck."; \
4861
else \
4962
echo "*** Check all files with CppCheck"; \
5063
if [ -d $(CPPCHECK_BUILD_DIR) ]; then \
5164
rm -rf $(CPPCHECK_BUILD_DIR); \
5265
fi; \
5366
mkdir -p $(CPPCHECK_BUILD_DIR); \
54-
$(CPPCHECK_CMD) $(CPPCHECK_BASE_OPT) $(CPPCHECK_DEFINE_OPT) $(CPPCHECK_ENABLE_OPT) $(CPPCHECK_IGNORE_OPT) --cppcheck-build-dir=$(CPPCHECK_BUILD_DIR) $(CPPCHECK_TARGET); \
67+
if test `$(CPPCHECK_CMD) --version | sed -e 's/\./ /g' | awk '{print ($$2 * 1000 + $$3)}'` -le $(CPPCHECK_GT207_VER); then \
68+
$(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); \
69+
elif test `$(CPPCHECK_CMD) --version | sed -e 's/\./ /g' | awk '{print ($$2 * 1000 + $$3)}'` -lt $(CPPCHECK_GE211_VER); then \
70+
$(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); \
71+
else \
72+
$(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); \
73+
fi; \
5574
rm -rf $(CPPCHECK_BUILD_DIR); \
5675
fi; \
5776
else \
@@ -75,16 +94,17 @@ SHELLCHECK_FILES_SH = `grep -ril '^\#!/bin/sh' . | grep '\.sh' | grep -v '\
7594
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' ' '`
7695

7796
shellcheck:
78-
@if type shellcheck > /dev/null 2>&1; then \
97+
@set -e; \
98+
if type shellcheck > /dev/null 2>&1; then \
7999
echo "*** Check all files with ShellCheck"; \
80100
if [ -n "$(SHELLCHECK_FILES_NO_SH)" ]; then \
81-
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_IGN_OPT) $(SHELLCHECK_FILES_NO_SH) || exit 1; \
101+
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_IGN_OPT) $(SHELLCHECK_FILES_NO_SH); \
82102
fi; \
83103
if [ -n "$(SHELLCHECK_FILES_SH)" ]; then \
84-
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_IGN_OPT) $(SHELLCHECK_FILES_SH) || exit 1; \
104+
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_IGN_OPT) $(SHELLCHECK_FILES_SH); \
85105
fi; \
86106
if [ -n "$(SHELLCHECK_FILES_INCLUDE_SH)" ]; then \
87-
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_INCLUDE_IGN_OPT) $(SHELLCHECK_FILES_INCLUDE_SH) || exit 1; \
107+
LC_ALL=C.UTF-8 $(SHELLCHECK_CMD) $(SHELLCHECK_BASE_OPT) $(SHELLCHECK_INCLUDE_IGN_OPT) $(SHELLCHECK_FILES_INCLUDE_SH); \
88108
fi; \
89109
echo " -> No error was detected."; \
90110
echo ""; \

buildutils/control.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Source: @PACKAGE_NAME@
22
Section: libs
33
Priority: optional
44
Maintainer: @DEV_NAME@ <@DEV_EMAIL@>
5-
Build-Depends: @DEBHELPER_DEP@, k2hash-dev (>= 1.0.92), libfullock-dev (>= 1.0.57), chmpx-dev (>= 1.0.104), libyaml-dev, gnutls-dev
5+
Build-Depends: @DEBHELPER_DEP@, k2hash-dev (>= 1.0.93), libfullock-dev (>= 1.0.59), chmpx-dev (>= 1.0.105), libyaml-dev, gnutls-dev
66
Depends: ${misc:Depends}
77
Standards-Version: 3.9.8
88
Homepage: https://@GIT_DOMAIN@/@GIT_ORG@/@GIT_REPO@
@@ -12,6 +12,6 @@ Vcs-Browser: https://@GIT_DOMAIN@/@GIT_ORG@/@GIT_REPO@
1212
Package: @PACKAGE_NAME@
1313
Section: libs
1414
Architecture: amd64
15-
Depends: ${shlibs:Depends}, ${misc:Depends}, k2hash (>= 1.0.92), libfullock (>= 1.0.57), chmpx (>= 1.0.104)
15+
Depends: ${shlibs:Depends}, ${misc:Depends}, k2hash (>= 1.0.93), libfullock (>= 1.0.59), chmpx (>= 1.0.105)
1616
Description: @SHORTDESC@
1717
@DEBLONGDESC@

buildutils/k2htpdtor.spec.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ License: @PKGLICENSE@
5252
@RPMPKG_GROUP@
5353
URL: https://@GIT_DOMAIN@/@GIT_ORG@/@PACKAGE_NAME@
5454
Source0: https://@GIT_DOMAIN@/@GIT_ORG@/@PACKAGE_NAME@/archive/%{gittag}/%{name}-%{version}.tar.gz
55-
Requires: libfullock%{?_isa} >= 1.0.57, k2hash%{?_isa} >= 1.0.92, chmpx%{?_isa} >= 1.0.104
56-
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
55+
Requires: libfullock%{?_isa} >= 1.0.59, k2hash%{?_isa} >= 1.0.93, chmpx%{?_isa} >= 1.0.105
56+
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
5757

5858
%description
5959
@LONGDESC@

configure.ac

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ AC_ARG_ENABLE(check-depend-libs,
160160
esac]
161161
)
162162
AS_IF([test ${check_depend_libs} = 1], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
163-
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([fullock], [libfullock >= 1.0.57], [], [AC_MSG_ERROR(not found libfullock package)])])
164-
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([k2hash], [libk2hash >= 1.0.92], [], [AC_MSG_ERROR(not found k2hash package)])])
165-
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([chmpx], [libchmpx >= 1.0.104], [], [AC_MSG_ERROR(not found chmpx package)])])
163+
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([fullock], [libfullock >= 1.0.59], [], [AC_MSG_ERROR(not found libfullock package)])])
164+
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([k2hash], [libk2hash >= 1.0.93], [], [AC_MSG_ERROR(not found k2hash package)])])
165+
AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([chmpx], [libchmpx >= 1.0.105], [], [AC_MSG_ERROR(not found chmpx package)])])
166166

167167
#
168168
# CFLAGS/CXXFLAGS

lib/k2htpdtorman.cc

+14-2
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ void* K2HtpDtorManager::WorkerThread(void* param)
300300
}
301301
// catch event
302302
for(int cnt = 0; cnt < eventcnt; cnt++){
303+
// cppcheck-suppress unmatchedSuppression
304+
// cppcheck-suppress knownConditionTrueFalse
303305
if(!pDtorMan->CheckWatch(events[cnt].data.fd)){
304306
ERR_K2HPRN("Something error occurred in checking epoll event, but continue...");
305307
}
@@ -348,6 +350,8 @@ bool K2HtpDtorManager::ReadIniFileContents(const char* filepath, dtorstrlst_t& l
348350
// found include.
349351
bool found_same_file = false;
350352
for(dtorstrlst_t::const_iterator iter = allfiles.begin(); iter != allfiles.end(); ++iter){
353+
// cppcheck-suppress unmatchedSuppression
354+
// cppcheck-suppress useStlAlgorithm
351355
if(value == (*iter)){
352356
found_same_file = true;
353357
break;
@@ -475,6 +479,8 @@ bool K2HtpDtorManager::LoadConfigurationIni(const char* filepath, string& chmpxc
475479

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

830836
}else if(0 == strcasecmp(INICFG_K2HTPDTOR_FILTER_STR, key.c_str())){
831837
// set except types
838+
// cppcheck-suppress unmatchedSuppression
839+
// cppcheck-suppress knownConditionTrueFalse
832840
if(!parse_except_types(reinterpret_cast<const char*>(yevent.data.scalar.value), excepttypes)){
833841
WAN_K2HPRN("could not load except transaction type(%s) by %s key.", reinterpret_cast<const char*>(yevent.data.scalar.value), key.c_str());
834842
excepttypes.clear();
@@ -1185,7 +1193,9 @@ bool K2HtpDtorManager::CheckWatch(int inotifyfd)
11851193
//
11861194
string tgfile;
11871195
for(dtorlist_t::iterator iter = dtorlist.begin(); iter != dtorlist.end(); ++iter){
1188-
PDTORINFO pdtor = *iter;
1196+
// cppcheck-suppress unmatchedSuppression
1197+
// cppcheck-suppress constVariablePointer
1198+
const PDTORINFO pdtor = *iter;
11891199
if(pdtor && pdtor->inotify_fd == inotifyfd){
11901200
tgfile = pdtor->outputfile;
11911201
break;
@@ -1289,7 +1299,9 @@ bool K2HtpDtorManager::IsExceptKey(k2h_h k2hhandle, const unsigned char* pkey, s
12891299
if(dtormap.end() == dtormap.find(k2hhandle)){
12901300
ERR_K2HPRN("K2HTPDTOR does not have k2hash handle(0x%016" PRIx64 ") mapping.", k2hhandle);
12911301
}else{
1292-
PDTORINFO pdtor = dtormap[k2hhandle];
1302+
// cppcheck-suppress unmatchedSuppression
1303+
// cppcheck-suppress constVariablePointer
1304+
const PDTORINFO pdtor = dtormap[k2hhandle];
12931305
if(pdtor){
12941306
result = find_dtorpbylst(pdtor->excepts, pkey, length);
12951307
}

lib/k2htpdtorman.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ inline void free_dtorpbylst(dtorpbylst_t& pbylst)
5959
}
6060
}
6161

62-
inline bool find_dtorpbylst(dtorpbylst_t& pbylst, const unsigned char* pbin, size_t length)
62+
inline bool find_dtorpbylst(const dtorpbylst_t& pbylst, const unsigned char* pbin, size_t length)
6363
{
6464
if(!pbin || 0 == length){
6565
return false;

src/k2htpdtorsvrfd.cc

+6
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ void* K2htpSvrFd::WorkerThread(void* param)
226226
// check removing/moving file
227227
if(K2htpSvrFd::CheckInotifyEvents(events[cnt].data.fd, pSvrFdObj)){
228228
// close fd
229+
// cppcheck-suppress unmatchedSuppression
230+
// cppcheck-suppress knownConditionTrueFalse
229231
if(!pSvrFdObj->Close()){
230232
ERR_K2HPRN("Failed to close file(%s), but continue...", pSvrFdObj->filepath.c_str());
231233
}
@@ -276,6 +278,8 @@ K2htpSvrFd::~K2htpSvrFd(void)
276278
ERR_K2HPRN("Could not stop thread, but continue...");
277279
}
278280
// close file
281+
// cppcheck-suppress unmatchedSuppression
282+
// cppcheck-suppress knownConditionTrueFalse
279283
if(!Close()){
280284
ERR_K2HPRN("Could not close file, but continue...");
281285
}
@@ -284,6 +288,8 @@ K2htpSvrFd::~K2htpSvrFd(void)
284288
bool K2htpSvrFd::Initialize(const char* path)
285289
{
286290
// open file
291+
// cppcheck-suppress unmatchedSuppression
292+
// cppcheck-suppress knownConditionTrueFalse
287293
if(!Close() || !Open(path)){
288294
ERR_K2HPRN("Could not initialize about file(%s).", path);
289295
return false;

0 commit comments

Comments
 (0)