Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
07612ad
Add local and CI code quality validation workflow
minminlittleshrimp Jun 24, 2026
5ccd37d
Fix dlt_version.h macro redefinition and sign-conversion warnings
minminlittleshrimp Jul 12, 2026
a373a8a
Add SPDX-License-Identifier headers to all source files
minminlittleshrimp Jul 12, 2026
3cd9bca
Fix unused-result warning on fread in dlt-system-processes
minminlittleshrimp Jul 12, 2026
096ceb4
Fix memory safety bugs found by ASan and cppcheck
minminlittleshrimp Jul 12, 2026
a5d6095
Fix stale SHM and improve test infrastructure for ASan
minminlittleshrimp Jul 12, 2026
d566d9b
Improve cppcheck performance and configuration
minminlittleshrimp Jul 12, 2026
11e6662
Update .gitignore for build artifacts
minminlittleshrimp Jul 12, 2026
15bed08
Fix race conditions in dlt_user.c and stack-buffer-overflow in test
minminlittleshrimp Jul 12, 2026
4f912dc
Fix gtest_dlt_common_v2 segfault and improve CI pipeline
minminlittleshrimp Jul 12, 2026
84c2a6b
Fix deadlock in dlt_free() and ASan suppression configuration
minminlittleshrimp Jul 12, 2026
86f0344
Fix CI pipeline issues
minminlittleshrimp Jul 12, 2026
087c8f2
Fix valgrind CI: create DartConfiguration.tcl and use memcheck
minminlittleshrimp Jul 13, 2026
ce85147
Fix macOS build: dynamically detect GCC version
minminlittleshrimp Jul 13, 2026
f683ae8
Fix commit-check CI and add local commit validation
minminlittleshrimp Jul 13, 2026
acd7ee7
Fix devtest: restart daemon after logstorage disconnect crash
minminlittleshrimp Jul 13, 2026
150e443
Fix clang-format violations in source files
minminlittleshrimp Jul 13, 2026
11e170a
Fix cppcheck resource leak and allow warnings in pipeline
minminlittleshrimp Jul 13, 2026
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
32 changes: 19 additions & 13 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
---
Language: Cpp
# BasedOnStyle: LLVM
# BasedOnStyle: LLVM
# Clang-Format 16+ Configuration for dlt-daemon
#
# This project targets C (gnu11) and C++ (gnu++17). The Cpp language
# mode is used because clang-format does not have a separate C mode;
# the formatting rules apply equally to .c and .cpp files.
Standard: c++11

AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
Expand All @@ -32,13 +39,15 @@ BraceWrapping:
BeforeCatch: false
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
Expand Down Expand Up @@ -72,19 +81,16 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortIncludes: CaseSensitive
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

19 changes: 19 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Checks: >
-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-assignment-in-if-condition,
clang-analyzer-*,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Give a reason for disabling warnings about insecure APIs. dlt is doing a lot of buffer handling, so doing that safely would be a benefit right?
Same for strcpy it could be replaced with strncpy in (almost?) all cases and prevent a bunch of memory issues. Might be worth at least a follow up?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comments
This is due to the huge workload a reviewer need for this such "WTF" Pull Request from me, so to reduce the painful review for now we temp ok with this disable, and shall apply Annet K secure api like strcpy_s ... or any suitable approach later in other PRs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth creating a couple of issues for that, so someone can easily volunteer to fix these? It would be a big benefit to the project and is likely something that can be pretty well with AI (at least the first shot, it probably needs some human brains to fix some details then)

-clang-analyzer-security.insecureAPI.strcpy,
-clang-analyzer-valist.Uninitialized,
performance-*,
portability-*,
misc-*
WarningsAsErrors: >-
clang-analyzer-*,
bugprone-*
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: file
User: covesa
123 changes: 123 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/bin/bash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: You might want to use something like uv + precommit instead of hand building this, it can help you with the pre commit and pre push too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. here is what we are using in opensovd https://github.com/eclipse-opensovd/cicd-workflows/blob/main/.pre-commit-hooks.yaml it will make your life easier and simplify the github stages too. (Linking opensovd only because it's a good example on how to configure pre-commit, you don't have to this exact config)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This much more good reference to me, things can be learnt form other experts.
Thank a lots

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anytime! you can also reach out to me directly, if you have questions about that or need support :)

