Use "#pragma once" for headers

Some of the header guard names in ipmitool duplicated with the ones in
freeipmi.

* ipmitool/ipmi_fru.h and freeipmi/fru/ipmi-fru.h both uses IPMI_FRU_H
* ipmitool/ipmi_sdr.h and freeipmi/sdr/ipmi-sdr.h both uses IPMI_SDR_H
* ipmitool/ipmi_sel.h and freeipmi/sel/ipmi-sel.h both uses IPMI_SEL_H

This is problematic as including the 1st will prevent the 2nd from being
included, leading to the loss of any declarations, inline definitions,
or other "#includes" in the 2nd header.

For example, including ipmitool/ipmi_sel.h and freeipmi/freeipmi.h fails
to build.

$ cat test.c
 #include <ipmitool/ipmi_sel.h>
 #include <freeipmi/freeipmi.h>
$ gcc test.c -I${HOME}/src/oss/ipmitool/include
In file included from /usr/include/freeipmi/freeipmi.h:90,
                 from test.c:2:
/usr/include/freeipmi/sdr/oem/ipmi-sdr-oem-intel-node-manager.h:48:44: error: unknown type name 'ipmi_sdr_ctx_t'; did you mean 'ipmi_fru_ctx_t'?
   48 | int ipmi_sdr_oem_parse_intel_node_manager (ipmi_sdr_ctx_t ctx,
      |                                            ^~~~~~~~~~~~~~
      |                                            ipmi_fru_ctx_t

Remove header guards and use "#pragma once" instead. In this way, we
don't have to do manual management to avoid name clashes.
* src/plugins/lan/md5.h is left as is being an external header
  originally.
* src/plugins/imb/imbapi.h is a convoluted header consisting of multiple
  header guards. Let's just add "#pragma once" and leave header guards
  as is for now.

Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
This commit is contained in:
Bing-Hua Wang
2020-11-13 13:35:25 +08:00
committed by Alexander Amelkin
parent 682fec09ef
commit 5a36080f92
62 changed files with 70 additions and 253 deletions

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef _IPMI_BMC_H_
#define _IPMI_BMC_H_
#pragma once
#ifdef __cplusplus
extern "C" {
@ -48,5 +47,3 @@ void ipmi_bmc_close(struct ipmi_intf *intf);
#ifdef __cplusplus
}
#endif
#endif /* _IPMI_BMC_H_ */

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef _BMC_INTF_H
#define _BMC_INTF_H
#pragma once
#pragma ident "@(#)bmc_intf.h 1.2 05/03/07 SMI"
@ -203,5 +202,3 @@ typedef struct bmc_msg {
#ifdef __cplusplus
}
#endif
#endif /* _BMC_INTF_H */

View File

@ -1,5 +1,4 @@
#ifndef IPMI_DUMMYIPMI_H
# define IPMI_DUMMYIPMI_H
#pragma once
#define IPMI_DUMMY_DEFAULTSOCK "/tmp/.ipmi_dummy"
@ -26,5 +25,3 @@ struct dummy_rs {
int data_len;
uint8_t *data;
};
#endif

View File

@ -33,6 +33,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*----------------------------------------------------------------------*/
#pragma once
#ifndef _WINDEFS_H
#define _WINDEFS_H

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_ASF_H
#define IPMI_ASF_H
#pragma once
#include <ipmitool/helper.h>
#include "lan.h"
@ -57,5 +56,3 @@ struct asf_hdr {
#endif
int handle_asf(struct ipmi_intf * intf, uint8_t * data, int data_len);
#endif /* IPMI_ASF_H */

View File

@ -30,11 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_AUTH_H
#define IPMI_AUTH_H
#pragma once
uint8_t * ipmi_auth_md2(struct ipmi_session * s, uint8_t * data, int data_len);
uint8_t * ipmi_auth_md5(struct ipmi_session * s, uint8_t * data, int data_len);
uint8_t * ipmi_auth_special(struct ipmi_session * s);
#endif /*IPMI_AUTH_H*/

View File

@ -30,12 +30,9 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_LAN_H
#define IPMI_LAN_H
#pragma once
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
extern struct ipmi_intf ipmi_lan_intf;
#endif /*IPMI_LAN_H*/

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_RMCP_H
#define IPMI_RMCP_H
#pragma once
#include <ipmitool/helper.h>
#include "lan.h"
@ -82,5 +81,3 @@ struct rmcp_pong {
#endif
int handle_rmcp(struct ipmi_intf * intf, uint8_t * data, int data_len);
#endif /* IPMI_RMCP_H */

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_ASF_H
#define IPMI_ASF_H
#pragma once
#include <ipmitool/helper.h>
#include "lanplus.h"
@ -57,5 +56,3 @@ struct asf_hdr {
#endif
int handle_asf(struct ipmi_intf * intf, uint8_t * data, int data_len);
#endif /* IPMI_ASF_H */

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_LANPLUS_H
#define IPMI_LANPLUS_H
#pragma once
#include <ipmitool/ipmi.h>
@ -130,5 +129,3 @@ struct ipmi_rs * ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req
int ipmi_lanplus_open(struct ipmi_intf * intf);
void ipmi_lanplus_close(struct ipmi_intf * intf);
int ipmiv2_lan_ping(struct ipmi_intf * intf);
#endif /*IPMI_LAN_H*/

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_LANPLUS_CRYPT_H
#define IPMI_LANPLUS_CRYPT_H
#pragma once
#include <ipmitool/ipmi_intf.h>
@ -68,8 +67,3 @@ int lanplus_decrypt_payload(uint8_t crypt_alg,
uint16_t * payload_size);
int lanplus_has_valid_auth_code(struct ipmi_rs * rs,
struct ipmi_session * session);
#endif /* IPMI_LANPLUS_CRYPT_H */

View File

@ -30,9 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_LANPLUS_CRYPT_IMPL_H
#define IPMI_LANPLUS_CRYPT_IMPL_H
#pragma once
int
lanplus_seed_prng(uint32_t bytes);
@ -61,6 +59,3 @@ lanplus_decrypt_aes_cbc_128(const uint8_t * iv,
uint32_t input_length,
uint8_t * output,
uint32_t * bytes_written);
#endif /* IPMI_LANPLUS_CRYPT_IMPL_H */

View File

@ -30,9 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_LANPLUS_DUMP_H
#define IPMI_LANPLUS_DUMP_H
#pragma once
#include <ipmitool/ipmi_intf.h>
@ -40,6 +38,3 @@
void lanplus_dump_open_session_response(const struct ipmi_rs * rsp);
void lanplus_dump_rakp2_message(const struct ipmi_rs * rsp, uint8_t auth_alg);
void lanplus_dump_rakp4_message(const struct ipmi_rs * rsp, uint8_t auth_alg);
#endif /* IPMI_LANPLUS_DUMP_H */

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_RMCP_H
#define IPMI_RMCP_H
#pragma once
#include <ipmitool/helper.h>
#include "lanplus.h"
@ -65,5 +64,3 @@ struct rmcp_hdr {
#endif
int handle_rmcp(struct ipmi_intf * intf, uint8_t * data, int data_len);
#endif /* IPMI_RMCP_H */

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_LIPMI_H
#define IPMI_LIPMI_H
#pragma once
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
@ -42,5 +41,3 @@ struct ipmi_rs * ipmi_lipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * r
int ipmi_lipmi_open(struct ipmi_intf * intf);
void ipmi_lipmi_close(struct ipmi_intf * intf);
int lipmi_intf_setup(struct ipmi_intf ** intf);
#endif

View File

@ -30,8 +30,7 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef IPMI_OPENIPMI_H
#define IPMI_OPENIPMI_H
#pragma once
#define IPMI_MAX_ADDR_SIZE 0x20
#define IPMI_BMC_CHANNEL 0xf
@ -102,5 +101,3 @@ struct ipmi_ipmb_addr {
#define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int)
#define IPMICTL_SET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 19, unsigned int)
#define IPMICTL_GET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 20, unsigned int)
#endif /*IPMI_OPENIPMI_H*/