Skip to content

Commit 4d13265

Browse files
authored
Merge pull request #507 from igaw/private-fallhtrough-define
util: Do not expose fallthrough defines
2 parents 67a7457 + 6349127 commit 4d13265

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

meson.build

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,29 @@ conf.set10(
186186
description: 'Is linux/mctp.h include-able?'
187187
)
188188

189+
if meson.version().version_compare('>= 0.48')
190+
has_fallthrough = cc.has_function_attribute('fallthrough')
191+
else
192+
has_fallthrough = cc.compiles(
193+
'''int main(int argc, char **argv) {
194+
switch(argc) {
195+
case 0:
196+
__attribute__((__fallthrough__));
197+
case 1:
198+
return 1;
199+
}
200+
return 0;
201+
}
202+
''',
203+
name: 'has fallthrough')
204+
endif
205+
206+
if has_fallthrough
207+
conf.set('fallthrough', '__attribute__((__fallthrough__))')
208+
else
209+
conf.set('fallthrough', 'do {} while (0) /* fallthrough */')
210+
endif
211+
189212
################################################################################
190213
substs = configuration_data()
191214
substs.set('NAME', meson.project_name())

src/nvme/util.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
* libnvme utility functions
1818
*/
1919

20-
#if __has_attribute(__fallthrough__)
21-
# define fallthrough __attribute__((__fallthrough__))
22-
#else
23-
# define fallthrough do {} while (0) /* fallthrough */
24-
#endif
25-
2620
/**
2721
* enum nvme_connect_err - nvme connect error codes
2822
* @ENVME_CONNECT_RESOLVE: failed to resolve host

0 commit comments

Comments
 (0)