Skip to content

Commit

Permalink
Migrate from #ifndef guards to #pragma once
Browse files Browse the repository at this point in the history
Using a pragma instead of guards is easier to write, less error prone
and avoids name clashes (a source of very subtle bugs). This pragma
is supported on almost all compilers, including all the compilers we
care about: https://en.wikipedia.org/wiki/Pragma_once#Portability.

This patch does not change the autogenerated files: asn1/asn1c/*.h.

Reviewed-By: Martin Basti <[email protected]>
Reviewed-By: Christian Heimes <[email protected]>
  • Loading branch information
npmccallum authored and MartinBasti committed May 29, 2016
1 parent 9cbb54d commit 4bafba0
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 54 deletions.
5 changes: 1 addition & 4 deletions asn1/ipa_asn1.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __IPA_ASN1_H_
#define __IPA_ASN1_H_
#pragma once

#include "ipa_krb5.h"

Expand Down Expand Up @@ -72,5 +71,3 @@ bool ipaasn1_dec_getkt(void *buf, size_t len, bool *newkt,
*/
bool ipaasn1_dec_getktreply(void *buf, size_t len,
int *kvno, struct keys_container *keys);

#endif /* __IPA_ASN1_H_ */
5 changes: 1 addition & 4 deletions client/ipa-client-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __IPA_CLIENT_COMMON_H
#define __IPA_CLIENT_COMMON_H
#pragma once

#include <libintl.h>
#define _(STRING) gettext(STRING)
Expand All @@ -29,5 +28,3 @@
#endif

int init_gettext(void);

#endif /* __IPA_CLIENT_COMMON_H */
6 changes: 1 addition & 5 deletions daemons/ipa-kdb/ipa_kdb_mspac_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef _IPA_KDB_MSPAC_PRIVATE_H_
#define _IPA_KDB_MSPAC_PRIVATE_H_
#pragma once

