From 10d36d9f340dbc3756749c011ed26b1cf172c30b Mon Sep 17 00:00:00 2001
From: "Kevin P. Fleming" <kpfleming@digium.com>
Date: Thu, 30 Oct 2008 16:49:02 +0000
Subject: [PATCH] fix a few small things found by using sparse

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@152809 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 apps/app_adsiprog.c              |  2 +-
 channels/misdn/isdn_lib.c        | 25 ++++++++++++++++---------
 channels/misdn/isdn_lib.h        |  8 +++++---
 channels/misdn/isdn_lib_intern.h |  2 ++
 codecs/lpc10/chanwr.c            |  3 ++-
 main/asterisk.c                  |  8 +-------
 main/buildinfo.c                 |  1 +
 main/dial.c                      | 18 +++++++++---------
 main/dnsmgr.c                    |  2 +-
 utils/astcanary.c                |  2 +-
 10 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/apps/app_adsiprog.c b/apps/app_adsiprog.c
index 8ee3a0410d..255026fbd9 100644
--- a/apps/app_adsiprog.c
+++ b/apps/app_adsiprog.c
@@ -828,7 +828,7 @@ static int onevent(char *buf, char *name, int id, char *args, struct adsi_script
 			ast_log(LOG_WARNING, "'%s' is not a valid state name at line %d of %s\n", tok, lineno, script);
 			return 0;
 		}
-		if ((snums[scnt] = getstatebyname(state, sname, script, lineno, 0) < 0)) {
+		if ((snums[scnt] = getstatebyname(state, sname, script, lineno, 0) == NULL)) {
 			ast_log(LOG_WARNING, "State '%s' not declared at line %d of %s\n", sname, lineno, script);
 			return 0;
 		}
diff --git a/channels/misdn/isdn_lib.c b/channels/misdn/isdn_lib.c
index 6836e01467..f7295bdb3a 100644
--- a/channels/misdn/isdn_lib.c
+++ b/channels/misdn/isdn_lib.c
@@ -25,6 +25,14 @@
 #include "isdn_lib_intern.h"
 #include "isdn_lib.h"
 
+enum event_response_e (*cb_event) (enum event_e event, struct misdn_bchannel *bc, void *user_data);
+
+void (*cb_log) (int level, int port, char *tmpl, ...)
+	__attribute__ ((format (printf, 3, 4)));
+
+int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
+
+
 /* 
  * Define ARRAY_LEN() because I cannot
  * #include "asterisk/utils.h"
@@ -259,8 +267,8 @@ static int  entity;
 
 static struct misdn_lib *glob_mgr;
 
-char tone_425_flip[TONE_425_SIZE];
-char tone_silence_flip[TONE_SILENCE_SIZE];
+static char tone_425_flip[TONE_425_SIZE];
+static char tone_silence_flip[TONE_SILENCE_SIZE];
 
 static void misdn_lib_isdn_event_catcher(void *arg);
 static int handle_event_nt(void *dat, void *arg);
@@ -472,7 +480,7 @@ static void dump_chan_list(struct misdn_stack *stack)
 }
 
 
-void misdn_dump_chanlist()
+void misdn_dump_chanlist(void)
 {
 	struct misdn_stack *stack=get_misdn_stack();
 	for ( ; stack; stack=stack->next) {
@@ -481,7 +489,7 @@ void misdn_dump_chanlist()
 
 }
 
-int set_chan_in_stack(struct misdn_stack *stack, int channel)
+static int set_chan_in_stack(struct misdn_stack *stack, int channel)
 {
 
 	cb_log(4,stack->port,"set_chan_in_stack: %d\n",channel);
@@ -1838,7 +1846,7 @@ int release_cr(struct misdn_stack *stack, mISDNuser_head_t *hh)
 	return 0 ;
 }
 
-int
+static int
 handle_event_nt(void *dat, void *arg)
 {
 	manager_t *mgr = (manager_t *)dat;
@@ -3079,7 +3087,7 @@ static void misdn_lib_isdn_event_catcher(void *arg)
 
 /** App Interface **/
 
-int te_lib_init() {
+int te_lib_init(void) {
 	char buff[1025] = "";
 	iframe_t *frm=(iframe_t*)buff;
 	int midev=mISDN_open();
@@ -3888,7 +3896,7 @@ int misdn_lib_port_restart(int port)
 
 
 
-sem_t handler_started; 
+static sem_t handler_started; 
 
 /* This is a thread */
 static void manager_event_handler(void *arg)
@@ -4037,7 +4045,6 @@ void misdn_lib_nt_debug_init( int flags, char *file )
 	}
 }
 
-
 int misdn_lib_init(char *portlist, struct misdn_lib_iface *iface, void *user_data)
 {
 	struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib));
