linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [1/1] rt-tests: cyclictest: Suppress unused parameter warnings
@ 2024-12-12 16:24 ende.tan
  2024-12-13  6:35 ` Crystal Wood
  2024-12-20 18:07 ` John Kacur
  0 siblings, 2 replies; 7+ messages in thread
From: ende.tan @ 2024-12-12 16:24 UTC (permalink / raw)
  To: linux-rt-users, mtosatti
  Cc: williams, jkacur, leyfoon.tan, endeneer, Tan En De

From: Tan En De <ende.tan@starfivetech.com>

Mark unused parameters with `__attribute__((unused))`.

Signed-off-by: Tan En De <ende.tan@starfivetech.com>
---
 src/cyclictest/cyclictest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index b1f8420..f2db5e4 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -603,12 +603,12 @@ static int has_smi_counter(void)
 	return 1;
 }
 #else
-static int open_msr_file(int cpu)
+static int open_msr_file(int cpu __attribute__((unused)))
 {
 	return -1;
 }
 
-static int get_smi_counter(int fd, unsigned long *counter)
+static int get_smi_counter(int fd __attribute__((unused)), unsigned long *counter __attribute__((unused)))
 {
 	return 1;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [1/1] rt-tests: cyclictest: Suppress unused parameter warnings
  2024-12-12 16:24 [1/1] rt-tests: cyclictest: Suppress unused parameter warnings ende.tan
@ 2024-12-13  6:35 ` Crystal Wood
  2024-12-20 18:02   ` John Kacur
  2024-12-20 18:07 ` John Kacur
  1 sibling, 1 reply; 7+ messages in thread
From: Crystal Wood @ 2024-12-13  6:35 UTC (permalink / raw)
  To: ende.tan, linux-rt-users, mtosatti
  Cc: williams, jkacur, leyfoon.tan, endeneer

On Fri, 2024-12-13 at 00:24 +0800, ende.tan@starfivetech.com wrote:
> From: Tan En De <ende.tan@starfivetech.com>
> 
> Mark unused parameters with `__attribute__((unused))`.
> 
> Signed-off-by: Tan En De <ende.tan@starfivetech.com>
> ---
>  src/cyclictest/cyclictest.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Can we just turn off this warning?  Unused parameters are entirely
normal in functions used as callbacks as well as with ifdefs, and it
seems like a low value warning to begin with (there's a reason it's not
in -Wall).


-Crystal


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [1/1] rt-tests: cyclictest: Suppress unused parameter warnings
  2024-12-13  6:35 ` Crystal Wood
@ 2024-12-20 18:02   ` John Kacur
  2024-12-21  1:06     ` Crystal Wood
  0 siblings, 1 reply; 7+ messages in thread
From: John Kacur @ 2024-12-20 18:02 UTC (permalink / raw)
  To: Crystal Wood
  Cc: ende.tan, linux-rt-users, mtosatti, williams, leyfoon.tan,
	endeneer



On Fri, 13 Dec 2024, Crystal Wood wrote:

> On Fri, 2024-12-13 at 00:24 +0800, ende.tan@starfivetech.com wrote:
> > From: Tan En De <ende.tan@starfivetech.com>
> > 
> > Mark unused parameters with `__attribute__((unused))`.
> > 
> > Signed-off-by: Tan En De <ende.tan@starfivetech.com>
> > ---
> >  src/cyclictest/cyclictest.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Can we just turn off this warning?  Unused parameters are entirely
> normal in functions used as callbacks as well as with ifdefs, and it
> seems like a low value warning to begin with (there's a reason it's not
> in -Wall).

I believe it IS in -Wall
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

John


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [1/1] rt-tests: cyclictest: Suppress unused parameter warnings
  2024-12-12 16:24 [1/1] rt-tests: cyclictest: Suppress unused parameter warnings ende.tan
  2024-12-13  6:35 ` Crystal Wood
@ 2024-12-20 18:07 ` John Kacur
  2024-12-21  0:00   ` EnDe Tan
  2025-01-07 22:06   ` Crystal Wood
  1 sibling, 2 replies; 7+ messages in thread
From: John Kacur @ 2024-12-20 18:07 UTC (permalink / raw)
  To: Tan En De; +Cc: linux-rt-users, mtosatti, williams, leyfoon.tan, endeneer



On Fri, 13 Dec 2024, ende.tan@starfivetech.com wrote:

> From: Tan En De <ende.tan@starfivetech.com>
> 
> Mark unused parameters with `__attribute__((unused))`.

You were probably trying to be consistent with the rest of the programs in 
rt-tests, however, according to checkpatch, 

WARNING: __always_unused or __maybe_unused is preferred over 
__attribute__((__unused__))

__always_unused is slightly shorter, shall we try that instead?

John

> 
> Signed-off-by: Tan En De <ende.tan@starfivetech.com>
> ---
>  src/cyclictest/cyclictest.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index b1f8420..f2db5e4 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -603,12 +603,12 @@ static int has_smi_counter(void)
>  	return 1;
>  }
>  #else
> -static int open_msr_file(int cpu)
> +static int open_msr_file(int cpu __attribute__((unused)))
>  {
>  	return -1;
>  }
>  
> -static int get_smi_counter(int fd, unsigned long *counter)
> +static int get_smi_counter(int fd __attribute__((unused)), unsigned long *counter __attribute__((unused)))
>  {
>  	return 1;
>  }
> -- 
> 2.34.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [1/1] rt-tests: cyclictest: Suppress unused parameter warnings
  2024-12-20 18:07 ` John Kacur
@ 2024-12-21  0:00   ` EnDe Tan
  2025-01-07 22:06   ` Crystal Wood
  1 sibling, 0 replies; 7+ messages in thread
From: EnDe Tan @ 2024-12-21  0:00 UTC (permalink / raw)
  To: John Kacur
  Cc: linux-rt-users@vger.kernel.org, mtosatti@redhat.com,
	williams@redhat.com, Leyfoon Tan, endeneer@gmail.com

> WARNING: __always_unused or __maybe_unused is preferred over
> __attribute__((__unused__))

I tried the `__maybe_unused` using gcc 12, but it didn't work.

It looks like the `__maybe_unused` attribute is only available in C23 and later
https://en.cppreference.com/w/c/language/attributes/maybe_unused

For backward compatibility, maybe we shall keep the existing `__attribute__((__unused__))`.

Regards
Tan En De

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [1/1] rt-tests: cyclictest: Suppress unused parameter warnings
  2024-12-20 18:02   ` John Kacur
