[asterisk-commits] russell: trunk r133568 - /trunk/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 25 08:02:00 CDT 2008


Author: russell
Date: Fri Jul 25 08:01:59 2008
New Revision: 133568

URL: http://svn.digium.com/view/asterisk?view=rev&rev=133568
Log:
Minor coding guidelines tweaks ...
 - Use ast_strlen_zero in one place
 - check for successful string comparison the way most of Asterisk code does it

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=133568&r1=133567&r2=133568
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Jul 25 08:01:59 2008
@@ -5633,7 +5633,7 @@
 /*! \brief Reads one line of SIP message body */
 static char *get_body_by_line(const char *line, const char *name, int nameLen)
 {
-	if (strncasecmp(line, name, nameLen) == 0 && line[nameLen] == '=')
+	if (!strncasecmp(line, name, nameLen) && line[nameLen] == '=')
 		return ast_skip_blanks(line + nameLen + 1);
 
 	return "";
@@ -6519,7 +6519,7 @@
 		if(!strcasecmp(req->line[x], "Content-Type: application/sdp"))
 			found_application_sdp = TRUE;
 		
-		if(strlen(req->line[x]) == 0 ){
+		if (ast_strlen_zero(req->line[x])) {
 			if(found_application_sdp && !found_end_of_headers){
 				req->sdp_start = x;
 				found_end_of_headers = TRUE;
@@ -7504,9 +7504,9 @@
 		++h;
 	else {
 		h = uri;
-		if (strncasecmp(h, "sip:", 4) == 0)
+		if (!strncasecmp(h, "sip:", 4))
 			h += 4;
-		else if (strncasecmp(h, "sips:", 5) == 0)
+		else if (!strncasecmp(h, "sips:", 5))
 			h += 5;
 	}
 	hn = strcspn(h, ":;>") + 1;
@@ -9433,7 +9433,7 @@
 		return -1;
 	}
 
-	if (strncasecmp(channame, "sip/", 4) == 0) {
+	if (!strncasecmp(channame, "sip/", 4)) {
 		channame += 4;
 	}
 
@@ -10966,27 +10966,27 @@
 /*! \brief Translate referring cause */
 static void sip_set_redirstr(struct sip_pvt *p, char *reason) {
 
-	if (strcmp(reason, "unknown")==0) {
+	if (!strcmp(reason, "unknown")) {
 		ast_string_field_set(p, redircause, "UNKNOWN");
-	} else if (strcmp(reason, "user-busy")==0) {
+	} else if (!strcmp(reason, "user-busy")) {
 		ast_string_field_set(p, redircause, "BUSY");
-	} else if (strcmp(reason, "no-answer")==0) {
+	} else if (!strcmp(reason, "no-answer")) {
 		ast_string_field_set(p, redircause, "NOANSWER");
-	} else if (strcmp(reason, "unavailable")==0) {
+	} else if (!strcmp(reason, "unavailable")) {
 		ast_string_field_set(p, redircause, "UNREACHABLE");
-	} else if (strcmp(reason, "unconditional")==0) {
+	} else if (!strcmp(reason, "unconditional")) {
 		ast_string_field_set(p, redircause, "UNCONDITIONAL");
-	} else if (strcmp(reason, "time-of-day")==0) {
+	} else if (!strcmp(reason, "time-of-day")) {
 		ast_string_field_set(p, redircause, "UNKNOWN");
-	} else if (strcmp(reason, "do-not-disturb")==0) {
+	} else if (!strcmp(reason, "do-not-disturb")) {
 		ast_string_field_set(p, redircause, "UNKNOWN");
-	} else if (strcmp(reason, "deflection")==0) {
+	} else if (!strcmp(reason, "deflection")) {
 		ast_string_field_set(p, redircause, "UNKNOWN");
-	} else if (strcmp(reason, "follow-me")==0) {
+	} else if (!strcmp(reason, "follow-me")) {
 		ast_string_field_set(p, redircause, "UNKNOWN");
-	} else if (strcmp(reason, "out-of-service")==0) {
+	} else if (!strcmp(reason, "out-of-service")) {
 		ast_string_field_set(p, redircause, "UNREACHABLE");
-	} else if (strcmp(reason, "away")==0) {
+	} else if (!strcmp(reason, "away")) {
 		ast_string_field_set(p, redircause, "UNREACHABLE");
 	} else {
 		ast_string_field_set(p, redircause, "UNKNOWN");
@@ -12610,7 +12610,7 @@
 		ast_copy_string(newlist, new, sizeof(newlist));
 		stringp = newlist;
 		while ((newcontext = strsep(&stringp, "&"))) {
-			if (strcmp(newcontext, oldcontext) == 0) {
+			if (!strcmp(newcontext, oldcontext)) {
 				/* This is not the context you're looking for */
 				stalecontext = '\0';
 				break;
@@ -14864,7 +14864,7 @@
 	
 		chanvar = strsep(&chanvar, "]");
 		for (v = peer->chanvars ; v ; v = v->next)
-			if (strcasecmp(v->name, chanvar) == 0)
+			if (!strcasecmp(v->name, chanvar))
 				ast_copy_string(buf, v->value, len);
 	} else  if (!strncasecmp(colname, "codec[", 6)) {
 		char *codecnum;
@@ -18246,35 +18246,35 @@
 		if (ast_strlen_zero(args.field))
 			args.field = "all";
 		
-		if (strcasecmp(args.type, "AUDIO") == 0) {
+		if (!strcasecmp(args.type, "AUDIO")) {
 			all = ast_rtp_get_quality(rtp = p->rtp, &qos, RTPQOS_SUMMARY);
-		} else if (strcasecmp(args.type, "VIDEO") == 0) {
+		} else if (!strcasecmp(args.type, "VIDEO")) {
 			all = ast_rtp_get_quality(rtp = p->vrtp, &qos, RTPQOS_SUMMARY);
-		} else if (strcasecmp(args.type, "TEXT") == 0) {
+		} else if (!strcasecmp(args.type, "TEXT")) {
 			all = ast_rtp_get_quality(rtp = p->trtp, &qos, RTPQOS_SUMMARY);
 		} else {
 			return -1;
 		}
 		
-		if (strcasecmp(args.field, "local_ssrc") == 0)
+		if (!strcasecmp(args.field, "local_ssrc"))
 			snprintf(buf, buflen, "%u", qos.local_ssrc);
-		else if (strcasecmp(args.field, "local_lostpackets") == 0)
+		else if (!strcasecmp(args.field, "local_lostpackets"))
 			snprintf(buf, buflen, "%u", qos.local_lostpackets);
-		else if (strcasecmp(args.field, "local_jitter") == 0)
+		else if (!strcasecmp(args.field, "local_jitter"))
 			snprintf(buf, buflen, "%.0f", qos.local_jitter * 1000.0);
-		else if (strcasecmp(args.field, "local_count") == 0)
+		else if (!strcasecmp(args.field, "local_count"))
 			snprintf(buf, buflen, "%u", qos.local_count);
-		else if (strcasecmp(args.field, "remote_ssrc") == 0)
+		else if (!strcasecmp(args.field, "remote_ssrc"))
 			snprintf(buf, buflen, "%u", qos.remote_ssrc);
-		else if (strcasecmp(args.field, "remote_lostpackets") == 0)
+		else if (!strcasecmp(args.field, "remote_lostpackets"))
 			snprintf(buf, buflen, "%u", qos.remote_lostpackets);
-		else if (strcasecmp(args.field, "remote_jitter") == 0)
+		else if (!strcasecmp(args.field, "remote_jitter"))
 			snprintf(buf, buflen, "%.0f", qos.remote_jitter * 1000.0);
-		else if (strcasecmp(args.field, "remote_count") == 0)
+		else if (!strcasecmp(args.field, "remote_count"))
 			snprintf(buf, buflen, "%u", qos.remote_count);
-		else if (strcasecmp(args.field, "rtt") == 0)
+		else if (!strcasecmp(args.field, "rtt"))
 			snprintf(buf, buflen, "%.0f", qos.rtt * 1000.0);
-		else if (strcasecmp(args.field, "all") == 0)
+		else if (!strcasecmp(args.field, "all"))
 			ast_copy_string(buf, all, buflen);
 		else if (!ast_rtp_get_qos(rtp, args.field, buf, buflen))
 			 ;




More information about the asterisk-commits mailing list