@@ -4560,7 +4567,7 @@ void manager_ec_disable(struct misdn_bchannel *bc)
 #endif
 }
 
-struct misdn_stack* get_misdn_stack() {
+struct misdn_stack* get_misdn_stack(void) {
 	return glob_mgr->stack_list;
 }
 
diff --git a/channels/misdn/isdn_lib.h b/channels/misdn/isdn_lib.h
index 59b9418193..638df8a740 100644
--- a/channels/misdn/isdn_lib.h
+++ b/channels/misdn/isdn_lib.h
@@ -567,10 +567,12 @@ struct misdn_bchannel {
 };
 
 
-enum event_response_e (*cb_event) (enum event_e event, struct misdn_bchannel *bc, void *user_data);
-void (*cb_log) (int level, int port, char *tmpl, ...)
+extern enum event_response_e (*cb_event) (enum event_e event, struct misdn_bchannel *bc, void *user_data);
+
+extern void (*cb_log) (int level, int port, char *tmpl, ...)
 	__attribute__ ((format (printf, 3, 4)));
-int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
+
+extern int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
 
 struct misdn_lib_iface {
 	enum event_response_e (*cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data);
diff --git a/channels/misdn/isdn_lib_intern.h b/channels/misdn/isdn_lib_intern.h
index 498c739352..a4ddc7a496 100644
--- a/channels/misdn/isdn_lib_intern.h
+++ b/channels/misdn/isdn_lib_intern.h
@@ -28,8 +28,10 @@
 #endif
 
 
+#if 0
 ibuffer_t *astbuf;		/* Not used */
 ibuffer_t *misdnbuf;	/* Not used */
+#endif
 
 struct send_lock {
 	pthread_mutex_t lock;
diff --git a/codecs/lpc10/chanwr.c b/codecs/lpc10/chanwr.c
index cefcdd1453..b7a9c722ed 100644
--- a/codecs/lpc10/chanwr.c
+++ b/codecs/lpc10/chanwr.c
@@ -29,6 +29,7 @@ Some OSS fixes and a few lpc changes to make it actually work
 	-lf2c -lm   (in that order)
 */
 
+#include <stdlib.h>
 #include "f2c.h"
 
 /* *********************************************************************** */
@@ -228,5 +229,5 @@ L_chanrd:
 /* Subroutine */ int chanrd_(integer *order, integer *ipitv, integer *irms, 
 	integer *irc, integer *ibits)
 {
-    return chanwr_0_(1, order, ipitv, irms, irc, ibits, 0);
+    return chanwr_0_(1, order, ipitv, irms, irc, ibits, NULL);
     }
diff --git a/main/asterisk.c b/main/asterisk.c
index 7da70c232b..73e27c2296 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -117,6 +117,7 @@ int daemon(int, int);  /* defined in libresolv of all places */
 #include "asterisk/devicestate.h"
 #include "asterisk/module.h"
 #include "asterisk/dsp.h"
+#include "asterisk/buildinfo.h"
 
 #include "asterisk/doxyref.h"		/* Doxygen documentation */
 
@@ -246,13 +247,6 @@ static char ast_config_AST_CTL_OWNER[PATH_MAX] = "\0";
 static char ast_config_AST_CTL_GROUP[PATH_MAX] = "\0";
 static char ast_config_AST_CTL[PATH_MAX] = "asterisk.ctl";
 
-extern const char *ast_build_hostname;
-extern const char *ast_build_kernel;
-extern const char *ast_build_machine;
-extern const char *ast_build_os;
-extern const char *ast_build_date;
-extern const char *ast_build_user;
-
 static char *_argv[256];
 static int shuttingdown;
 static int restartnow;
diff --git a/main/buildinfo.c b/main/buildinfo.c
index 964e06eb37..9eb47f0e49 100644
--- a/main/buildinfo.c
+++ b/main/buildinfo.c
@@ -23,6 +23,7 @@
  * \author Kevin P. Fleming <kpfleming@digium.com>
  */
 
+#include "asterisk/buildinfo.h"
 #include "asterisk/build.h"
 
 const char *ast_build_hostname = BUILD_HOSTNAME;
diff --git a/main/dial.c b/main/dial.c
index be1cc6982e..54654a94ac 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -53,15 +53,15 @@ struct ast_dial {
 
 /*! \brief Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more! */
 struct ast_dial_channel {
-	int num;                               /*!< Unique number for dialed channel */
-	int timeout;                           /*!< Maximum time allowed for attempt */
-	char *tech;                            /*!< Technology being dialed */
-	char *device;                          /*!< Device being dialed */
-	void *options[AST_DIAL_OPTION_MAX];    /*!< Channel specific options */
-	int cause;                             /*!< Cause code in case of failure */
-	int is_running_app:1;                  /*!< Is this running an application? */
-	struct ast_channel *owner;             /*!< Asterisk channel */
-	AST_LIST_ENTRY(ast_dial_channel) list; /*!< Linked list information */
+	int num;				/*!< Unique number for dialed channel */
+	int timeout;				/*!< Maximum time allowed for attempt */
+	char *tech;				/*!< Technology being dialed */
+	char *device;				/*!< Device being dialed */
+	void *options[AST_DIAL_OPTION_MAX];	/*!< Channel specific options */
+	int cause;				/*!< Cause code in case of failure */
+	unsigned int is_running_app:1;		/*!< Is this running an application? */
+	struct ast_channel *owner;		/*!< Asterisk channel */
+	AST_LIST_ENTRY(ast_dial_channel) list;	/*!< Linked list information */
 };
 
 /*! \brief Typedef for dial option enable */
diff --git a/main/dnsmgr.c b/main/dnsmgr.c
index 7ff7a4f5d7..c20d85d233 100644
--- a/main/dnsmgr.c
+++ b/main/dnsmgr.c
@@ -57,7 +57,7 @@ struct ast_dnsmgr_entry {
 	/*! SRV record to lookup, if provided. Composed of service, protocol, and domain name: _Service._Proto.Name */
 	char *service;
 	/*! Set to 1 if the entry changes */
-	int changed:1;
+	unsigned int changed:1;
 	ast_mutex_t lock;
 	AST_RWLIST_ENTRY(ast_dnsmgr_entry) list;
 	/*! just 1 here, but we use calloc to allocate the correct size */
diff --git a/utils/astcanary.c b/utils/astcanary.c
index a0a295ca32..d4a47c4233 100644
--- a/utils/astcanary.c
+++ b/utils/astcanary.c
@@ -59,7 +59,7 @@
  * Asterisk itself.
  */
 
-const char explanation[] =
+static const char explanation[] =
 "This file is created when Asterisk is run with a realtime priority (-p).  It\n"
 "must continue to exist, and the astcanary process must be allowed to continue\n"
 "running, or else the Asterisk process will, within a short period of time,\n"
-- 
GitLab