@ 2024-12-21  1:06     ` Crystal Wood
  0 siblings, 0 replies; 7+ messages in thread
From: Crystal Wood @ 2024-12-21  1:06 UTC (permalink / raw)
  To: John Kacur
  Cc: ende.tan, linux-rt-users, mtosatti, williams, leyfoon.tan,
	endeneer

On Fri, 2024-12-20 at 13:02 -0500, John Kacur wrote:
> 
> On Fri, 13 Dec 2024, Crystal Wood wrote:
> 
> > On Fri, 2024-12-13 at 00:24 +0800, ende.tan@starfivetech.com wrote:
> > > From: Tan En De <ende.tan@starfivetech.com>
> > > 
> > > Mark unused parameters with `__attribute__((unused))`.
> > > 
> > > Signed-off-by: Tan En De <ende.tan@starfivetech.com>
> > > ---
> > >  src/cyclictest/cyclictest.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > Can we just turn off this warning?  Unused parameters are entirely
> > normal in functions used as callbacks as well as with ifdefs, and it
> > seems like a low value warning to begin with (there's a reason it's not
> > in -Wall).
> 
> I believe it IS in -Wall
> https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

-Wunused-parameter is in -Wextra, as per that link.  It's a crappy
warning that just causes noise to suppress all over the place.  The
kernel doesn't enable this warning, FWIW.

-Crystal


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [1/1] rt-tests: cyclictest: Suppress unused parameter warnings
  2024-12-20 18:07 ` John Kacur
  2024-12-21  0:00   ` EnDe Tan
@ 2025-01-07 22:06   ` Crystal Wood
  1 sibling, 0 replies; 7+ messages in thread
From: Crystal Wood @ 2025-01-07 22:06 UTC (permalink / raw)
  To: John Kacur, Tan En De
  Cc: linux-rt-users, mtosatti, williams, leyfoon.tan, endeneer

On Fri, 2024-12-20 at 13:07 -0500, John Kacur wrote:
> 
> On Fri, 13 Dec 2024, ende.tan@starfivetech.com wrote:
> 
> > From: Tan En De <ende.tan@starfivetech.com>
> > 
> > Mark unused parameters with `__attribute__((unused))`.
> 
> You were probably trying to be consistent with the rest of the programs in 
> rt-tests, however, according to checkpatch, 
> 
> WARNING: __always_unused or __maybe_unused is preferred over 
> __attribute__((__unused__))
> 
> __always_unused is slightly shorter, shall we try that instead?

Checkpatch isn't perfect even when used on kernel sources, but should be
taken with quite a few grains of salt when used with other projects. 
Failing to use a macro that doesn't even exist in rt-tests is a bit more
than "trying to be consistent" :-P

-Crystal


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-07 22:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-12 16:24 [1/1] rt-tests: cyclictest: Suppress unused parameter warnings ende.tan
2024-12-13  6:35 ` Crystal Wood
2024-12-20 18:02   ` John Kacur
2024-12-21  1:06     ` Crystal Wood
2024-12-20 18:07 ` John Kacur
2024-12-21  0:00   ` EnDe Tan
2025-01-07 22:06   ` Crystal Wood

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).