remove unnecessary (char *) casts for ast_config_AST_* variables.
[asterisk/asterisk.git] / utils / extconf.c
index 0d30cc9..c6e8cf6 100644 (file)
  *
  */
 
-#include "asterisk/autoconfig.h"
+#include "asterisk/compat.h"
 
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
 #include <errno.h>
 #include <time.h>
 #include <sys/stat.h>
@@ -67,8 +63,6 @@ struct ast_channel
 
 
 #include "asterisk/inline_api.h"
-#include "asterisk/compat.h"
-#include "asterisk/compiler.h"
 #include "asterisk/endian.h"
 #include "asterisk/ast_expr.h"
 #include "asterisk/ael_structs.h"
@@ -1152,7 +1146,7 @@ extern int ast_language_is_prefix;
 
 /* Asterisk REQUIRES recursive (not error checking) mutexes
    and will not run without them. */
-#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
+#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) && defined(PTHREAD_MUTEX_RECURSIVE_NP)
 #define PTHREAD_MUTEX_INIT_VALUE       PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
 #define AST_MUTEX_KIND                 PTHREAD_MUTEX_RECURSIVE_NP
 #else
@@ -1841,8 +1835,6 @@ AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
 #define ast_channel_trylock(x)         ast_mutex_trylock(&x->lock)
 #else
 
-struct ast_channel;
-
 /*! \brief Lock AST channel (and print debugging output)
 \note You need to enable DEBUG_CHANNEL_LOCKS for this function */
 int ast_channel_lock(struct ast_channel *chan);
@@ -3664,7 +3656,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
                if (use_local_dir)
                        snprintf(fn, sizeof(fn), "./%s", filename);
                else
-                       snprintf(fn, sizeof(fn), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, filename);
+                       snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, filename);
        }
 
        if (withcomments && cfg && cfg->include_level < 2 ) {
@@ -5700,6 +5692,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
        char *vars, *vare;
        int pos, brackets, needsub, len;
 
+       *cp2 = 0; /* just in case there's nothing to do */
        whereweare=tmp=cp1;
        while (!ast_strlen_zero(whereweare) && count) {
                /* Assume we're copying the whole remaining string */
@@ -5731,6 +5724,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
                        count -= pos;
                        cp2 += pos;
                        whereweare += pos;
+                       *cp2 = 0;
                }
 
                if (nextvar) {
@@ -5802,6 +5796,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
                                memcpy(cp2, cp4, length);
                                count -= length;
                                cp2 += length;
+                               *cp2 = 0;
                        }
                } else if (nextexp) {
                        /* We have an expression.  Find the start and end, and determine
@@ -5859,6 +5854,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
                                        ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2);
                                count -= length;
                                cp2 += length;
+                               *cp2 = 0;
                        }
                } else
                        break;