diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d639c71ceb0a0528f1a06d01c0a089cebf0b2229..1ad216d9eae807d5029631bbbe234f2b9fdc19fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -417,6 +417,49 @@ evs-pytest-on-merge-request: junit: - report-junit-evs.xml +clang-format-check: + extends: + - .test-job-linux + - .rules-merge-request + variables: + ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix" + stage: validate + needs: [] + timeout: "5 minutes" + script: + # Set up variables. This can't be done in the "variables" section because variables are not expanded properly there + - PATCH_FILE_NAME="$ARTIFACT_BASE_NAME".patch + - > + INSTRUCTIONS_GITLAB="To fix formatting issues:\n + - download the diff patch available as artifact of this job\n + - unzip the artifact and place the patch file in the root directory of your local IVAS repo\n + - run: git apply $PATCH_FILE_NAME\n + - commit new changes" + - > + INSTRUCTIONS_README="To fix formatting issues:\n + - place the patch file in the root directory of your local IVAS repo\n + - run: git apply $PATCH_FILE_NAME\n + - commit new changes" + + - scripts/check-format.sh -af -p 8 || format_problems=$? + - if [ $format_problems == 0 ] ; then exit 0; fi + + - mkdir tmp-formatting-fix + - git diff > "tmp-formatting-fix/$PATCH_FILE_NAME" + + # Print instructions to job output + - echo -e "$INSTRUCTIONS_GITLAB" + + # Include readme in the artifact, in case someone misses the job printout (e.g. getting the artifact via MR interface) + - echo -e "$INSTRUCTIONS_README" > "tmp-formatting-fix/readme.txt" + + - exit $format_problems + artifacts: + paths: + - tmp-formatting-fix/ + when: on_failure + name: "$ARTIFACT_BASE_NAME" + expose_as: 'formatting patch' # --------------------------------------------------------------- # Test jobs for main branch diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 5c189b7d32d08ae33d4975fc180a3636198d1d8e..1d98e39e2b2b3651d02b792bfeb93bcc91d47004 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -206,7 +206,8 @@ ivas_error ivas_core_dec( { float gain; - gain = ( st->element_mode == IVAS_CPE_MDCT ) ? st->hTcxDec->conceal_eof_gain : ( st->hPlcInfo != NULL ) ? st->hPlcInfo->recovery_gain : 0.0f; + gain = ( st->element_mode == IVAS_CPE_MDCT ) ? st->hTcxDec->conceal_eof_gain : ( st->hPlcInfo != NULL ) ? st->hPlcInfo->recovery_gain + : 0.0f; if ( ( st->element_mode == IVAS_CPE_MDCT && hMCT == NULL ) || ( st->hPlcInfo != NULL ) ) { diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 8e56ed5ef78e8f53b9d5900e76858573414a9526..54af577fd14bbf8831c857707352d70fa43bcc9f 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -835,7 +835,7 @@ static void dec_prm_tcx( #ifdef FIX_TCX_DEC_RECONF_BFI const int16_t last_element_mode, #endif - int16_t *bitsRead /* o : number of read bits */ + int16_t *bitsRead /* o : number of read bits */ ) { int16_t start_bit_pos, bits_common; @@ -963,8 +963,7 @@ static void dec_prm_tcx( static void stereo_tcx_dec_mode_switch_reconf( Decoder_State *st, const int16_t MCT_flag, - const int16_t last_element_mode -) + const int16_t last_element_mode ) { int16_t frame_size_index; diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index aca565b64d04c40b11683d6f61feabad2b458820..d987b41d51f40535f125f6d7693cbacbd7842ef4 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -150,8 +150,8 @@ ivas_error ivas_sba_enc_reinit( ind_list_metadata = hMetaData->ind_list; /*------------------------------------------------------------------------------------------* - * Closing Encoder handles before Reinitialisation - *------------------------------------------------------------------------------------------*/ + * Closing Encoder handles before Reinitialisation + *------------------------------------------------------------------------------------------*/ /* Q Metadata handle */ ivas_qmetadata_close( &( st_ivas->hQMetaData ) ); @@ -208,8 +208,8 @@ ivas_error ivas_sba_enc_reinit( } /*------------------------------------------------------------------------------------------* - * Reopening Encoder handles for Reinitialisation - *------------------------------------------------------------------------------------------*/ + * Reopening Encoder handles for Reinitialisation + *------------------------------------------------------------------------------------------*/ if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { diff --git a/scripts/check-format.sh b/scripts/check-format.sh index 1302b5e03df82084b9a2b003b6a14e5e586f5b7a..f372403115cf960365071fae3c74bd6c3b029229 100755 --- a/scripts/check-format.sh +++ b/scripts/check-format.sh @@ -62,7 +62,7 @@ EOM } cl-format-check-version() { - ${CLANG_FORMAT} --version | awk '{print $3}' + ${CLANG_FORMAT} --version | sed 's/.*version \([1-9]*\.[0-9]*\).*/\1/' } cl-format-apply() { @@ -229,7 +229,7 @@ else rm "$NUMFAILSTMPFILE" if [[ $NUMFAILS -gt 0 ]]; then echo "Total fails: $NUMFAILS" -# exit $NUMFAILS ## uncomment if script should have num fails as return code + exit $NUMFAILS ## uncomment if script should have num fails as return code fi fi