#
# SPDX-License-Identifier: MPL-2.0
#
# commit-msg hook for dlt-daemon
#
# Validates the commit message of the current commit being created.
# This mirrors the CI commit-check rules so issues are caught before commit.
#
# To enable:
# git config core.hooksPath .githooks
#
# To bypass (emergency only):
# git commit --no-verify
#

set -euo pipefail

RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

COMMIT_MSG_FILE="$1"

print_header()
{
echo
echo "=================================================="
echo "$1"
echo "=================================================="
}

main()
{
print_header "COMMIT MESSAGE CHECK"

local SUBJECT BODY FULL
SUBJECT=$(head -1 "${COMMIT_MSG_FILE}")
BODY=$(sed -n '2,$p' "${COMMIT_MSG_FILE}")
FULL=$(cat "${COMMIT_MSG_FILE}")

local FAILED=0

# Strip comment lines (lines starting with #) for validation
local SUBJECT_NOCOMMENT BODY_NOCOMMENT FULL_NOCOMMENT
SUBJECT_NOCOMMENT=$(grep -v '^#' "${COMMIT_MSG_FILE}" | head -1)
BODY_NOCOMMENT=$(grep -v '^#' "${COMMIT_MSG_FILE}" | sed -n '2,$p')
FULL_NOCOMMENT=$(grep -v '^#' "${COMMIT_MSG_FILE}")

# Subject must not be empty
if [ -z "${SUBJECT_NOCOMMENT}" ]; then
echo "Commit subject is empty."
FAILED=1
fi

# Subject must be <= 72 chars
if [ ${#SUBJECT_NOCOMMENT} -gt 72 ]; then
echo "Commit subject exceeds 72 characters:"
echo " ${SUBJECT_NOCOMMENT}"
FAILED=1
fi

# No trailing period on subject
if echo "${SUBJECT_NOCOMMENT}" | grep -qE '\.$'; then
echo "Commit subject must not end with a period:"
echo " ${SUBJECT_NOCOMMENT}"
FAILED=1
fi

# No fixup!/squash! commits
if echo "${SUBJECT_NOCOMMENT}" | grep -qE '^(fixup|squash)!'; then
echo "fixup!/squash! commits are not allowed"
FAILED=1
fi

# Subject must start with an imperative verb
if ! echo "${SUBJECT_NOCOMMENT}" | grep -qE \
'^(Add|Fix|Remove|Update|Refactor|Implement|Improve|Introduce|Rename|Replace|Cleanup|Document|Convert|Move|Enable|Disable)\b'; then
echo "Commit subject must start with an imperative verb."
echo " Allowed: Add|Fix|Remove|Update|Refactor|Implement|Improve|"
echo " Introduce|Rename|Replace|Cleanup|Document|Convert|"
echo " Move|Enable|Disable"
echo " Got: ${SUBJECT_NOCOMMENT}"
FAILED=1
fi

# Must have Signed-off-by (DCO)
if ! echo "${FULL_NOCOMMENT}" | grep -q '^Signed-off-by:'; then
echo "Missing Signed-off-by."
echo " Use: git commit -s"
FAILED=1
fi

# Blank line between subject and body
local SECOND_LINE
SECOND_LINE=$(grep -v '^#' "${COMMIT_MSG_FILE}" | sed -n '2p')
if [ -n "${SECOND_LINE}" ]; then
if ! echo "${SECOND_LINE}" | grep -qE '^[[:space:]]*$'; then
echo "Blank line required between subject and body."
FAILED=1
fi
fi

# Body lines must be <= 72 chars
while IFS= read -r LINE; do
[ -z "${LINE}" ] && continue
if [ ${#LINE} -gt 72 ]; then
echo "Commit body line exceeds 72 characters:"
echo " ${LINE}"
FAILED=1
fi
done <<< "${BODY_NOCOMMENT}"

if [ ${FAILED} -ne 0 ]; then
echo ""
echo -e "${RED}FAIL: Commit message validation failed${NC}"
exit 1
fi

echo -e "${GREEN}PASS${NC}"
}

main
164 changes: 164 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#!/bin/bash
#
# SPDX-License-Identifier: MPL-2.0
#
# Pre-commit hook for dlt-daemon
#
# Runs clang-format and commit-message checks on staged files.
# This mirrors the CI pipeline so issues are caught before push.
#
# To enable:
# git config core.hooksPath .githooks
#
# To bypass (emergency only):
# git commit --no-verify
#

set -euo pipefail

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'

# Directories excluded from checks (same as check.sh)
EXCLUDE_PATTERNS=(
'^src/android/'
'^src/dlt-qnx-system/'
'^src/core_dump_handler/'
'^src/dbus/'
'^src/kpi/'
'^src/tests/'
'^qnx/'
'^googletest/'
'^doc/'
'^build/'
)

EXCLUDE_REGEX="$(IFS='|'; echo "${EXCLUDE_PATTERNS[*]}")"

print_header()
{
echo
echo "=================================================="
echo "$1"
echo "=================================================="
}

# ---------------------------------------------------------------------------
# Collect staged C/C++ files
# ---------------------------------------------------------------------------
get_staged_files()
{
git diff --cached --name-only --diff-filter=ACM \
| grep -E '^(src|include|tests)/.*\.(c|cc|cpp|cxx|h|hh|hpp|hxx)$' \
| grep -Ev "${EXCLUDE_REGEX}" \
|| true
}

# ---------------------------------------------------------------------------
# clang-format check
# ---------------------------------------------------------------------------
run_format_check()
{
# Prefer clang-format-16 to match CI (Docker container with LLVM 16)
local CLANG_FORMAT
CLANG_FORMAT=$(command -v clang-format-16 || command -v clang-format-18 || command -v clang-format)

if [ -z "${CLANG_FORMAT}" ]; then
echo -e "${YELLOW}WARNING: clang-format not found, skipping format check${NC}"
return 0
fi

print_header "CLANG-FORMAT (staged files)"

local FILES
FILES=$(get_staged_files)

if [ -z "${FILES}" ]; then
echo "No C/C++ files staged."
return 0
fi

local FAILED=0

while IFS= read -r FILE; do
[ -z "${FILE}" ] && continue

echo "Checking ${FILE}"

if ! "${CLANG_FORMAT}" \
--style=file \
--dry-run \
--Werror \
"${FILE}"; then
FAILED=1
fi
done <<< "${FILES}"

if [ "${FAILED}" -ne 0 ]; then
echo ""
echo -e "${RED}FAIL: One or more files are not formatted${NC}"
echo "Fix with:"
echo " ./check.sh fix-format"
echo "Or for specific files:"
echo " clang-format -i <file>"
return 1
fi

echo -e "${GREEN}PASS${NC}"
}

# ---------------------------------------------------------------------------
# SPDX license header check
# ---------------------------------------------------------------------------
run_spdx_check()
{
print_header "SPDX LICENSE HEADER (staged files)"

local FILES
FILES=$(git diff --cached --name-only --diff-filter=ACM \
| grep -E '^(src|include|tests)/.*\.(c|cc|cpp|cxx|h|hh|hpp|hxx)$' \
| grep -Ev "${EXCLUDE_REGEX}" \
|| true)

if [ -z "${FILES}" ]; then
echo "No C/C++ files staged."
return 0
fi

local FAILED=0

while IFS= read -r FILE; do
[ -z "${FILE}" ] && continue

if ! grep -q 'SPDX-License-Identifier:' "${FILE}"; then
echo "Missing SPDX-License-Identifier in: ${FILE}"
FAILED=1
fi
done <<< "${FILES}"

if [ "${FAILED}" -ne 0 ]; then
echo ""
echo -e "${RED}FAIL: Missing SPDX headers${NC}"
echo "Add the following to the top of each file:"
echo " /* SPDX-License-Identifier: MPL-2.0 */"
return 1
fi

echo -e "${GREEN}PASS${NC}"
}

# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
main()
{
run_format_check
run_spdx_check

print_header "PRE-COMMIT"
echo -e "${GREEN}All checks passed${NC}"
}

main
Loading
Loading