diff --git a/.github/workflows/ECLAIR_final.yml b/.github/workflows/ECLAIR_final.yml
deleted file mode 100644
index 1f80857..0000000
--- a/.github/workflows/ECLAIR_final.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-name: "ECLAIR final"
-on: [workflow_dispatch]
-env:
- GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- ANALYSIS_KIND: final
-jobs:
- Analyze:
- runs-on: eclairit
- steps:
- - name: Checkout repository
- uses: actions/checkout@v3
- with:
- submodules: 'true'
- - name: Build and analyze with ECLAIR
- run: |
- set -eu
- ./prepare.sh Debug
- cd ECLAIR
- ./analyze.sh "${ANALYSIS_KIND}"
- - name: ECLAIR analysis log
- if: always()
- run: cat ECLAIR_out/ANALYSIS.log
- - name: ECLAIR report log
- if: always()
- run: cat ECLAIR_out/REPORT.log
- - name: Upload ECLAIR artifacts
- if: always()
- uses: actions/upload-artifact@v3
- with:
- name: artifacts
- path: ECLAIR_out*/
- - name: Upload ECLAIR SARIF
- uses: BUGSENG/codeql-action/upload-sarif@v2
- with:
- sarif_file: ECLAIR_out/reports.sarif
- - name: Publish ECLAIR results
- env:
- WTOKEN: ${{secrets.WTOKEN}}
- run: ECLAIR/action_push.sh "${WTOKEN}" ECLAIR_out
diff --git a/.github/workflows/ECLAIR_normal.yml b/.github/workflows/ECLAIR_normal.yml
deleted file mode 100644
index a6d2894..0000000
--- a/.github/workflows/ECLAIR_normal.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-name: "ECLAIR normal"
-on: [push]
-env:
- GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- ANALYSIS_KIND: normal
-jobs:
- Analyze:
- runs-on: eclairit
- steps:
- - name: Checkout repository
- uses: actions/checkout@v3
- with:
- submodules: 'true'
- - name: Build and analyze with ECLAIR
- run: |
- set -eu
- ./prepare.sh Debug
- cd ECLAIR
- ./analyze.sh "${ANALYSIS_KIND}"
- - name: ECLAIR analysis log
- if: always()
- run: cat ECLAIR_out/ANALYSIS.log
- - name: ECLAIR report log
- if: always()
- run: cat ECLAIR_out/REPORT.log
- - name: Upload ECLAIR artifacts
- if: always()
- uses: actions/upload-artifact@v3
- with:
- name: artifacts
- path: ECLAIR_out*/
- - name: Upload ECLAIR SARIF
- uses: BUGSENG/codeql-action/upload-sarif@v2
- with:
- sarif_file: ECLAIR_out/reports.sarif
- - name: Publish ECLAIR results
- env:
- WTOKEN: ${{secrets.WTOKEN}}
- run: ECLAIR/action_push.sh "${WTOKEN}" ECLAIR_out
diff --git a/.github/workflows/ECLAIR_pull_request.yml b/.github/workflows/ECLAIR_pull_request.yml
deleted file mode 100644
index ea3c1bf..0000000
--- a/.github/workflows/ECLAIR_pull_request.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-name: "ECLAIR pull request"
-on:
- pull_request_target:
- types: ['opened', 'synchronize']
-env:
- GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{github.event.pull_request.number}}
- GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- ANALYSIS_KIND: normal
-jobs:
- Analyze:
- runs-on: eclairit
- steps:
- - name: Checkout repository
- uses: actions/checkout@v3
- with:
- ref: "refs/pull/${{github.event.pull_request.number}}/merge"
- submodules: 'true'
- - name: Build and analyze with ECLAIR
- run: |
- set -eu
- ./prepare.sh Debug
- cd ECLAIR
- ./analyze.sh "${ANALYSIS_KIND}"
- - name: ECLAIR analysis log
- if: always()
- run: cat ECLAIR_out/ANALYSIS.log
- - name: ECLAIR report log
- if: always()
- run: cat ECLAIR_out/REPORT.log
- - name: Upload ECLAIR artifacts
- if: always()
- uses: actions/upload-artifact@v3
- with:
- name: artifacts
- path: ECLAIR_out*/
- - name: Upload ECLAIR SARIF
- uses: BUGSENG/codeql-action/upload-sarif@v2
- with:
- sarif_file: ECLAIR_out/reports.sarif
- - name: Publish ECLAIR results
- env:
- PR_HEAD_REF: ${{github.event.pull_request.head.ref}}
- PR_HEAD_REPO: ${{github.event.pull_request.head.repo.full_name}}
- PR_BASE_REF: ${{github.event.pull_request.base.ref}}
- PR_USER: ${{github.event.pull_request.user.login}}
- WTOKEN: ${{secrets.WTOKEN}}
- run: ECLAIR/action_pull_request.sh "${WTOKEN}" ECLAIR_out
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0f1ab64..8f390fe 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -6,5 +6,4 @@ Before you open PR:
- run `make cppcheck`
- run `make misra`
-After PR is opened, ECLAIR will check your code and Bot will report if any MISRA violation exists in the code.
-After all violations are fixed, we will review your code, and after that code can be merged into the main branch.
+After PR is opened, we will review your code, and after that code can be merged into the main branch.
diff --git a/ECLAIR/action.helpers b/ECLAIR/action.helpers
deleted file mode 100644
index e2bd477..0000000
--- a/ECLAIR/action.helpers
+++ /dev/null
@@ -1,193 +0,0 @@
-if [ -n "${GITLAB_CI:-}" ]; then
- ci=gitlab
-elif [ -n "${GITHUB_ACTION:-}" ]; then
- ci=github
-elif [ -n "${JENKINS_HOME:-}" ]; then
- ci=jenkins
-else
- echo "Unexpected CI/CD context" >&2
- exit 1
-fi
-
-esc=$(printf '\e')
-cr=$(printf '\r')
-
-open_section() {
- id=$1
- title=$2
- collapsed=$3
- echo "${esc}[0Ksection_start:$(date +%s):${id}${collapsed}${cr}${esc}[0K${esc}[1m${esc}[36m${title}${esc}[m"
-}
-
-close_section() {
- id=$1
- echo "${esc}[0Ksection_end:$(date +%s):${id}${cr}${esc}[0K"
-}
-
-summary() {
- fixedReports=
- newReports=
- unfixedReports=
- while read -r line; do
- var=${line%%: *}
- val=${line#*: }
- eval "${var}=${val}"
- done <"${updateLog}"
-
- case "${ci}" in
- github)
- nl="\\"
- ;;
- gitlab)
- nl=""
- ;;
- jenkins)
- nl="
"
- ;;
- *)
- nl=""
- ;;
- esac
-
- if [ -z "${newReports}" ]; then
- fixedMsg=""
- unfixedMsg="Unfixed reports: ${unfixedReports}"
- countsMsg="${unfixedMsg}"
- else
- fixedMsg="Fixed reports: ${fixedReports}"
- unfixedMsg="Unfixed reports: ${unfixedReports} [new: ${newReports}]"
- countsMsg="${fixedMsg}${nl}
-${unfixedMsg}"
- fi
- case "${ci}" in
- jenkins)
- cat <"${summaryTxt}"
-${countsMsg} ${nl}
-
-
-
-${jobHeadline}
-Browse analysis results
-EOF
- ;;
- *)
- cat <"${summaryTxt}"
-
-
-
-Analysis Summary
-
-${jobHeadline}${nl}
-${countsMsg}${nl}
-[Browse analysis](${indexHtmlUrl})
-EOF
- ;;
- esac
-
- case ${ci} in
- github)
- cat "${summaryTxt}" >"${GITHUB_STEP_SUMMARY}"
- ;;
- gitlab)
- open_section ECLAIR_summary "ECLAIR analysis summary" ""
- # Generate summary and print it (GitLab-specific)
- cat <&2
- exit 1
- ;;
- esac
-}
-
-log_file() {
- section_id=$1
- section_name=$2
- file=$3
- exit_code=$4
- if [ "${exit_code}" = 0 ]; then
- collapsed="[collapsed=true]"
- else
- collapsed=
- fi
-
- case ${ci} in
- github | jenkins)
- echo "${section_name}"
- ;;
- gitlab)
- open_section "${section_id}" "${section_name}" "${collapsed}"
- ;;
- *)
- echo "Unexpected CI/CD context" >&2
- exit 1
- ;;
- esac
-
- cat "${file}"
-
- case ${ci} in
- github | jenkins) ;;
- gitlab)
- close_section "${section_id}"
- ;;
- *) ;;
- esac
-}
-
-maybe_log_file_exit() {
- section_id=$1
- section_name=$2
- file=$3
- exit_code=$4
-
- case ${ci} in
- github | jenkins)
- echo "${section_name}"
- ;;
- gitlab)
- open_section "${section_id}" "${section_name}" ""
- ;;
- *)
- echo "Unexpected CI/CD context" >&2
- exit 1
- ;;
- esac
-
- if [ "${exit_code}" != 0 ]; then
- cat "${file}"
- fi
-
- case ${ci} in
- github | jenkins) ;;
- gitlab)
- close_section "${section_id}"
- ;;
- *) ;;
- esac
- return "${exit_code}"
-}
-
-is_enabled() {
- case "$1" in
- true | TRUE | y | Y | yes | YES | 1)
- return 0
- ;;
- *)
- return 1
- ;;
- esac
-}
diff --git a/ECLAIR/action.settings b/ECLAIR/action.settings
deleted file mode 100644
index f7366be..0000000
--- a/ECLAIR/action.settings
+++ /dev/null
@@ -1,156 +0,0 @@
-# Fit to repo setup, and add to the ECLAIR folder
-
-variantSubDir=
-variantHeadline=
-if [ -n "${VARIANT:-}" ]; then
- variantSubDir="/${VARIANT}"
- variantHeadline=" [${VARIANT}]"
-fi
-
-# AUTO PR Feature
-# If the following variables are defined, then all pipelines
-# of other branches will be considered pull-requests to
-# autoPRBranch.
-# To be customized (keep it empty to disable the AUTO PR feature)
-autoPRRepository=
-# To be customized (keep it empty to disable the AUTO PR feature)
-autoPRBranch=
-
-# To be customized
-keepOldAnalyses=0
-
-# To be customized
-artifactsRoot=/var/local/eclair/github
-
-case "${ci}" in
-github)
- autoPRRemoteUrl="${GITHUB_SERVER_URL}/${autoPRRepository:-}"
- # To be customized
- repository=${GITHUB_REPOSITORY}
- jobId=${GITHUB_RUN_NUMBER}
-
- case "${GITHUB_EVENT_NAME}" in
- pull_request*)
- event="pull_request"
- pullRequestId=${GITHUB_EVENT_PULL_REQUEST_NUMBER}
- pullRequestHeadRepo=${PR_HEAD_REPO}
- pullRequestHeadRef=${PR_HEAD_REF}
- pullRequestBaseRef=${PR_BASE_REF}
- pullRequestUser=${PR_USER}
- # baseCommitId and headCommitId are the most recent merge points without conflicts
- git fetch -q --deepen=2
- baseCommitId=$(git show -s --pretty=%H HEAD^1)
- headCommitId=$(git show -s --pretty=%H HEAD^2)
- ;;
- push | workflow_dispatch)
- event="push"
- # Extract the branch name from "refs/heads/"
- branch=${GITHUB_REF#refs/heads/}
- headCommitId=${GITHUB_SHA}
- pushUser=${GITHUB_ACTOR}
- ;;
- *)
- echo "Unexpected GITHUB_REF ${GITHUB_REF}" >&2
- exit 1
- ;;
- esac
- ;;
-gitlab)
- gitlabApiUrl="${CI_SERVER_PROTOCOL}://${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4"
- autoPRRemoteUrl="${CI_SERVER_PROTOCOL}://${CI_SERVER_HOST}:${CI_SERVER_PORT}/${autoPRRepository:-}"
- # To be customized
- gitlabBotToken="${ECLAIR_BOT_TOKEN:-}"
- # To be customized
- repository=${CI_PROJECT_PATH}
- jobId=${CI_JOB_ID}
-
- case "${CI_PIPELINE_SOURCE}" in
- merge_request_event)
- event="pull_request"
- pullRequestId=${CI_MERGE_REQUEST_IID}
- pullRequestHeadRef=${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}
- pullRequestHeadRepo=${CI_MERGE_REQUEST_SOURCE_PROJECT_PATH}
- pullRequestBaseRef=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
- pullRequestUser=${GITLAB_USER_LOGIN}
- headCommitId=${CI_COMMIT_SHA}
- baseCommitId=${CI_MERGE_REQUEST_DIFF_BASE_SHA}
- ;;
- push | pipeline | web)
- event="push"
- branch=${CI_COMMIT_BRANCH}
- headCommitId=${CI_COMMIT_SHA}
- pushUser=${GITLAB_USER_NAME}
- ;;
- *)
- echo "Unexpected event ${CI_PIPELINE_SOURCE}" >&2
- exit 1
- ;;
- esac
- ;;
-jenkins)
- jenkinsApiUrl="${JENKINS_URL}"
- autoPRRemoteUrl="${JENKINS_URL}/${autoPRRepository:-}"
- # To be customized
- jenkinsBotUsername="${ECLAIR_BOT_USERNAME:-}"
- jenkinsBotToken="${ECLAIR_BOT_TOKEN:-}"
-
- # To be customized
- repository="${JOB_BASE_NAME}"
- project="${JOB_NAME}"
- jobId=${BUILD_NUMBER}
-
- event="push"
- branch=${GIT_BRANCH}
- headCommitId=${GIT_COMMIT}
- pushUser=$(git show --pretty='format:%aN' -s)
- ;;
-*)
- echo "Unexpected CI/CD context" >&2
- exit 1
- ;;
-esac
-
-if [ "${event}" = "push" ] && [ -n "${autoPRBranch:-}" ]; then
- # AUTO PR Feature enabled
- if ! [ "${branch}" = "${autoPRBranch}" ] ||
- ! [ "${repository}" = "${autoPRRepository}" ]; then
- event=auto_pull_request
- fi
-fi
-
-case "${event}" in
-pull_request)
- subDir=${pullRequestHeadRepo}.ecdf/${pullRequestBaseRef}
- jobHeadline="ECLAIR ${ANALYSIS_KIND} on repository ${repository}: ${pullRequestUser} wants to merge ${pullRequestHeadRepo}:${pullRequestHeadRef} (${headCommitId}) into ${pullRequestBaseRef} (${baseCommitId})"
- ;;
-push)
- subDir="${branch}"
- jobHeadline="ECLAIR ${ANALYSIS_KIND} on repository ${repository}: branch ${branch} (${headCommitId})"
- badgeLabel="ECLAIR ${ANALYSIS_KIND} ${branch}${variantHeadline} #${jobId}"
- ;;
-auto_pull_request)
- git remote remove autoPRRemote || true
- git remote add autoPRRemote "${autoPRRemoteUrl}"
- git fetch autoPRRemote
- subDir=${branch}
- baseCommitId=$(git merge-base "autoPRRemote/${autoPRBranch}" HEAD)
- jobHeadline="ECLAIR ${ANALYSIS_KIND} on repository ${repository}: ${pushUser} wants to merge ${repository}:${branch} (${headCommitId}) into ${autoPRRepository}/${autoPRBranch} (${baseCommitId})"
- ;;
-*)
- echo "Unexpected event ${event}" >&2
- exit 1
- ;;
-esac
-
-artifactsDir=${artifactsRoot}/${repository}.ecdf/ECLAIR_${ANALYSIS_KIND}
-subDir="${subDir}${variantSubDir}"
-jobHeadline="${jobHeadline}${variantHeadline}"
-
-# To be customized
-eclairReportUrlPrefix=https://eclairit.com:3787
-
-jobDir=${artifactsDir}/${subDir}/${jobId}
-updateLog=${analysisOutputDir}/update.log
-commentLog=${analysisOutputDir}/comment.json
-indexHtmlUrl=${eclairReportUrlPrefix}/fs${jobDir}/index.html
-summaryTxt="${analysisOutputDir}/summary.txt"
diff --git a/ECLAIR/action_log.sh b/ECLAIR/action_log.sh
deleted file mode 100755
index 67125b0..0000000
--- a/ECLAIR/action_log.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-usage() {
- echo "Usage: $0 SECTION_ID SECTION_NAME FILE EXIT_CODE" >&2
- exit 2
-}
-
-[ $# -eq 4 ] || usage
-
-# Load settings and helpers
-. "$(dirname "$0")/action.helpers"
-
-log_file "$@"
diff --git a/ECLAIR/action_pull_request.sh b/ECLAIR/action_pull_request.sh
deleted file mode 100755
index 68f7e62..0000000
--- a/ECLAIR/action_pull_request.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-usage() {
- echo "Usage: $0 WTOKEN ANALYSIS_OUTPUT_DIR COMMIT_ID" >&2
- exit 2
-}
-
-[ $# -eq 2 ] || usage
-
-wtoken=$1
-analysisOutputDir=$2
-
-# Load settings and helpers
-. "$(dirname "$0")/action.helpers"
-. "$(dirname "$0")/action.settings"
-
-curl -sS "${eclairReportUrlPrefix}/ext/update_pull_request" \
- -F "wtoken=${wtoken}" \
- -F "artifactsDir=${artifactsDir}" \
- -F "subDir=${subDir}" \
- -F "jobId=${jobId}" \
- -F "jobHeadline=${jobHeadline}" \
- -F "baseCommitId=${baseCommitId}" \
- -F "keepOldAnalyses=${keepOldAnalyses}" \
- -F "db=@${analysisOutputDir}/PROJECT.ecd" \
- >"${updateLog}"
-ex=0
-grep -Fq "unfixedReports: " "${updateLog}" || ex=$?
-maybe_log_file_exit PUBLISH_RESULT "Publishing results" "${updateLog}" "${ex}"
-
-summary
-
-if is_enabled "${ENABLE_ECLAIR_BOT:-}"; then
- case ${ci} in
- github)
- ex=0
- gh api \
- --method POST \
- "/repos/${repository}/issues/${pullRequestId}/comments" \
- -F "body=@${summaryTxt}" \
- --silent >"${commentLog}" 2>&1 || ex=$?
- maybe_log_file_exit ADD_COMMENT "Adding comment" "${commentLog}" "${ex}"
- ;;
- gitlab)
- curl -sS --request POST \
- "${gitlabApiUrl}/projects/${CI_PROJECT_ID}/merge_requests/${pullRequestId}/notes" \
- -H "PRIVATE-TOKEN: ${gitlabBotToken}" \
- -F "body=<${summaryTxt}" >"${commentLog}"
- ex=0
- grep -Fq "Unfixed reports: " "${commentLog}" || ex=$?
- maybe_log_file_exit ADD_COMMENT "Adding comment" "${commentLog}" "${ex}"
- ;;
- *) ;;
- esac
-fi
diff --git a/ECLAIR/action_push.sh b/ECLAIR/action_push.sh
deleted file mode 100755
index 45215fb..0000000
--- a/ECLAIR/action_push.sh
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-usage() {
- echo "Usage: $0 WTOKEN ANALYSIS_OUTPUT_DIR" >&2
- exit 2
-}
-
-[ $# -eq 2 ] || usage
-
-wtoken=$1
-analysisOutputDir=$2
-
-# Load settings and helpers
-. "$(dirname "$0")/action.helpers"
-. "$(dirname "$0")/action.settings"
-
-case "${event}" in
-push)
- curl -sS "${eclairReportUrlPrefix}/ext/update_push" \
- -F "wtoken=${wtoken}" \
- -F "artifactsDir=${artifactsDir}" \
- -F "subDir=${subDir}" \
- -F "jobId=${jobId}" \
- -F "jobHeadline=${jobHeadline}" \
- -F "commitId=${headCommitId}" \
- -F "badgeLabel=${badgeLabel}" \
- -F "keepOldAnalyses=${keepOldAnalyses}" \
- -F "db=@${analysisOutputDir}/PROJECT.ecd" \
- >"${updateLog}"
- ;;
-auto_pull_request)
- curl -sS "${eclairReportUrlPrefix}/ext/update_pull_request" \
- -F "wtoken=${wtoken}" \
- -F "artifactsDir=${artifactsDir}" \
- -F "subDir=${subDir}" \
- -F "jobId=${jobId}" \
- -F "jobHeadline=${jobHeadline}" \
- -F "baseCommitId=${baseCommitId}" \
- -F "keepOldAnalyses=${keepOldAnalyses}" \
- -F "db=@${analysisOutputDir}/PROJECT.ecd" \
- >"${updateLog}"
- ;;
-*)
- echo "Unexpected event ${event}" >&2
- exit 1
- ;;
-esac
-
-ex=0
-grep -Fq "unfixedReports: " "${updateLog}" || ex=$?
-maybe_log_file_exit PUBLISH_RESULT "Publishing results" "${updateLog}" "${ex}"
-
-summary
-
-if is_enabled "${ENABLE_ECLAIR_BOT:-}"; then
- case ${ci} in
- github)
- ex=0
- gh api \
- --method POST \
- "/repos/${repository}/commits/${headCommitId}/comments" \
- -F "body=@${summaryTxt}" \
- --silent >"${commentLog}" 2>&1 || ex=$?
- maybe_log_file_exit ADD_COMMENT "Adding comment" "${commentLog}" "${ex}"
- ;;
- gitlab)
- curl -sS --request POST \
- "${gitlabApiUrl}/projects/${CI_PROJECT_ID}/repository/commits/${CI_COMMIT_SHA}/comments" \
- -H "PRIVATE-TOKEN: ${gitlabBotToken}" \
- -F "note=<${summaryTxt}" >"${commentLog}"
- ex=0
- grep -Fq "Unfixed reports: " "${commentLog}" || ex=$?
- maybe_log_file_exit ADD_COMMENT "Adding comment" "${commentLog}" "${ex}"
- ;;
- jenkins)
- ex=0
- curl \
- --user "${jenkinsBotUsername}:${jenkinsBotToken}" \
- --data-urlencode "description=$(cat "${summaryTxt}")" \
- --data-urlencode "Submit=Submit" \
- "${jenkinsApiUrl}job/${project}/${jobId}/submitDescription" \
- >"${commentLog}" 2>&1 || ex=$?
- curl \
- --user "${jenkinsBotUsername}:${jenkinsBotToken}" \
- --data-urlencode "description=$(cat "${summaryTxt}")" \
- --data-urlencode "Submit=Submit" \
- "${jenkinsApiUrl}job/${project}/submitDescription" \
- >"${commentLog}" 2>&1 || ex=$?
- maybe_log_file_exit ADD_COMMENT "Adding comment" "${commentLog}" "${ex}"
- ;;
- *) ;;
- esac
-fi
diff --git a/ECLAIR/action_upload_sarif.sh b/ECLAIR/action_upload_sarif.sh
deleted file mode 100755
index 60b8034..0000000
--- a/ECLAIR/action_upload_sarif.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-usage() {
- echo "Usage: $0 SARIF_FILE" >&2
- exit 2
-}
-
-[ $# -eq 1 ] || usage
-
-HERE=$( (
- cd "$(dirname "$0")"
- echo "${PWD}"
-))
-
-. "${HERE}/action.helpers"
-
-sarifFile=$1
-sarifPayload=${HERE}/sarif.gz.b64
-uploadLog=${HERE}/upload_sarif.log
-
-gzip -c "${sarifFile}" | base64 -w0 >"${sarifPayload}"
-
-ex=0
-gh api --method POST -H "Accept: application/vnd.github+json" \
- "/repos/${GITHUB_REPOSITORY}/code-scanning/sarifs" \
- -f "commit_sha=${GITHUB_SHA}" -f "ref=${GITHUB_REF}" \
- -F "sarif=@${sarifPayload}" \
- --silent >"${uploadLog}" 2>&1 || ex=$?
-maybe_log_file_exit ADD_COMMENT "Uploading SARIF" "${uploadLog}" "${ex}"
diff --git a/ECLAIR/analysis_common.ecl b/ECLAIR/analysis_common.ecl
deleted file mode 100644
index 3ff96b1..0000000
--- a/ECLAIR/analysis_common.ecl
+++ /dev/null
@@ -1,15 +0,0 @@
--project_name=getenv("ECLAIR_PROJECT_NAME")
--project_root=getenv("ECLAIR_PROJECT_ROOT")
-
--setq=data_dir,getenv("ECLAIR_DATA_DIR")
-
--enable=B.REPORT.ECB
--config=B.REPORT.ECB,output=join_paths(data_dir,"FRAME.@FRAME@.ecb")
--config=B.REPORT.ECB,preprocessed=show
--config=B.REPORT.ECB,macros=10
-
--enable=B.EXPLAIN
-
--eval_file=config.ecl
-
--reports+={hide,all_exp_external}
diff --git a/ECLAIR/analysis_final.ecl b/ECLAIR/analysis_final.ecl
deleted file mode 100644
index 6a32401..0000000
--- a/ECLAIR/analysis_final.ecl
+++ /dev/null
@@ -1 +0,0 @@
--eval_file=analysis_common.ecl
diff --git a/ECLAIR/analysis_normal.ecl b/ECLAIR/analysis_normal.ecl
deleted file mode 100644
index 6a32401..0000000
--- a/ECLAIR/analysis_normal.ecl
+++ /dev/null
@@ -1 +0,0 @@
--eval_file=analysis_common.ecl
diff --git a/ECLAIR/analyze.sh b/ECLAIR/analyze.sh
deleted file mode 100755
index bc458fc..0000000
--- a/ECLAIR/analyze.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-
-set -eu
-set -o pipefail
-
-HERE=$( (
- cd "$(dirname "$0")"
- echo "${PWD}"
-))
-
-usage() {
- echo "Usage: $0 ANALYSIS_KIND" >&2
- exit 2
-}
-
-[ $# -eq 1 ] || usage
-
-analysis_ecl=${HERE}/analysis_$1.ecl
-report_ecl=${HERE}/report_$1.ecl
-
-# shellcheck source=./eclair_settings.sh
-. "${HERE}/eclair_settings.sh"
-
-rm -rf "${ECLAIR_OUTPUT_DIR}" "${ECLAIR_DATA_DIR}"
-mkdir -p "${ECLAIR_OUTPUT_DIR}" "${ECLAIR_DATA_DIR}"
-
-../clean.sh | tee "${ECLAIR_CLEAN_LOG}"
-"${ECLAIR_PATH}eclair_env" "-eval_file='${analysis_ecl}'" -- ../build.sh | tee "${ECLAIR_BUILD_LOG}"
-
-"${ECLAIR_PATH}eclair_report" "-eval_file='${report_ecl}'" > "${ECLAIR_REPORT_LOG}"
diff --git a/ECLAIR/config.ecl b/ECLAIR/config.ecl
deleted file mode 100644
index b7449c9..0000000
--- a/ECLAIR/config.ecl
+++ /dev/null
@@ -1,14 +0,0 @@
--enable=MC3R1
-
--eval_file=gcc-x86_64-9.5.0.ecl
-
--doc="Sources in the test suite are not under MISRA compliance."
--file_tag+={external,"^Tests/.*$"}
-
--comment_selector={cppcheck_suppress_comment, "^// cppcheck-suppress.*$"}
-
--doc="cppcheck deviation comments should not be considered."
--config=MC3R1.D4.4,+ignored_comments="cppcheck_suppress_comment"
-
--doc="For documentation reasons, URLs in comments are allowed to contain //."
--config=MC3R1.R3.1,comments={url_in_comment,"!^.*(/\*|[^:]//).*$" }
diff --git a/ECLAIR/cpp.pdf b/ECLAIR/cpp.pdf
deleted file mode 100644
index 52405a8..0000000
Binary files a/ECLAIR/cpp.pdf and /dev/null differ
diff --git a/ECLAIR/eclair_settings.sh b/ECLAIR/eclair_settings.sh
deleted file mode 100755
index 1c52488..0000000
--- a/ECLAIR/eclair_settings.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-case "${ECLAIR_PATH=/opt/bugseng/eclair/bin/}" in
-*/ | "") ;;
-*)
- ECLAIR_PATH=${ECLAIR_PATH}/
- ;;
-esac
-
-export ECLAIR_PATH
-
-TOP=${HERE%/*}
-export ECLAIR_PROJECT_NAME="${TOP##*/}"
-export ECLAIR_PROJECT_ROOT="${TOP}"
-
-export ECLAIR_OUTPUT_DIR="${TOP}/ECLAIR_out"
-export ECLAIR_DATA_DIR="${HERE}/.data"
-export ECLAIR_WORKSPACE="${ECLAIR_DATA_DIR}/eclair_workspace"
-
-# Set the variable for the ECLAIR project database file.
-export ECLAIR_PROJECT_ECD="${ECLAIR_OUTPUT_DIR}/PROJECT.ecd"
-
-# Set the variable for the clean log file.
-ECLAIR_CLEAN_LOG=${ECLAIR_OUTPUT_DIR}/CLEAN.log
-
-# Set the variable for the build log file.
-ECLAIR_BUILD_LOG=${ECLAIR_OUTPUT_DIR}/BUILD.log
-
-# NEEDED: set the variable for the ECLAIR analysis log absolute file path.
-ECLAIR_ANALYSIS_LOG=${ECLAIR_OUTPUT_DIR}/ANALYSIS.log
-
-# Set the variable for the ECLAIR report log file.
-ECLAIR_REPORT_LOG=${ECLAIR_OUTPUT_DIR}/REPORT.log
-
-export ECLAIR_REPORTS_SARIF="${ECLAIR_OUTPUT_DIR}/reports.sarif"
-
-export ECLAIR_DIAGNOSTICS_OUTPUT="${ECLAIR_ANALYSIS_LOG}"
-
-export CC_ALIASES="gcc"
-#export AS_ALIASES="as"
-#export AR_ALIASES="ar"
-#export LD_ALIASES="ld"
diff --git a/ECLAIR/gcc-x86_64-9.5.0.ecl b/ECLAIR/gcc-x86_64-9.5.0.ecl
deleted file mode 100644
index 2f780fc..0000000
--- a/ECLAIR/gcc-x86_64-9.5.0.ecl
+++ /dev/null
@@ -1,37 +0,0 @@
--file_tag+={GCC9,"^/usr/bin/x86_64-linux-gnu-gcc-9$"}
-
--doc="See Section 4.1 (page 443) of gcc.pdf."
--config=STD.diagidnt,behavior={c99, GCC9, "specified"}
-
--doc="See Section 4.4 (page 444) of gcc.pdf and Section 3.1.2 (page 11) of x86_64-abi-0.99.pdf."
--config=STD.bytebits,behavior={c99, GCC9, "8"}
-
--doc="See Section 4.4 (page 444) of gcc.pdf and the documentation of -fexec-charset=charset and -finput-charset=charset (page 206) in the same manual."
--config=STD.charsmem,behavior={c99, GCC9, "ascii"}
-
--doc="See Section 4.4 (page 444) of gcc.pdf and the documentation of -fexec-charset=charset (page 206) in the same manual."
--config=STD.execvals,behavior={c99, GCC9, "specified"}
-
--doc="See Section 4.4 (page 444) of gcc.pdf and the documentation of -fexec-charset=charset and -finput-charset=charset (page 206) of the same manual."
--config=STD.charsmap,behavior={c99, GCC9, "specified"}
-
--doc="See Section 4.4 (page 444) of gcc.pdf and the documentation of -fexec-charset=charset and -finput-charset=charset (page 206) in the same manual."
--config=STD.charsmem,behavior={c99, GCC9, "ascii"}
-
--doc="See Section 4.5 (page 445) of gcc.pdf."
--config=STD.signdint,behavior={c99, GCC9, "specified"}
-
--doc="See Section 4.15 (page 450) of gcc.pdf and Section 3.1.2 (page 11 and following) of x86_64-abi-0.99.pdf."
--config=STD.objbytes,behavior={c99, GCC9, "specified"}
-
--doc_begin="See Section 2 (page 7 and following) of cpp.pdf."
--config=STD.inclangl,behavior={c99, GCC9, "specified"}
--config=STD.inclfile,behavior={c99, GCC9, "specified"}
--config=STD.inclhead,behavior={c99, GCC9, "specified"}
--doc_end
-
--doc="See Section 3 (page 13 and following) of cpp.pdf."
--config=STD.stdmacro,behavior={c99, GCC9, "specified"}
-
--doc="See Section 25.7 (page 784 and following of libc.pdf."
--config=STD.exitstat,behavior={c99, GCC9, "specified"}
diff --git a/ECLAIR/gcc.pdf b/ECLAIR/gcc.pdf
deleted file mode 100644
index 94e8e82..0000000
Binary files a/ECLAIR/gcc.pdf and /dev/null differ
diff --git a/ECLAIR/libc.pdf b/ECLAIR/libc.pdf
deleted file mode 100644
index c652ac9..0000000
Binary files a/ECLAIR/libc.pdf and /dev/null differ
diff --git a/ECLAIR/report_common.ecl b/ECLAIR/report_common.ecl
deleted file mode 100644
index 8efcafd..0000000
--- a/ECLAIR/report_common.ecl
+++ /dev/null
@@ -1,18 +0,0 @@
-# eclair_report
-
-quiet()
-
-setq(data_dir,getenv("ECLAIR_DATA_DIR"))
-setq(output_dir,getenv("ECLAIR_OUTPUT_DIR"))
-setq(ecd_file,getenv("ECLAIR_PROJECT_ECD"))
-setq(sarif_file,getenv("ECLAIR_REPORTS_SARIF"))
-
-create_db(ecd_file)
-loading()
-strings_map("load_ecb",500,"",".+\\.ecb",0,setq(ecb,join_paths(data_dir,$0)),load(ecb))
-strings_map("load_ecb",500,"",".*",0)
-map_strings("load_ecb", dir_entries(data_dir))
-loaded()
-
-#reports
-reports_sarif(sarif_file)
diff --git a/ECLAIR/report_final.ecl b/ECLAIR/report_final.ecl
deleted file mode 100644
index 538d08a..0000000
--- a/ECLAIR/report_final.ecl
+++ /dev/null
@@ -1,17 +0,0 @@
-# eclair_report
-
--eval_file=report_common.ecl
-
-# Full output in pure text format.
-full_txt(join_paths(output_dir,"txt"))
-# Output metrics for use with spreadsheet applications (if enabled).
-metrics_tab(join_paths(output_dir,"metrics"))
-# Output reports for use with spreadsheet applications
-reports_tab(join_paths(output_dir,"reports"))
-
-# Show only first area in reports
-first_area()
-# Full output in ODT format.
-full_odt(join_paths(output_dir,"odt"))
-# Full output in ODT format.
-full_doc(join_paths(output_dir,"doc"))
diff --git a/ECLAIR/report_normal.ecl b/ECLAIR/report_normal.ecl
deleted file mode 100644
index ebc61f6..0000000
--- a/ECLAIR/report_normal.ecl
+++ /dev/null
@@ -1,3 +0,0 @@
-# eclair_report
-
--eval_file=report_common.ecl
diff --git a/ECLAIR/x86_64-abi-0.99.pdf b/ECLAIR/x86_64-abi-0.99.pdf
deleted file mode 100644
index 91747c3..0000000
Binary files a/ECLAIR/x86_64-abi-0.99.pdf and /dev/null differ
diff --git a/Inc/misra_c_2012_doc.h b/Inc/misra_c_2012_doc.h
index 814f5a0..d477e09 100644
--- a/Inc/misra_c_2012_doc.h
+++ b/Inc/misra_c_2012_doc.h
@@ -29,14 +29,11 @@ to be executed from interrupt handlers, or in multi-threading environments.
Documentation for MISRA C:2012 Dir 4.1: read from uninitialized automatic object
--------------------------------------------------------------------------------
-Automatic objects are always initialized before their usage. ECLAIR is used for
-MISRA rules verification, and there is no violations nor cautions regarding 9.1
-rule.
+Automatic objects are always initialized before their usage.
Documentation for MISRA C:2012 Dir 4.1: read from uninitialized allocated object
--------------------------------------------------------------------------------
-Allocated objects are not used in the code. ECLAIR is used for MISRA rules
-verification, and there is no violations nor cautions regarding 21.3 rule.
+Allocated objects are not used in the code.
Documentation for MISRA C:2012 Dir 4.1: write to string literal or const object
-------------------------------------------------------------------------------
@@ -50,8 +47,7 @@ Non-volatile access to volatile object is not used in the project.
Documentation for MISRA C:2012 Dir 4.1: access to dead allocated object
-----------------------------------------------------------------------
-Allocated objects are not used in the code. ECLAIR is used for MISRA rules
-verification, and there is no violations nor cautions regarding 21.3 rule.
+Allocated objects are not used in the code.
Documentation for MISRA C:2012 Dir 4.1: access to dead automatic object
-----------------------------------------------------------------------
diff --git a/Inc/typedefs.h b/Inc/typedefs.h
index 44fc8de..2198e79 100644
--- a/Inc/typedefs.h
+++ b/Inc/typedefs.h
@@ -44,7 +44,6 @@ typedef float float32_t;
typedef double float64_t;
typedef long double float128_t;
-/* -E> compliant MC3R1.D4.6 2 Type byte_t shall be used everywhere where a pointer to bytes is needed to follow Strict Aliasing Rule */
// More on the topic can be found here: https://gist.github.com/jibsen/da6be27cde4d526ee564
typedef unsigned char byte_t;
diff --git a/README.md b/README.md
index d494fc6..acc2a52 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,14 @@
-
-
-
-
-[](https://eclairit.com:3787/fs/var/local/eclair/github/IMProject/IMUtility.ecdf/ECLAIR_normal/main/latest/index.html)
-
-[Browse all ECLAIR analyses](https://eclairit.com:3787/fs/var/local/eclair/github/IMProject/IMUtility.ecdf/)
-
+# IMUtility: A Safety-Critical Utility Code
[](https://discord.gg/R6nZxZqDH3)
[](https://github.com/IMProject/IMUtility/actions/workflows/compile.yml?query=branch%3Amain) [](https://github.com/IMProject/IMUtility/actions/workflows/checks.yml?query=branch%3Amain)
[](https://codecov.io/gh/IMProject/IMUtility)
-
-# IMUtility: A Safety-Critical Utility Code
-
## About
The IMUtility (Incorporated MISRA Utility Code) originated as a sub-repository of the [IMBootloader](https://github.com/IMProject/IMBootloader) project. After a thorough review of the available safety-critical utility open-source projects in C, we realized that none of them met our standards. Therefore, we made the decision to create our own project and make it publicly available.
-Our team has meticulously laid the foundation for everything necessary to ensure the code meets the rigorous standards required for safety-critical applications. Presently, we have incorporated unit tests using the [Unity](https://github.com/ThrowTheSwitch/Unity) framework, code coverage using gcov/lcov, ensured code style conformance through Astyle formatting, and implemented cppcheck with all checks enabled. Additionally, we have enforced MISRA C 2012 checks using both cppcheck and [ECLAIR](https://www.bugseng.com/eclair), sponsored by Bugseng.
+Our team has meticulously laid the foundation for everything necessary to ensure the code meets the rigorous standards required for safety-critical applications. Presently, we have incorporated unit tests using the [Unity](https://github.com/ThrowTheSwitch/Unity) framework, code coverage using gcov/lcov, ensured code style conformance through Astyle formatting, and implemented cppcheck with all checks enabled. Additionally, we have enforced MISRA C 2012 checks using both cppcheck and [ECLAIR](https://www.bugseng.com/eclair), sponsored by Bugseng (last [commit](https://github.com/IMProject/IMUtility/commit/08e8e444b3115841e9084212b718e94ecda3604b) with ECLAIR analysis).
However, to further enhance the project's quality, we intend to achieve 100% coverage where feasible. This will serve as an additional layer of assurance that the code is of the highest quality and complies with safety-critical standards.
@@ -43,8 +33,7 @@ Before you open PR:
- run `make cppcheck`
- run `make misra`
-After PR is opened, ECLAIR will check your code and Bot will report if any MISRA violation exists in the code.
-After all violations are fixed, we will review your code, and after that code can be merged into the main branch.
+After PR is opened, we will review your code, and after that code can be merged into the main branch.
#### Discord
Join us on the Discord channel https://discord.gg/R6nZxZqDH3
diff --git a/Src/bit_manipulation.c b/Src/bit_manipulation.c
index 34e3ff1..89241bd 100644
--- a/Src/bit_manipulation.c
+++ b/Src/bit_manipulation.c
@@ -49,7 +49,6 @@ BitManipulation_reflect(uint32_t data, uint8_t n_bits) {
* If the LSB bit is set, set the reflection of it.
*/
if (1u == (temp_data & 1u) ) {
- /* -E> compliant MC3R1.R12.2 1 The shift count is granted to be between 0 and 31 due to bit masking. */
reflection |= (uint32_t)((uint32_t)1U << (0x1FU & ((n_bits - 1U) - bit)));
}
@@ -63,7 +62,6 @@ bool
BitManipulation_bitSet(uint32_t data, uint8_t n, bool* bit_set) {
bool status = false;
if (n <= MAX_BIT_SHIFT) {
- /* -E> compliant MC3R1.R12.2 1 Right hand operand of shift expression is between 0 and 31 due to previous IF statement. */
uint32_t temp = (uint32_t)1U << n;
*bit_set = ((data & temp) != 0U);
status = true;
@@ -75,7 +73,6 @@ bool
BitManipulation_setBit(uint32_t data, uint8_t n, uint32_t* out) {
bool status = false;
if (n <= MAX_BIT_SHIFT) {
- /* -E> compliant MC3R1.R12.2 1 Right hand operand of shift expression is between 0 and 31 due to previous IF statement. */
*out = (data | ((uint32_t)1U << n));
status = true;
}
@@ -86,7 +83,6 @@ bool
BitManipulation_clearBit(uint32_t data, uint8_t n, uint32_t* out) {
bool status = false;
if (n <= MAX_BIT_SHIFT) {
- /* -E> compliant MC3R1.R12.2 1 Right hand operand of shift expression is between 0 and 31 due to previous IF statement. */
*out = (data & (~((uint32_t)1U << n)));
status = true;
}
@@ -97,7 +93,6 @@ bool
BitManipulation_toggleBit(uint32_t data, uint8_t n, uint32_t* out) {
bool status = false;
if (n <= MAX_BIT_SHIFT) {
- /* -E> compliant MC3R1.R12.2 1 Right hand operand of shift expression is between 0 and 31 due to previous IF statement. */
*out = (data ^ ((uint32_t)1U << n));
status = true;
}
@@ -106,7 +101,5 @@ BitManipulation_toggleBit(uint32_t data, uint8_t n, uint32_t* out) {
uint32_t
BitManipulation_rotl32(uint32_t data, uint32_t n_bits) {
-
- /* -E> hide MC3R1.R12.2 1 To optimize efficiency, we do not verify whether n_bits is between 0 and 31. */
return ((data << n_bits) ^ (data >> (32U - n_bits)));
}
diff --git a/Src/crypto/chacha20.c b/Src/crypto/chacha20.c
index c4bd544..8caa63f 100644
--- a/Src/crypto/chacha20.c
+++ b/Src/crypto/chacha20.c
@@ -122,7 +122,6 @@ Block(const byte_t key[CHACHA20_KEY_SIZE], uint32_t counter, const byte_t nonce[
x14 += Utils_deserialize32LE(&nonce[4]);
x15 += Utils_deserialize32LE(&nonce[8]);
- /* -E> compliant MC3R1.R18.6 16 automatic storage pointed with "out" is not copied to values from this function */
Utils_serialize32LE(&out[0], x0);
Utils_serialize32LE(&out[4], x1);
Utils_serialize32LE(&out[8], x2);
diff --git a/Src/json.c b/Src/json.c
index 24c84b2..df8a23f 100644
--- a/Src/json.c
+++ b/Src/json.c
@@ -69,14 +69,12 @@ Json_addData(char* buffer, size_t buffer_size, const char* key, const char* valu
strcpy(&buffer[index], "\"");
index += strlen("\"");
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
- /* -E> compliant MC3R1.R19.1 1 Overlap will not happen because of the check in if statement. */
strcpy(&buffer[index], key);
index += strlen(key);
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
strcpy(&buffer[index], "\":\"");
index += strlen("\":\"");
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
- /* -E> compliant MC3R1.R19.1 1 Overlap will not happen because of the check in if statement. */
strcpy(&buffer[index], value);
index += strlen(value);
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
@@ -116,8 +114,6 @@ Json_findByKey(const char* buffer, size_t buffer_size, const char* key, char* va
for (index = 0U; index < max_search_size; ++index) {
- /* -E> compliant MC3R1.R21.18 2 strncmp is guarded in for loop condition to not go out of buffer boundaries
- by calculating max_search_size from buffer size and key size */
if (0 == strncmp(&buffer[index], key, key_size)) {
if (buffer[index + key_size] == '"') {
diff --git a/Src/map.c b/Src/map.c
index ce59322..628aab3 100644
--- a/Src/map.c
+++ b/Src/map.c
@@ -42,7 +42,6 @@ static int32_t
GetIndex(const Map_t* map, const byte_t* key, int32_t size) {
int32_t index = INDEX_NOT_FOUND;
for (int32_t i = 0; i < size; ++i) {
- /* -E> compliant MC3R1.R21.18 1 map->key_size is a size of the key in the map and it has appropriate value. */
if (memcmp(&map->keys[i * map->key_size], key, (size_t)map->key_size) == 0) {
index = i;
break;
@@ -74,23 +73,14 @@ Map_insert(Map_t* map, const byte_t* key, const byte_t* value) {
int32_t index = GetIndex(map, key, map->current_size);
if (index == INDEX_NOT_FOUND) {
if (map->current_size != map->max_map_size) {
- /* -E> compliant MC3R1.R21.18 4 map->key_size is a size of the key in the map and it has appropriate value. */
- /* -E> compliant MC3R1.R19.1 3 Overlap will not happen because there is a check if current map size reached
- * max map size. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&map->keys[map->current_size * map->key_size], key, (size_t)map->key_size);
- /* -E> compliant MC3R1.R21.18 4 map->value_size is a size of the value in the map and it has appropriate value. */
- /* -E> compliant MC3R1.R19.1 3 Overlap will not happen because there is a check if current map size reached
- * max map size. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&map->values[map->current_size * map->value_size], value, (size_t)map->value_size);
++map->current_size;
status = true;
}
} else {
- /* -E> compliant MC3R1.R21.18 4 map->value_size is a size of the value in the map and it has appropriate value. */
- /* -E> compliant MC3R1.R19.1 3 Overlap will not happen since the current key is the same as the key that is
- * previously inserted in the map. Therefore, new value will be mapped to that key. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&map->values[index * map->value_size], value, (size_t)map->value_size);
status = true;
@@ -105,9 +95,6 @@ Map_getValue(const Map_t* map, const byte_t* key, byte_t* value) {
if (map != NULL_PTR) {
int32_t index = GetIndex(map, key, map->current_size);
if (index != INDEX_NOT_FOUND) {
- /* -E> compliant MC3R1.R21.18 4 map->value_size is a size of the value in the map and it has appropriate value. */
- /* -E> compliant MC3R1.R19.1 3 Overlap will not happen because the map->value_size is the size of the value
- * and every element in map->values has that size */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(value, &map->values[index * map->value_size], (size_t)map->value_size);
status = true;
diff --git a/Src/priority_queue.c b/Src/priority_queue.c
index 0b5ddd5..396303a 100644
--- a/Src/priority_queue.c
+++ b/Src/priority_queue.c
@@ -96,8 +96,6 @@ PriorityQueue_enqueue(PriorityQueue_t* queue, const PriorityQueueItem_t* item) {
bool status = false;
if (!Full(queue)) {
uint8_t* buffer = queue->buffer;
- /* -E> compliant MC3R1.R21.18 3 Buffer overflow will not happen, there is a guard that checks that priority
- * queue is not full. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&buffer[queue->size * queue->element_size], item->element, queue->element_size);
queue->priority_array[queue->size] = *(item->priority);
@@ -111,17 +109,11 @@ PriorityQueue_enqueue(PriorityQueue_t* queue, const PriorityQueueItem_t* item) {
queue->size = queue->size - 1U;
const uint32_t current_size = queue->size;
for (uint32_t i = lowest_priority_index; i < current_size; ++i) {
- /* -E> compliant MC3R1.R19.1 4 Overlap will not happen because iteration will be performed until current
- * queue size is reached which is previous size - 1. Therefore, last valid element that will be used in
- * memcpy function is placed in current size + 1. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&buffer[i * queue->element_size], &buffer[(i * queue->element_size) + queue->element_size],
queue->element_size);
queue->priority_array[i] = queue->priority_array[i + 1U];
}
- /* -E> compliant MC3R1.R21.18 4 Buffer overflow will not happen, there will be one more place in buffer to
- * insert a new element because of removing element with the lowest priority (performed in the above code,
- * in the same function). */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&buffer[queue->size * queue->element_size], item->element, queue->element_size);
queue->priority_array[queue->size] = *(item->priority);
@@ -138,16 +130,11 @@ PriorityQueue_dequeue(PriorityQueue_t* queue, uint8_t* element) {
status = true;
uint32_t highest_priority_index = GetHighestPriorityIndex(queue);
uint8_t* buffer = queue->buffer;
- /* -E> compliant MC3R1.R21.18 3 Buffer overflow will not happen, element has same size as one element
- * in buffer, and their size is stored in element_size member. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(element, &buffer[highest_priority_index * queue->element_size], queue->element_size);
queue->size = queue->size - 1U;
const uint32_t current_size = queue->size;
for (uint32_t i = highest_priority_index; i < current_size; ++i) {
- /* -E> compliant MC3R1.R19.1 4 Overlap will not happen because iteration will be performed until current
- * queue size is reached which is previous size - 1. Therefore, last valid element that will be used in
- * memcpy function is placed in current size + 1. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&buffer[i * queue->element_size], &buffer[(i * queue->element_size) + queue->element_size],
queue->element_size);
diff --git a/Src/queue.c b/Src/queue.c
index 8f4d7f5..789f42e 100644
--- a/Src/queue.c
+++ b/Src/queue.c
@@ -67,9 +67,6 @@ Queue_enqueue(Queue_t* queue, const uint8_t* element) {
if ((queue != NULL_PTR) && (element != NULL_PTR)) {
if (!Queue_full(queue)) {
uint8_t* buffer = queue->buffer;
- /* -E> compliant MC3R1.R21.18 4 Buffer overflow will not happen, element has same size as one element
- * in buffer, and their size is stored in element_size member. Also, there is a guard that checks that
- * queue is not full. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&buffer[((queue->rear + 1U) % queue->capacity) * queue->element_size], element, queue->element_size);
queue->rear = (queue->rear + 1U) % queue->capacity;
@@ -86,8 +83,6 @@ Queue_dequeue(Queue_t* queue, uint8_t* element) {
if ((queue != NULL_PTR) && (element != NULL_PTR)) {
if (!Queue_empty(queue)) {
const uint8_t* buffer = (const uint8_t*)queue->buffer;
- /* -E> compliant MC3R1.R21.18 3 Buffer overflow will not happen, element has same size as one element
- * in buffer, and their size is stored in element_size member. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(element, &buffer[queue->front * queue->element_size], queue->element_size);
queue->front = (queue->front + 1U) % queue->capacity;
@@ -104,8 +99,6 @@ Queue_front(const Queue_t* queue, uint8_t* element) {
if ((queue != NULL_PTR) && (element != NULL_PTR)) {
if (!Queue_empty(queue)) {
const uint8_t* buffer = (const uint8_t*)queue->buffer;
- /* -E> compliant MC3R1.R21.18 3 Buffer overflow will not happen, element has same size as one element
- * in buffer, and their size is stored in element_size member. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(element, &buffer[queue->front * queue->element_size], queue->element_size);
status = true;
@@ -120,8 +113,6 @@ Queue_rear(const Queue_t* queue, uint8_t* element) {
if ((queue != NULL_PTR) && (element != NULL_PTR)) {
if (!Queue_empty(queue)) {
const uint8_t* buffer = (const uint8_t*)queue->buffer;
- /* -E> compliant MC3R1.R21.18 3 Buffer overflow will not happen, element has same size as one element
- * in buffer, and their size is stored in element_size member. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(element, &buffer[queue->rear * queue->element_size], queue->element_size);
status = true;
diff --git a/Src/sort/insertion_sort.c b/Src/sort/insertion_sort.c
index 8bd4dcc..5c26c7a 100644
--- a/Src/sort/insertion_sort.c
+++ b/Src/sort/insertion_sort.c
@@ -44,9 +44,6 @@ InsertionSort_sort(byte_t* buffer, int32_t number_of_elements, int32_t element_s
byte_t* element = &max_element[0];
for (int32_t i = 1; i < number_of_elements; ++i) {
- /* -E> compliant MC3R1.R21.18 4 Buffer overflow will not happen, all elements in buffer
- * have same size, and their size is stored in element_size variable. Precondition is that
- * element_size must be less than or equal to MAX_ELEMENT_SIZE. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(element, &elements[i * element_size], (size_t)element_size);
@@ -54,16 +51,11 @@ InsertionSort_sort(byte_t* buffer, int32_t number_of_elements, int32_t element_s
bool compare = compareFun(&elements[j * element_size], element);
while ((j >= 0) && compare) {
- /* -E> compliant MC3R1.R19.1 3 Overlap will not happen, all elements in buffer
- * have same size, and their size is stored in element_size variable. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&elements[(j + 1) * element_size], &elements[j * element_size], (size_t)element_size);
--j;
compare = compareFun(&elements[j * element_size], element);
}
- /* -E> compliant MC3R1.R21.18 4 Buffer overflow will not happen, all elements in buffer
- * have same size, and their size is stored in element_size variable. Precondition is that
- * element_size must be less than or equal to MAX_ELEMENT_SIZE. */
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
memcpy(&elements[(j + 1) * element_size], element, (size_t)element_size);
}