[rtems commit] semopen.c: Address set but unused variable warning

Ralf Corsepius ralf.corsepius at rtems.org
Sun Sep 22 03:01:49 UTC 2013


On 09/21/2013 11:19 PM, Joel Sherrill wrote:
> Module:    rtems
> Branch:    master
> Commit:    949265991e186d7262677fa81cf17ccaa8b78cbd
> Changeset: http://git.rtems.org/rtems/commit/?id=949265991e186d7262677fa81cf17ccaa8b78cbd
>
> Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
> Date:      Sat Sep 21 16:17:48 2013 -0500
>
> semopen.c: Address set but unused variable warning
>
> ---
>
>   cpukit/posix/src/semopen.c |    9 +++++++++
>   1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/cpukit/posix/src/semopen.c b/cpukit/posix/src/semopen.c
> index b863080..e61fad0 100644
> --- a/cpukit/posix/src/semopen.c
> +++ b/cpukit/posix/src/semopen.c
> @@ -43,6 +43,14 @@
>    *        parameters must be present.
>    */
>
> +/*
> + * mode is set but never used. GCC gives a warning for this
> + * and we need to tell GCC not to complain. But we have to
> + * have it because we have to work through the variable
> + * arguments to get to attr.
> + */
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
>   sem_t *sem_open(
>     const char *name,
>     int         oflag,
> @@ -137,3 +145,4 @@ return_id:
>       return (sem_t *)&the_semaphore->Object.id;
>     #endif
>   }
> +#pragma GCC diagnostic pop

Why this brutal and probably non-portable way to suppress warnings?

Why doesn't __attribute__((unused)) or similar suffice?

Ralf





More information about the devel mailing list