coresight: catu: fix clang build warning
PATCH 1/1 coresight: catu: fix clang build warning
Clang points out a syntax error, as the etr_catu_buf_ops structure is declared 'static' before the type is known:
In file included from drivers/hwtracing/coresight/coresight-tmc-etr.c:12:drivers/hwtracing/coresight/coresight-catu.h:116:40: warning: tentative definition of variable with internal linkage has incomplete non-array type 'const struct etr_buf_operations' [-Wtentative-definition-incomplete-type]
static const struct etr_buf_operations etr_catu_buf_ops;
^drivers/hwtracing/coresight/coresight-catu.h:116:21: note: forward declaration of 'struct etr_buf_operations' static const struct etr_buf_operations etr_catu_buf_ops;
This seems worth fixing in the code, so replace pointer to the empty constant structure with a NULL pointer. We need an extra NULL pointer check here, but the result should be better object code otherwise, avoiding the silly empty structure.
--- drivers/hwtracing/coresight/coresight-catu.h | 5 ----- drivers/hwtracing/coresight/coresight-tmc-etr.c | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/hwtracing/coresight/coresight-catu.h +0 -5
@@ -109,11 +109,6 @@ static inline bool coresight_is_catu_device(struct coresight_device *csdev) return true; } -#ifdef CONFIG_CORESIGHT_CATU extern const struct etr_buf_operations etr_catu_buf_ops; -#else -/* Dummy declaration for the CATU ops */ -static const struct etr_buf_operations etr_catu_buf_ops; -#endif #endif
drivers/hwtracing/coresight/coresight-tmc-etr.c +2 -2
@@ -772,7 +772,7 @@ static inline void tmc_etr_disable_catu(struct tmc_drvdata *drvdata)static const struct etr_buf_operations *etr_buf_ops[] = { [ETR_MODE_FLAT ] = &etr_flat_buf_ops, [ETR_MODE_ETR_SG ] = &etr_sg_buf_ops, - [ETR_MODE_CATU ] = &etr_catu_buf_ops, + [ETR_MODE_CATU ] =IS_ENABLED (CONFIG_CORESIGHT_CATU ) ? &etr_catu_buf_ops :NULL , }; static inline int tmc_etr_mode_alloc_buf(int mode,
@@ -786,7 +786,7 @@ static inline int tmc_etr_mode_alloc_buf(int mode,case ETR_MODE_FLAT :case ETR_MODE_ETR_SG :case ETR_MODE_CATU : -if (etr_buf_ops[mode]->alloc) +if (etr_buf_ops[mode] && etr_buf_ops[mode]->alloc) rc = etr_buf_ops[mode]->alloc (drvdata, etr_buf, node, pages);if (!rc)
Signature · 1 line
2.20.0
Hi Arnd,
Quoted 10 lines · Arnd Bergmann
Clang points out a syntax error, as the
etr_catu_buf_opsstructure is declared 'static' before the type is known:In file included from
drivers/hwtracing/coresight/coresight-tmc-etr.c:12:drivers/hwtracing/coresight/coresight-catu.h:116:40: warning: tentative definition of variable with internal linkage has incomplete non-array type 'const structetr_buf_operations' [-Wtentative-definition-incomplete-type]static const struct etr_buf_operations etr_catu_buf_ops; ^
drivers/hwtracing/coresight/coresight-catu.h:116:21: note: forward declaration of 'structetr_buf_operations' static const structetr_buf_operationsetr_catu_buf_ops;
Quoted 7 lines
This seems worth fixing in the code, so replace pointer to the empty constant structure with a NULL pointer. We need an extra NULL pointer check here, but the result should be better object code otherwise, avoiding the silly empty structure.
Fixes 434d611cddef ("coresight: catu: Plug in CATU as a backend for ETR buffer")Signed-off-by Arnd Bergmann <[email protected]>
Thanks for the fix.
Quoted 19 lines · Suzuki K Poulose
Hi Arnd,
Quoted 15 lines · Arnd Bergmann
Clang points out a syntax error, as the
etr_catu_buf_opsstructure is declared 'static' before the type is known:In file included from
drivers/hwtracing/coresight/coresight-tmc-etr.c:12:drivers/hwtracing/coresight/coresight-catu.h:116:40: warning: tentative definition of variable with internal linkage has incomplete non-array type 'const structetr_buf_operations' [-Wtentative-definition-incomplete-type]static const struct etr_buf_operations etr_catu_buf_ops; ^
drivers/hwtracing/coresight/coresight-catu.h:116:21: note: forward declaration of 'structetr_buf_operations' static const structetr_buf_operationsetr_catu_buf_ops;This seems worth fixing in the code, so replace pointer to the empty constant structure with a NULL pointer. We need an extra NULL pointer check here, but the result should be better object code otherwise, avoiding the silly empty structure.
Quoted 6 lines
Quoted 2 lines
Fixes 434d611cddef ("coresight: catu: Plug in CATU as a backend for ETR buffer")Signed-off-by Arnd Bergmann <[email protected]>Thanks for the fix.
Reviewed-by Suzuki K Poulose <[email protected]>
Applied after fixing line over 80 characters.
Thanks,
Mathieu