struct ipadb_mspac {
char *flat_domain_name;
Expand Down Expand Up @@ -53,5 +51,3 @@ struct ipadb_adtrusts {

int string_to_sid(const char *str, struct dom_sid *sid);
char *dom_sid_string(TALLOC_CTX *memctx, const struct dom_sid *dom_sid);

#endif /* _IPA_KDB_MSPAC_PRIVATE_H_ */
5 changes: 1 addition & 4 deletions daemons/ipa-otpd/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef INTERNAL_H_
#define INTERNAL_H_
#pragma once

#include "krad.h"

Expand Down Expand Up @@ -149,5 +148,3 @@ const char *otpd_parse_radius(LDAP *ldp, LDAPMessage *entry,

const char *otpd_parse_radius_username(LDAP *ldp, LDAPMessage *entry,
struct otpd_queue_item *item);

#endif /* INTERNAL_H_ */
5 changes: 1 addition & 4 deletions daemons/ipa-sam/ipa_sam.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
*/

#ifndef _PASSDB_PDB_IPA_H_
#define _PASSDB_PDB_IPA_H_
#pragma once

/* The following definitions come from passdb/pdb_ipa.c */

NTSTATUS pdb_ipa_init(void);

#endif /* _PASSDB_PDB_IPA_H_ */
5 changes: 1 addition & 4 deletions daemons/ipa-slapi-plugins/common/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/

#ifndef _SLAPI_PLUGINS_UTIL_H
#define _SLAPI_PLUGINS_UTIL_H
#pragma once

#define EOK 0
#define EFAIL -1
Expand Down Expand Up @@ -72,5 +71,3 @@
slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)

#define LOG_OOM() LOG_FATAL("Out of Memory!\n")

#endif /* _SLAPI_PLUGINS_UTIL_H */
4 changes: 1 addition & 3 deletions daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/

#ifndef _IPA_CLDAP_H_
#define _IPA_CLDAP_H_
#pragma once

#ifdef HAVE_CONFIG_H
# include <config.h>
Expand Down Expand Up @@ -108,4 +107,3 @@ int ipa_cldap_netlogon(struct ipa_cldap_ctx *ctx,
struct berval *reply);

char *make_netbios_name(TALLOC_CTX *mem_ctx, const char *s);
#endif /* _IPA_CLDAP_H_ */
4 changes: 1 addition & 3 deletions daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/

#ifndef _IPA_EXTDOM_H_
#define _IPA_EXTDOM_H_
#pragma once

#ifdef HAVE_CONFIG_H
# include <config.h>
Expand Down Expand Up @@ -202,4 +201,3 @@ int pack_ber_group(enum response_types response_type,
gid_t gid, char **members, struct sss_nss_kv *kv_list,
struct berval **berval);
void set_err_msg(struct extdom_req *req, const char *format, ...);
#endif /* _IPA_EXTDOM_H_ */
6 changes: 1 addition & 5 deletions daemons/ipa-slapi-plugins/ipa-pwd-extop/otpctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/


#ifndef OTPCTRL_H_
#define OTPCTRL_H_
#pragma once

#include "../libotp/otp_config.h"
#include <stdbool.h>
Expand All @@ -62,5 +60,3 @@ bool otpctrl_present(Slapi_PBlock *pb, const char *oid);

bool otpctrl_sync_handle(const struct otp_config *cfg, Slapi_PBlock *pb,
const char *user_dn);

#endif /* OTPCTRL_H_ */
4 changes: 1 addition & 3 deletions daemons/ipa-slapi-plugins/ipa-sidgen/ipa_sidgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/

#ifndef _IPA_SIDGEN_H_
#define _IPA_SIDGEN_H_
#pragma once

#define OBJECTCLASS "objectclass"
#define IPA_OBJECT "ipaobject"
Expand Down Expand Up @@ -105,4 +104,3 @@ int find_sid_for_ldap_entry(struct slapi_entry *entry,
const char *base_dn,
const char *dom_sid,
struct range_info **ranges);
#endif /* _IPA_SIDGEN_H_ */
5 changes: 1 addition & 4 deletions daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/

#ifndef IPA_WINSYNC_H
#define IPA_WINSYNC_H
#pragma once

#ifdef HAVE_CONFIG_H
# include <config.h>
Expand Down Expand Up @@ -172,5 +171,3 @@ enum {
#define IPA_WINSYNC_UPG_DEF_DN "cn=UPG Definition,cn=Definitions,cn=Managed Entries,cn=etc,%s"
#define IPA_WINSYNC_UPG_DEF_ATTR "originfilter"
#define IPA_WINSYNC_UPG_DEF_DISABLED "(objectclass=disable)"

#endif /* IPA_WINSYNC_H */
4 changes: 1 addition & 3 deletions util/ipa_krb5.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __IPA_KRB5_H_
#define __IPA_KRB5_H_
#pragma once

#include <lber.h>
#include <krb5/krb5.h>
Expand Down Expand Up @@ -83,4 +82,3 @@ int create_keys(krb5_context krbctx,
char **err_msg);

int ipa_kstuples_to_string(krb5_key_salt_tuple *kst, int n_kst, char **str);
#endif /* __IPA_KRB5_H_ */
5 changes: 1 addition & 4 deletions util/ipa_mspac.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __IPA_MSPAC_H_
#define __IPA_MSPAC_H_
#pragma once

char *ipa_mspac_well_known_sids[] = {
"S-1-0",
Expand Down Expand Up @@ -28,5 +27,3 @@ char *ipa_mspac_well_known_sids[] = {
"S-1-5-20",
NULL
};

#endif /* __IPA_MSPAC_H_ */
5 changes: 1 addition & 4 deletions util/ipa_pwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _IPA_PWD_H_
#define _IPA_PWD_H_
#pragma once

/* 90 days default pwd max lifetime */
#define IPAPWD_DEFAULT_PWDLIFE (90 * 24 *3600)
Expand Down Expand Up @@ -75,5 +74,3 @@ int ipapwd_generate_new_history(char *password,
int *new_pwd_hlen);

int encode_nt_key(char *newPasswd, uint8_t *nt_key);

#endif

0 comments on commit 4bafba0

Please sign in to comment.