From 48d9363fa747a7550c9d263cccc412148c594fc9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 10 Feb 2023 11:10:31 +1100 Subject: [PATCH] Cleanup: quiet clang compiler warnings - undeclared variable warning. - unreachable-code-return warnings. - array-parameter, mismatch bound. - 'requires' is a keyword in C++20, (rename to requires_flag). --- source/blender/blenkernel/BKE_fcurve.h | 2 +- source/blender/blenkernel/intern/fmodifier.c | 18 +++++++++--------- .../blender/blenlib/intern/lazy_threading.cc | 2 +- .../blender/editors/animation/fmodifier_ui.c | 4 ++-- source/blender/editors/asset/ED_asset_handle.h | 7 +++++-- source/blender/imbuf/intern/iris.c | 8 +++++--- source/creator/creator.c | 6 +++++- source/creator/creator_args.c | 3 +++ 8 files changed, 31 insertions(+), 19 deletions(-) diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index cdade9209b6..62b80a627bb 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -63,7 +63,7 @@ typedef struct FModifierTypeInfo { /** #eFMI_Action_Types. */ short acttype; /** #eFMI_Requirement_Flags. */ - short requires; + short requires_flag; /** name of modifier in interface. */ char name[64]; /** name of struct for SDNA. */ diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 46828a43818..ae9b0f5e558 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -64,7 +64,7 @@ static FModifierTypeInfo FMI_MODNAME = { /*type*/ FMODIFIER_TYPE_MODNAME, /*size*/ sizeof(FMod_ModName), /*acttype*/ FMI_TYPE_SOME_ACTION, - /*requires*/ FMI_REQUIRES_SOME_REQUIREMENT, + /*requires_flag*/ FMI_REQUIRES_SOME_REQUIREMENT, /*name*/ "Modifier Name", /*structName*/ "FMod_ModName", /*storage_size*/ 0, @@ -228,7 +228,7 @@ static FModifierTypeInfo FMI_GENERATOR = { /*type*/ FMODIFIER_TYPE_GENERATOR, /*size*/ sizeof(FMod_Generator), /*acttype*/ FMI_TYPE_GENERATE_CURVE, - /*requires*/ FMI_REQUIRES_NOTHING, + /*requires_flag*/ FMI_REQUIRES_NOTHING, /*name*/ N_("Generator"), /*structName*/ "FMod_Generator", /*storage_size*/ 0, @@ -358,7 +358,7 @@ static FModifierTypeInfo FMI_FN_GENERATOR = { /*type*/ FMODIFIER_TYPE_FN_GENERATOR, /*size*/ sizeof(FMod_FunctionGenerator), /*acttype*/ FMI_TYPE_GENERATE_CURVE, - /*requires*/ FMI_REQUIRES_NOTHING, + /*requires_flag*/ FMI_REQUIRES_NOTHING, /*name*/ N_("Built-In Function"), /*structName*/ "FMod_FunctionGenerator", /*storage_size*/ 0, @@ -471,7 +471,7 @@ static FModifierTypeInfo FMI_ENVELOPE = { /*type*/ FMODIFIER_TYPE_ENVELOPE, /*size*/ sizeof(FMod_Envelope), /*acttype*/ FMI_TYPE_REPLACE_VALUES, - /*requires*/ 0, + /*requires_flag*/ 0, /*name*/ N_("Envelope"), /*structName*/ "FMod_Envelope", /*storage_size*/ 0, @@ -770,7 +770,7 @@ static FModifierTypeInfo FMI_CYCLES = { /*type*/ FMODIFIER_TYPE_CYCLES, /*size*/ sizeof(FMod_Cycles), /*acttype*/ FMI_TYPE_EXTRAPOLATION, - /*requires*/ FMI_REQUIRES_ORIGINAL_DATA, + /*requires_flag*/ FMI_REQUIRES_ORIGINAL_DATA, /*name*/ CTX_N_(BLT_I18NCONTEXT_ID_ACTION, "Cycles"), /*structName*/ "FMod_Cycles", /*storage_size*/ sizeof(tFCMED_Cycles), @@ -832,7 +832,7 @@ static FModifierTypeInfo FMI_NOISE = { /*type*/ FMODIFIER_TYPE_NOISE, /*size*/ sizeof(FMod_Noise), /*acttype*/ FMI_TYPE_REPLACE_VALUES, - /*requires*/ 0, + /*requires_flag*/ 0, /*name*/ N_("Noise"), /*structName*/ "FMod_Noise", /*storage_size*/ 0, @@ -890,7 +890,7 @@ static FModifierTypeInfo FMI_PYTHON = { /*type*/ FMODIFIER_TYPE_PYTHON, /*size*/ sizeof(FMod_Python), /*acttype*/ FMI_TYPE_GENERATE_CURVE, - /*requires*/ FMI_REQUIRES_RUNTIME_CHECK, + /*requires_flag*/ FMI_REQUIRES_RUNTIME_CHECK, /*name*/ N_("Python"), /*structName*/ "FMod_Python", /*storage_size*/ 0, @@ -945,7 +945,7 @@ static FModifierTypeInfo FMI_LIMITS = { /*type*/ FMODIFIER_TYPE_LIMITS, /*size*/ sizeof(FMod_Limits), /*acttype*/ FMI_TYPE_GENERATE_CURVE, - /*requires*/ FMI_REQUIRES_RUNTIME_CHECK, /* XXX... err... */ + /*requires_flag*/ FMI_REQUIRES_RUNTIME_CHECK, /* XXX... err... */ /*name*/ N_("Limits"), /*structName*/ "FMod_Limits", /*storage_size*/ 0, @@ -1005,7 +1005,7 @@ static FModifierTypeInfo FMI_STEPPED = { /*type*/ FMODIFIER_TYPE_STEPPED, /*size*/ sizeof(FMod_Limits), /*acttype*/ FMI_TYPE_GENERATE_CURVE, - /*requires*/ FMI_REQUIRES_RUNTIME_CHECK, /* XXX... err... */ + /*requires_flag*/ FMI_REQUIRES_RUNTIME_CHECK, /* XXX... err... */ /*name*/ N_("Stepped"), /*structName*/ "FMod_Stepped", /*storage_size*/ 0, diff --git a/source/blender/blenlib/intern/lazy_threading.cc b/source/blender/blenlib/intern/lazy_threading.cc index 4f6d3a75ecc..2185766dd57 100644 --- a/source/blender/blenlib/intern/lazy_threading.cc +++ b/source/blender/blenlib/intern/lazy_threading.cc @@ -12,7 +12,7 @@ namespace blender::lazy_threading { * deadlocks. */ using HintReceivers = RawStack, 0>, 0>; -thread_local HintReceivers hint_receivers = []() { +static thread_local HintReceivers hint_receivers = []() { HintReceivers receivers; /* Make sure there is always at least one vector. */ receivers.push_as(); diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 4a562f2b420..5bb95f1155e 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -103,7 +103,7 @@ static void fmodifier_reorder(bContext *C, Panel *panel, int new_index) const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(fcm->type); /* Cycles modifier has to be the first, so make sure it's kept that way. */ - if (fmi->requires & FMI_REQUIRES_ORIGINAL_DATA) { + if (fmi->requires_flag & FMI_REQUIRES_ORIGINAL_DATA) { WM_report(RPT_ERROR, "Modifier requires original data"); return; } @@ -113,7 +113,7 @@ static void fmodifier_reorder(bContext *C, Panel *panel, int new_index) /* Again, make sure we don't move a modifier before a cycles modifier. */ FModifier *fcm_first = modifiers->first; const FModifierTypeInfo *fmi_first = get_fmodifier_typeinfo(fcm_first->type); - if (fmi_first->requires & FMI_REQUIRES_ORIGINAL_DATA && new_index == 0) { + if (fmi_first->requires_flag & FMI_REQUIRES_ORIGINAL_DATA && new_index == 0) { WM_report(RPT_ERROR, "Modifier requires original data"); return; } diff --git a/source/blender/editors/asset/ED_asset_handle.h b/source/blender/editors/asset/ED_asset_handle.h index 7bbba9b379e..b3d9b58b30e 100644 --- a/source/blender/editors/asset/ED_asset_handle.h +++ b/source/blender/editors/asset/ED_asset_handle.h @@ -25,8 +25,11 @@ struct AssetMetaData *ED_asset_handle_get_metadata(const struct AssetHandle *ass struct ID *ED_asset_handle_get_local_id(const struct AssetHandle *asset); ID_Type ED_asset_handle_get_id_type(const struct AssetHandle *asset); int ED_asset_handle_get_preview_icon_id(const struct AssetHandle *asset); -void ED_asset_handle_get_full_library_path(const struct AssetHandle *asset, - char r_full_lib_path[]); +void ED_asset_handle_get_full_library_path( + const struct AssetHandle *asset, + /* `1090` for #FILE_MAX_LIBEXTRA, + * rely on warnings to let us know if this gets out of sync. */ + char r_full_lib_path[1090]); #ifdef __cplusplus } diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index 29dfcc1b8f8..cec6913c211 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -205,9 +205,11 @@ static void test_endian_zbuf(struct ImBuf *ibuf) int len; int *zval; - if (BIG_LONG(1) == 1) { - return; - } + /* `BIG_LONG(1) == 1`, no change needed. */ +#ifdef __BIG_ENDIAN__ + return; +#endif + if (ibuf->zbuf == NULL) { return; } diff --git a/source/creator/creator.c b/source/creator/creator.c index 431c0c2e56f..63998b7b4c2 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -584,9 +584,13 @@ int main(int argc, } WM_main(C); } -#endif /* WITH_PYTHON_MODULE */ + /* Neither #WM_exit, #WM_main return, this quiets CLANG's `unreachable-code-return` warning. */ + BLI_assert_unreachable(); + +#endif /* !WITH_PYTHON_MODULE */ return 0; + } /* End of `int main(...)` function. */ #ifdef WITH_PYTHON_MODULE diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index 7eb37982086..b39d581b54c 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -478,6 +478,7 @@ static int arg_handle_print_version(int UNUSED(argc), { print_version_full(); exit(0); + BLI_assert_unreachable(); return 0; } @@ -684,6 +685,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo # endif exit(0); + BLI_assert_unreachable(); return 0; } @@ -1236,6 +1238,7 @@ static int arg_handle_env_system_set(int argc, const char **argv, void *UNUSED(d if (argc < 2) { fprintf(stderr, "%s requires one argument\n", argv[0]); exit(1); + BLI_assert_unreachable(); } for (; *ch_src; ch_src++, ch_dst++) {