From 591b8f35ae5ad03ab8c2a7f91c0429ab4c1827cc Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 30 Jun 2016 10:16:17 -0400 Subject: [PATCH] Make efivar-dp.h inlines compatible with --std=c89 Some people still insist on compiling programs with a C standard from the beginning of time, and that doesn't allow mixed declarations and code. We don't heavily depend on that, so this just fixes up the places where we use it. Fixes issue #54 Signed-off-by: Peter Jones --- src/include/efivar/efivar-dp.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/include/efivar/efivar-dp.h b/src/include/efivar/efivar-dp.h index 99aa6c9..46da47d 100644 --- a/src/include/efivar/efivar-dp.h +++ b/src/include/efivar/efivar-dp.h @@ -733,10 +733,12 @@ static inline int __attribute__((__unused__)) efidp_next_node(const_efidp in, const_efidp *out) { + ssize_t sz; + if (efidp_type(in) == EFIDP_END_TYPE) return -1; - ssize_t sz = efidp_node_size(in); + sz = efidp_node_size(in); if (sz < 0) return -1; @@ -749,11 +751,13 @@ static inline int __attribute__((__unused__)) efidp_next_instance(const_efidp in, const_efidp *out) { + ssize_t sz; + if (efidp_type(in) != EFIDP_END_TYPE || efidp_subtype(in) != EFIDP_END_INSTANCE) return -1; - ssize_t sz = efidp_node_size(in); + sz = efidp_node_size(in); if (sz < 0) return -1; @@ -768,7 +772,9 @@ efidp_is_multiinstance(const_efidp dn) { while (1) { const_efidp next; - int rc = efidp_next_node(dn, &next); + int rc; + + rc = efidp_next_node(dn, &next); if (rc < 0) break; dn = next; @@ -785,12 +791,13 @@ __attribute__((__unused__)) efidp_get_next_end(const_efidp in, const_efidp *out) { while (1) { + ssize_t sz; + if (efidp_type(in) == EFIDP_END_TYPE) { *out = in; return 0; } - ssize_t sz; sz = efidp_node_size(in); if (sz < 0) break; @@ -843,6 +850,7 @@ efidp_instance_size(const_efidp dpi) while (1) { ssize_t sz; const_efidp next; + int rc; sz = efidp_node_size(dpi); if (sz < 0) @@ -852,7 +860,7 @@ efidp_instance_size(const_efidp dpi) if (efidp_type(dpi) == EFIDP_END_TYPE) break; - int rc = efidp_next_node(dpi, &next); + rc = efidp_next_node(dpi, &next); if (rc < 0) return -1; dpi = next; -- 2.11.0