From fa0938a6e3cb928602633c3da0b909deb269369d Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Mon, 9 Dec 2013 22:06:40 +0100 Subject: Use pattern #elif defined(identifier) We had in source code following pattern #elif HAVE_ It worked because undefined identifier(in some cases) was evaluated to 0. But we do not care about value of HAVE_SOMETHING. We just need to know whether identifier was defined. There is not equivalent to #ifdef (short for of #if definded) We need to use long form: #elif defined HAVE_ It causes also compiler warning with enabled compiler flag -Wundef. Reviewed-by: Pavel Reichl --- src/util/sss_ini.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/util/sss_ini.c') diff --git a/src/util/sss_ini.c b/src/util/sss_ini.c index ce0d06755..5293ae93b 100644 --- a/src/util/sss_ini.c +++ b/src/util/sss_ini.c @@ -34,7 +34,7 @@ #ifdef HAVE_LIBINI_CONFIG_V1 #include "ini_configobj.h" -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) #include "collection.h" #include "collection_tools.h" #else @@ -61,7 +61,7 @@ struct sss_ini_initdata { -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) struct sss_ini_initdata { struct collection_item *error_list; @@ -99,7 +99,7 @@ void sss_ini_close_file(struct sss_ini_initdata *init_data) ini_config_file_destroy(init_data->file); init_data->file = NULL; } -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) if (init_data->file != -1) { close(init_data->file); init_data->file = -1; @@ -118,7 +118,7 @@ int sss_ini_config_file_open(struct sss_ini_initdata *init_data, return ini_config_file_open(config_file, INI_META_STATS, &init_data->file); -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) return check_and_open_readonly(config_file, &init_data->file, 0, 0, (S_IRUSR|S_IWUSR), CHECK_REG); #endif @@ -139,7 +139,7 @@ int sss_ini_config_access_check(struct sss_ini_initdata *init_data) 0, /* owned by root */ (S_IRUSR|S_IWUSR), /* rw------- */ 0); /* check all there parts */ -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) return EOK; #endif } @@ -156,7 +156,7 @@ int sss_ini_get_stat(struct sss_ini_initdata *init_data) if (!init_data->cstat) return EIO; return EOK; -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) return fstat(init_data->file, &init_data->cstat); #endif @@ -173,7 +173,7 @@ int sss_ini_get_mtime(struct sss_ini_initdata *init_data, #ifdef HAVE_LIBINI_CONFIG_V1 return snprintf(timestr, timestr_len, "%llu", (long long unsigned)init_data->cstat->st_mtime); -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) return snprintf(timestr, timestr_len, "%llu", (long long unsigned)init_data->cstat.st_mtime); #endif @@ -247,7 +247,7 @@ int sss_ini_get_config(struct sss_ini_initdata *init_data, return ret; -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) /* Read the configuration into a collection */ ret = config_from_fd("sssd", @@ -308,7 +308,7 @@ int sss_ini_get_int_config_value(struct sss_ini_initdata *init_data, { #ifdef HAVE_LIBINI_CONFIG_V1 return ini_get_int_config_value(init_data->obj, strict, def, error); -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) return get_int_config_value(init_data->obj, strict, def, error); #endif } @@ -325,7 +325,7 @@ void sss_ini_config_destroy(struct sss_ini_initdata *init_data) ini_config_destroy(init_data->sssd_config); init_data->sssd_config = NULL; } -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) free_ini_config(init_data->sssd_config); #endif } @@ -355,7 +355,7 @@ int sss_confdb_create_ldif(TALLOC_CTX *mem_ctx, size_t attr_len; #ifdef HAVE_LIBINI_CONFIG_V1 struct value_obj *obj = NULL; -#elif HAVE_LIBINI_CONFIG_V0 +#elif defined(HAVE_LIBINI_CONFIG_V0) struct collection_item *obj = NULL; #endif -- cgit