Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gcc unused value warning in FreeBSD simd.h #16693

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

DimitryAndric
Copy link
Contributor

With gcc we are seeing the following -Werror warnings:

/workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd.h:53:33: error: statement with no effect [-Werror=unused-value]
   53 | #define simd_stat_init()        0
      |                                 ^
/workspace/src/sys/contrib/openzfs/module/zcommon/zfs_prop.c:1092:9: note: in expansion of macro 'simd_stat_init'
 1092 |         simd_stat_init();
      |         ^~~~~~~~~~~~~~
/workspace/src/sys/contrib/openzfs/module/zcommon/zfs_prop.c: In function 'zcommon_fini':
/workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd.h:54:33: error: statement with no effect [-Werror=unused-value]
   54 | #define simd_stat_fini()        0
      |                                 ^
/workspace/src/sys/contrib/openzfs/module/zcommon/zfs_prop.c:1100:9: note: in expansion of macro 'simd_stat_fini'
 1100 |         simd_stat_fini();
      |         ^~~~~~~~~~~~~~

Both simd_stat_init() and simd_stat_fini() are defined in the FreeBSD specific version of simd.h:

#define     simd_stat_init()        0
#define     simd_stat_fini()        0

These should both be defined as do {} while (0) instead, similar to other macros in this file.

The macros `simd_stat_init()` and `simd_stat_fini()` in FreeBSD's
`simd.h` are defined as zero, but they are actually only used as
statements. Replace the definitions with `do {} while (0)` instead, to
avoid gcc `-Wunused-value` warnings.

Signed-off-by: Dimitry Andric <[email protected]>
@DimitryAndric
Copy link
Contributor Author

@tsoome, @amotin

freebsd-git pushed a commit to freebsd/freebsd-src that referenced this pull request Oct 28, 2024
With gcc we are seeing the following -Werror warnings:

  /workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd.h:53:33: error: statement with no effect [-Werror=unused-value]
     53 | #define simd_stat_init()        0
        |                                 ^
  /workspace/src/sys/contrib/openzfs/module/zcommon/zfs_prop.c:1092:9: note: in expansion of macro 'simd_stat_init'
   1092 |         simd_stat_init();
        |         ^~~~~~~~~~~~~~
  /workspace/src/sys/contrib/openzfs/module/zcommon/zfs_prop.c: In function 'zcommon_fini':
  /workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd.h:54:33: error: statement with no effect [-Werror=unused-value]
     54 | #define simd_stat_fini()        0
        |                                 ^
  /workspace/src/sys/contrib/openzfs/module/zcommon/zfs_prop.c:1100:9: note: in expansion of macro 'simd_stat_fini'
   1100 |         simd_stat_fini();
        |         ^~~~~~~~~~~~~~

Both `simd_stat_init()` and `simd_stat_fini()` are defined in the
FreeBSD specific version of `simd.h`:

  #define	simd_stat_init()	0
  #define	simd_stat_fini()	0

These should both be defined as `do {} while (0)` instead, similar to
other macros in this file.

Reviewed by:	mav, tsoome (upstream)
Obtained from:	openzfs/zfs#16693
MFC after:	3 days
Differential Revision:	<https://reviews.freebsd.org/D47297>
@amotin amotin merged commit c480e06 into openzfs:master Oct 29, 2024
20 checks passed
@amotin amotin added the Status: Accepted Ready to integrate (reviewed, tested) label Oct 29, 2024
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Nov 1, 2024
The macros `simd_stat_init()` and `simd_stat_fini()` in FreeBSD's
`simd.h` are defined as zero, but they are actually only used as
statements. Replace the definitions with `do {} while (0)` instead, to
avoid gcc `-Wunused-value` warnings.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Toomas Soome <[email protected]>
Signed-off-by: Dimitry Andric <[email protected]>
Closes openzfs#16693
ptr1337 pushed a commit to CachyOS/zfs that referenced this pull request Nov 14, 2024
The macros `simd_stat_init()` and `simd_stat_fini()` in FreeBSD's
`simd.h` are defined as zero, but they are actually only used as
statements. Replace the definitions with `do {} while (0)` instead, to
avoid gcc `-Wunused-value` warnings.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Toomas Soome <[email protected]>
Signed-off-by: Dimitry Andric <[email protected]>
Closes openzfs#16693
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants