Skip to content

Remove unreachable return statements after avm_internal_error calls. #5016

Draft
urvangjoshi wants to merge 3 commits into
AOMediaCodec:mainfrom
urvangjoshi:clang_build_fix
Draft

Remove unreachable return statements after avm_internal_error calls. #5016
urvangjoshi wants to merge 3 commits into
AOMediaCodec:mainfrom
urvangjoshi:clang_build_fix

Conversation

@urvangjoshi
Copy link
Copy Markdown
Contributor

This fixes following type of build errors on LLVM 22.1.6:

error: 'return' will never be executed [-Werror,-Wunreachable-code-return]

Related: Ensure that setjmp is called before avm_internal_error in FilmGrainTableIOTest.

Closes #5002

Comment thread av2/av2_cx_iface.c
AV2_COMMON *cm = &ctx->cpi->common;
avm_internal_error(&cm->error, AVM_CODEC_INVALID_PARAM,
"Incorrect buffer dimensions");
return cm->error.error_code;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

avm_internal_error() calls longjmp() only when setjmp() has been called. That is not the case here.

We should also verify setjmp() has been called in the other changes in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. There seem to be a few places in this file and also av2_dx_iface.c where setjmp has not been called.
Are you suggesting to add setjmp to those places?

Note that the clang is reporting these error likely because of how avm_internal_error() function is declared:

#define CLANG_ANALYZER_NORETURN                                                                                                                                                      
#if defined(__has_feature)                                                                                                                                                           
#if __has_feature(attribute_analyzer_noreturn)                                                                                                                                       
#undef CLANG_ANALYZER_NORETURN                                                                                                                                                       
#define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn))                                                                                                                   
#endif                                                                                                                                                                               
#endif                                                                                                                                                                               
                                                                                                                                                                                     
void avm_internal_error(struct avm_internal_error_info *info,
....

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In av2_cx_iface.c and av2_dx_iface.c we can delete the avm_internal_error() call and return the error code directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. I checked that most of the code in these files doesn't use avm_internal_error, so keeping only return statements instead is also consistent.
PTAL.

@urvangjoshi urvangjoshi force-pushed the clang_build_fix branch 2 times, most recently from ade92da to 16265dc Compare June 3, 2026 18:42
This fixes following type of build errors on LLVM 22.1.6:

```
error: 'return' will never be executed [-Werror,-Wunreachable-code-return]
```
Comment thread av2/common/ccso.c
@@ -374,13 +374,11 @@ void av2_apply_ccso_filter_for_row(AV2_COMMON *cm, MACROBLOCKD *xd,
avm_internal_error(
&cm->error, AVM_CODEC_ERROR,
"Invalid BRU activity in CCSO: only active SB can be filtered");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The av2_apply_ccso_filter_for_row() function may be called transitively by ccso_row_worker(), which does not call setjmp().

Comment thread av2/common/reconinter.c
@@ -1972,7 +1972,6 @@ void av2_build_one_bawp_inter_predictor(
avm_internal_error(
(struct avm_internal_error_info *)&cm->error, AVM_CODEC_ERROR,
"Inter BAWP template cannot outside the valid reference range");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

av2_build_one_bawp_inter_predictor() may be called transitively by enc_row_mt_worker_hook(), which does not call setjmp().

Note that libaom handles this correctly. We can port libaom's changes to the AVM.

Comment thread av2/av2_cx_iface.c
AV2_COMMON *cm = &ctx->cpi->common;
avm_internal_error(&cm->error, AVM_CODEC_INVALID_PARAM,
"Incorrect buffer dimensions");
return cm->error.error_code;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest we move the changes to av2/av2_cx_iface.c and av2/av2_dx_iface.c to a separate PR so that they can be reviewed and merged first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea! Moved to this PR: #5028

Marking this PR as Draft as I check about setjmp for other places.

@urvangjoshi urvangjoshi marked this pull request as draft June 3, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unreachable-code-return compile errors with LLVM 22.1.6

3 participants