* [PATCH] coresight: catu: fix clang build warning
@ 2019-03-07 10:32 Arnd Bergmann
2019-03-07 10:48 ` Suzuki K Poulose
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-07 10:32 UTC (permalink / raw)
To: Mathieu Poirier, Alexander Shishkin
Cc: Nick Desaulniers, Arnd Bergmann, Suzuki K Poulose,
Greg Kroah-Hartman, linux-arm-kernel, linux-kernel
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.
Fixes: 434d611cddef ("coresight: catu: Plug in CATU as a backend for ETR buffer")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/hwtracing/coresight/coresight-catu.h | 5 -----
drivers/hwtracing/coresight/coresight-tmc-etr.c | 4 ++--
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-catu.h b/drivers/hwtracing/coresight/coresight-catu.h
index 1b281f0dcccc..1d2ad183fd92 100644
--- a/drivers/hwtracing/coresight/coresight-catu.h
+++ b/drivers/hwtracing/coresight/coresight-catu.h
@@ -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
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index f684283890d3..6378c3dece6b 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
@@ -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)
--
2.20.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] coresight: catu: fix clang build warning
2019-03-07 10:32 [PATCH] coresight: catu: fix clang build warning Arnd Bergmann
@ 2019-03-07 10:48 ` Suzuki K Poulose
2019-03-07 17:24 ` Mathieu Poirier
0 siblings, 1 reply; 3+ messages in thread
From: Suzuki K Poulose @ 2019-03-07 10:48 UTC (permalink / raw)
To: arnd, mathieu.poirier, alexander.shishkin
Cc: ndesaulniers, gregkh, linux-arm-kernel, linux-kernel
Hi Arnd,
On 07/03/2019 10:32, Arnd Bergmann wrote:
> 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.
>
> Fixes: 434d611cddef ("coresight: catu: Plug in CATU as a backend for ETR buffer")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Thanks for the fix.
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] coresight: catu: fix clang build warning
2019-03-07 10:48 ` Suzuki K Poulose
@ 2019-03-07 17:24 ` Mathieu Poirier
0 siblings, 0 replies; 3+ messages in thread
From: Mathieu Poirier @ 2019-03-07 17:24 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: Arnd Bergmann, Alexander Shishkin, ndesaulniers, Greg KH,
linux-arm-kernel, Linux Kernel Mailing List
On Thu, 7 Mar 2019 at 03:48, Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> Hi Arnd,
>
> On 07/03/2019 10:32, Arnd Bergmann wrote:
> > 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.
> >
> > Fixes: 434d611cddef ("coresight: catu: Plug in CATU as a backend for ETR buffer")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Thanks for the fix.
>
> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Applied after fixing line over 80 characters.
Thanks,
Mathieu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-07 17:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 10:32 [PATCH] coresight: catu: fix clang build warning Arnd Bergmann
2019-03-07 10:48 ` Suzuki K Poulose
2019-03-07 17:24 ` Mathieu Poirier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).