Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv31455/channels

Modified Files:
        chan_iax2.c chan_sip.c 
Log Message:
remove useless buffer initializations (issue #5134)
convert pbx_dundi to use ast_copy_string) (issue #5134)


Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.342
retrieving revision 1.343
diff -u -d -r1.342 -r1.343
--- chan_iax2.c 7 Sep 2005 20:52:03 -0000       1.342
+++ chan_iax2.c 7 Sep 2005 21:01:31 -0000       1.343
@@ -1851,7 +1851,7 @@
 /*--- iax2_show_peer: Show one peer in detail ---*/
 static int iax2_show_peer(int fd, int argc, char *argv[])
 {
-       char status[30] = "";
+       char status[30];
        char cbuf[256];
        char iabuf[INET_ADDRSTRLEN];
        struct iax2_peer *peer;
@@ -1961,7 +1961,7 @@
 static int iax2_show_cache(int fd, int argc, char *argv[])
 {
        struct iax2_dpcache *dp;
-       char tmp[1024] = "", *pc;
+       char tmp[1024], *pc;
        int s;
        int x,y;
        struct timeval tv;
@@ -3244,7 +3244,7 @@
 {
        unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
        struct iax_ie_data ied;
-       char tmp[256] = "", *context;
+       char tmp[256], *context;
        ast_copy_string(tmp, dest, sizeof(tmp));
        context = strchr(tmp, '@');
        if (context) {
@@ -4022,7 +4022,7 @@
 #define FORMAT2 "%-15.15s  %-20.20s  %-15.15d  %-15.15s  %-5.5s  %-5.10s\n"
 
        struct iax2_user *user;
-       char auth[90] = "";
+       char auth[90];
        char *pstr = "";
 
        switch (argc) {
@@ -4087,7 +4087,7 @@
 #define FORMAT "%-15.15s  %-15.15s %s  %-15.15s  %-5d%s  %s %-10s\n"
 
        struct iax2_peer *peer;
-       char name[256] = "";
+       char name[256];
        char iabuf[INET_ADDRSTRLEN];
        int registeredonly=0;
 
@@ -4128,8 +4128,8 @@
        ast_cli(fd, FORMAT2, "Name/Username", "Host", "   ", "Mask", "Port", "  
 ", "Status");
        for (peer = peerl.peers;peer;peer = peer->next) {
                char nm[20];
-               char status[20] = "";
-               char srch[2000] = "";
+               char status[20];
+               char srch[2000];
 
                if (registeredonly && !peer->addr.sin_addr.s_addr)
                        continue;
@@ -4262,7 +4262,7 @@
 #define FORMAT "%-20.20s  %-10.10s  %-20.20s %8d  %s\n"
        struct iax2_registry *reg;
        char host[80];
-       char perceived[80] = "";
+       char perceived[80];
        char iabuf[INET_ADDRSTRLEN];
        if (argc != 3)
                return RESULT_SHOWUSAGE;
@@ -4851,7 +4851,7 @@
 
 static int authenticate_verify(struct chan_iax2_pvt *p, struct iax_ies *ies)
 {
-       char requeststr[256] = "";
+       char requeststr[256];
        char md5secret[256] = "";
        char secret[256] = "";
        char rsasecret[256] = "";
@@ -4869,7 +4869,7 @@
        if ((p->authmethods & IAX_AUTH_RSA) && !ast_strlen_zero(rsasecret) && 
!ast_strlen_zero(p->inkeys)) {
                struct ast_key *key;
                char *keyn;
-               char tmpkey[256] = "";
+               char tmpkey[256];
                char *stringp=NULL;
                ast_copy_string(tmpkey, p->inkeys, sizeof(tmpkey));
                stringp=tmpkey;
@@ -4973,7 +4973,7 @@
        /* Check secret against what we have on file */
        if (!ast_strlen_zero(rsasecret) && (p->authmethods & IAX_AUTH_RSA) && 
!ast_strlen_zero(iaxs[callno]->challenge)) {
                if (!ast_strlen_zero(p->inkeys)) {
-                       char tmpkeys[256] = "";
+                       char tmpkeys[256];
                        char *stringp=NULL;
                        ast_copy_string(tmpkeys, p->inkeys, sizeof(tmpkeys));
                        stringp=tmpkeys;
@@ -5090,7 +5090,7 @@
                if ((authmethods & IAX_AUTH_MD5) && 
!ast_strlen_zero(challenge)) {
                        struct MD5Context md5;
                        unsigned char digest[16];
-                       char digres[128] = "";
+                       char digres[128];
                        MD5Init(&md5);
                        MD5Update(&md5, (unsigned char *)challenge, 
strlen(challenge));
                        MD5Update(&md5, (unsigned char *)secret, 
strlen(secret));
@@ -5175,7 +5175,7 @@
 static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
 {
        int newcall = 0;
-       char newip[256] = "";
+       char newip[256];
        struct iax_ie_data ied;
        struct sockaddr_in new;
        
@@ -5321,7 +5321,7 @@
        struct iax2_registry *reg;
        /* Start pessimistic */
        char peer[256] = "";
-       char msgstatus[40] = "";
+       char msgstatus[40];
        int refresh = 0;
        char ourip[256] = "<Unspecified>";
        struct sockaddr_in oldus;
@@ -5434,7 +5434,7 @@
 
 static void register_peer_exten(struct iax2_peer *peer, int onoff)
 {
-       char multi[256]="";
+       char multi[256];
        char *stringp, *ext;
        if (!ast_strlen_zero(regcontext)) {
                ast_copy_string(multi, ast_strlen_zero(peer->regexten) ? 
peer->name : peer->regexten, sizeof(multi));
@@ -9104,7 +9104,7 @@
        struct iax2_peer *p;
        int found = 0;
        char *ext, *host;
-       char tmp[256] = "";
+       char tmp[256];
        int res = AST_DEVICE_INVALID;
 
        ast_copy_string(tmp, dest, sizeof(tmp));

Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.842
retrieving revision 1.843
diff -u -d -r1.842 -r1.843
--- chan_sip.c  7 Sep 2005 20:54:19 -0000       1.842
+++ chan_sip.c  7 Sep 2005 21:01:31 -0000       1.843
@@ -1329,7 +1329,7 @@
                        __sip_ack(p, p->packets->seqno, 
(ast_test_flag(p->packets, FLAG_RESPONSE)), cur->method);
                else {  /* Unknown packet type */
                        char *c;
-                       char method[128]="";
+                       char method[128];
                        ast_copy_string(method, p->packets->data, 
sizeof(method));
                        c = ast_skip_blanks(method); /* XXX what ? */
                        *c = '\0';
@@ -1510,8 +1510,8 @@
 /*--- realtime_update_peer: Update peer object in realtime storage ---*/
 static void realtime_update_peer(const char *peername, struct sockaddr_in 
*sin, const char *username, int expirey)
 {
-       char port[10] = "";
-       char ipaddr[20] = "";
+       char port[10];
+       char ipaddr[20];
        char regseconds[20] = "0";
        
        if (expirey) {  /* Registration */
@@ -1528,7 +1528,7 @@
 /*--- register_peer_exten: Automatically add peer extension to dial plan ---*/
 static void register_peer_exten(struct sip_peer *peer, int onoff)
 {
-       char multi[256]="";
+       char multi[256];
        char *stringp, *ext;
        if (!ast_strlen_zero(regcontext)) {
                ast_copy_string(multi, ast_strlen_zero(peer->regexten) ? 
peer->name : peer->regexten, sizeof(multi));
@@ -1590,7 +1590,7 @@
        struct ast_variable *var;
        struct ast_variable *tmp;
        char *newpeername = (char *) peername;
-       char iabuf[80] = "";
+       char iabuf[80];
 
        /* First check on peer name */
        if (newpeername) 
@@ -1839,7 +1839,7 @@
        char *port;
        int portno;
        char host[MAXHOSTNAMELEN], *hostn;
-       char peer[256]="";
+       char peer[256];
 
        ast_copy_string(peer, opeer, sizeof(peer));
        port = strchr(peer, ':');
@@ -2099,7 +2099,7 @@
 /* Thought: For realtime, we should propably update storage with inuse 
counter... */
 static int update_call_counter(struct sip_pvt *fup, int event)
 {
-       char name[256] = "";
+       char name[256];
        int *inuse, *call_limit;
        int outgoing = ast_test_flag(fup, SIP_OUTGOING);
        struct sip_user *u = NULL;
@@ -2999,7 +2999,7 @@
 {
        struct sip_pvt *p;
        char *callid;
-       char tmp[256] = "";
+       char tmp[256];
        char *tag = "", *c;
 
        callid = get_header(req, "Call-ID");
@@ -3053,7 +3053,7 @@
 static int sip_register(char *value, int lineno)
 {
        struct sip_registry *reg;
-       char copy[256] = "";
+       char copy[256];
        char *username=NULL, *hostname=NULL, *secret=NULL, *authuser=NULL;
        char *porta=NULL;
        char *contact=NULL;
@@ -3630,7 +3630,7 @@
 /*--- copy_via_headers: Copy SIP VIA Headers from one request to another ---*/
 static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, struct 
sip_request *orig, char *field)
 {
-       char tmp[256]="", *oh, *end;
+       char tmp[256], *oh, *end;
        int start = 0;
        int copied = 0;
        char new[256];
@@ -3698,7 +3698,7 @@
 /*--- set_destination: Set destination from SIP URI ---*/
 static void set_destination(struct sip_pvt *p, char *uri)
 {
-       char *h, *maddr, hostname[256] = "";
+       char *h, *maddr, hostname[256];
        char iabuf[INET_ADDRSTRLEN];
        int port, hn;
        struct hostent *hp;
@@ -3723,7 +3723,8 @@
                        h += 5;
        }
        hn = strcspn(h, ":;>") + 1;
-       if (hn > sizeof(hostname)) hn = sizeof(hostname);
+       if (hn > sizeof(hostname)) 
+               hn = sizeof(hostname);
        ast_copy_string(hostname, h, hn);
        h += hn - 1;
 
@@ -3793,7 +3794,7 @@
 /*--- respprep: Prepare SIP response packet ---*/
 static int respprep(struct sip_request *resp, struct sip_pvt *p, char *msg, 
struct sip_request *req)
 {
-       char newto[256] = "", *ot;
+       char newto[256], *ot;
 
        memset(resp, 0, sizeof(*resp));
        init_resp(resp, msg, req);
@@ -3845,7 +3846,7 @@
 static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, 
int seqno, int newbranch)
 {
        struct sip_request *orig = &p->initreq;
-       char stripped[80] ="";
+       char stripped[80];
        char tmp[80];
        char newto[256];
        char *c, *n;
@@ -3866,7 +3867,6 @@
                build_via(p, p->via, sizeof(p->via));
        }
 
-
        /* Check for strict or loose router */
        if (p->route && !ast_strlen_zero(p->route->hop) && 
strstr(p->route->hop,";lr") == NULL)
                is_strict = 1;
@@ -4090,15 +4090,15 @@
        char costr[80];
        struct sockaddr_in sin;
        struct sockaddr_in vsin;
-       char v[256] = "";
-       char s[256] = "";
-       char o[256] = "";
-       char c[256] = "";
-       char t[256] = "";
-       char m[256] = "";
-       char m2[256] = "";
-       char a[1024] = "";
-       char a2[1024] = "";
+       char v[256];
+       char s[256];
+       char o[256];
+       char c[256];
+       char t[256];
+       char m[256];
+       char m2[256];
+       char a[1024];
+       char a2[1024];
        char iabuf[INET_ADDRSTRLEN];
        int x = 0;
        int capability = 0 ;
@@ -4380,7 +4380,7 @@
 /*--- extract_uri: Check Contact: URI of SIP message ---*/
 static void extract_uri(struct sip_pvt *p, struct sip_request *req)
 {
-       char stripped[256]="";
+       char stripped[256];
        char *c, *n;
        ast_copy_string(stripped, get_header(req, "Contact"), sizeof(stripped));
        c = get_in_brackets(stripped);
@@ -5382,7 +5382,7 @@
 /*--- parse_ok_contact: Parse contact header for 200 OK on INVITE ---*/
 static int parse_ok_contact(struct sip_pvt *pvt, struct sip_request *req)
 {
-       char contact[250]= ""; 
+       char contact[250]; 
        char *c, *n, *pt;
        int port;
        struct hostent *hp;
@@ -5452,7 +5452,7 @@
 /*--- parse_contact: Parse contact header and save registration ---*/
 static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct 
sip_request *req)
 {
-       char contact[80]= ""; 
+       char contact[80]; 
        char data[256];
        char iabuf[INET_ADDRSTRLEN];
        char *expires = get_header(req, "Expires");
@@ -5786,7 +5786,7 @@
                char a2_hash[256];
                char resp[256];
                char resp_hash[256]="";
-               char tmp[256] = "";
+               char tmp[256];
                char *c;
                char *z;
                char *ua_hash ="";
@@ -5944,7 +5944,7 @@
 {
        int res = -3;
        struct sip_peer *peer;
-       char tmp[256] = "";
+       char tmp[256];
        char iabuf[INET_ADDRSTRLEN];
        char *name, *c;
        char *t;
@@ -6055,7 +6055,7 @@
 /*--- get_rdnis: get referring dnis ---*/
 static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq)
 {
-       char tmp[256] = "", *c, *a;
+       char tmp[256], *c, *a;
        struct sip_request *req;
        
        req = oreq;
@@ -6084,7 +6084,7 @@
 static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
 {
        char tmp[256] = "", *c, *a;
-       char tmpf[256]= "", *fr;
+       char tmpf[256], *fr;
        struct sip_request *req;
        
        req = oreq;
@@ -6321,7 +6321,7 @@
 /*--- get_also_info: Call transfer support (old way, depreciated)--*/
 static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
 {
-       char tmp[256] = "", *c, *a;
+       char tmp[256], *c, *a;
        struct sip_request *req;
        
        req = oreq;
@@ -6363,13 +6363,12 @@
 /*--- check_via: check Via: headers ---*/
 static int check_via(struct sip_pvt *p, struct sip_request *req)
 {
-       char via[256] = "";
+       char via[256];
        char iabuf[INET_ADDRSTRLEN];
        char *c, *pt;
        struct hostent *hp;
        struct ast_hostent ahp;
 
-       memset(via, 0, sizeof(via));
        ast_copy_string(via, get_header(req, "Via"), sizeof(via));
        c = strchr(via, ';');
        if (c) 
@@ -6483,7 +6482,7 @@
 {
        struct sip_user *user;
        struct sip_peer *peer;
-       char *of, from[256] = "", *c;
+       char *of, from[256], *c;
        char *rpid,rpid_num[50];
        char iabuf[INET_ADDRSTRLEN];
        int res = 0;
@@ -6807,7 +6806,7 @@
 static int sip_show_inuse(int fd, int argc, char *argv[]) {
 #define FORMAT  "%-25.25s %-15.15s %-15.15s \n"
 #define FORMAT2 "%-25.25s %-15.15s %-15.15s \n"
-       char ilimits[40] = "";
+       char ilimits[40];
        char iused[40];
        int showall = 0;
 
@@ -6987,7 +6986,7 @@
 #define FORMAT2 "%-25.25s  %-15.15s %-3.3s %-3.3s %-3.3s %-15.15s  %-8s 
%-10s\n"
 #define FORMAT  "%-25.25s  %-15.15s %-3.3s %-3.3s %-3.3s %-15.15s  %-8d 
%-10s\n"
 
-       char name[256] = "";
+       char name[256];
        char iabuf[INET_ADDRSTRLEN];
        int total_peers = 0;
        int peers_online = 0;
@@ -8099,7 +8098,7 @@
 /*    Doesn't read the duration of the DTMF signal */
 static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
 {
-       char buf[1024] = "";
+       char buf[1024];
        unsigned int event;
        char resp = 0;
        struct ast_frame f;
@@ -8410,7 +8409,7 @@
 static int reply_digest(struct sip_pvt *p, struct sip_request *req,
        char *header, int sipmethod,  char *digest, int digest_len)
 {
-       char tmp[512] = "";
+       char tmp[512];
        char *c;
 
        /* table of recognised keywords, and places where they should be copied 
*/
@@ -8484,7 +8483,7 @@
        char a2_hash[256];
        char resp[256];
        char resp_hash[256];
-       char uri[256] = "";
+       char uri[256];
        char cnonce[80];
        char iabuf[INET_ADDRSTRLEN];
        char *username;
@@ -8850,7 +8849,7 @@
 /*--- parse_moved_contact: Parse 302 Moved temporalily response */
 static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
 {
-       char tmp[256] = "";
+       char tmp[256];
        char *s, *e;
        ast_copy_string(tmp, get_header(req, "Contact"), sizeof(tmp));
        s = get_in_brackets(tmp);
@@ -10493,7 +10492,7 @@
                }
                memcpy(&p->recv, &sin, sizeof(p->recv));
                if (recordhistory) {
-                       char tmp[80] = "";
+                       char tmp[80];
                        /* This is a response, note what it was for */
                        snprintf(tmp, sizeof(tmp), "%s / %s", req.data, 
get_header(&req, "CSeq"));
                        append_history(p, "Rx", tmp);
@@ -10797,7 +10796,7 @@
 static int sip_devicestate(void *data)
 {
        char *ext, *host;
-       char tmp[256] = "";
+       char tmp[256];
        char *dest = data;
 
        struct hostent *hp;
@@ -10861,7 +10860,7 @@
        struct sip_pvt *p;
        struct ast_channel *tmpc = NULL;
        char *ext, *host;
-       char tmp[256] = "";
+       char tmp[256];
        char *dest = data;
 
        oldformat = format;
@@ -11044,7 +11043,7 @@
 /*--- add_realm_authentication: Add realm authentication in list ---*/
 static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, 
char *configuration, int lineno)
 {
-       char authcopy[256] = "";
+       char authcopy[256];
        char *username=NULL, *realm=NULL, *secret=NULL, *md5secret=NULL;
        char *stringp;
        struct sip_auth *auth;

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to