[asterisk-commits] russell: branch russell/smdi-1.4 r93292 - /team/russell/smdi-1.4/res/res_smdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 17 14:14:14 CST 2007


Author: russell
Date: Mon Dec 17 14:14:13 2007
New Revision: 93292

URL: http://svn.digium.com/view/asterisk?view=rev&rev=93292
Log:
use sizeof() instead of constants where appropriate

Modified:
    team/russell/smdi-1.4/res/res_smdi.c

Modified: team/russell/smdi-1.4/res/res_smdi.c
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/res/res_smdi.c?view=diff&rev=93292&r1=93291&r2=93292
==============================================================================
--- team/russell/smdi-1.4/res/res_smdi.c (original)
+++ team/russell/smdi-1.4/res/res_smdi.c Mon Dec 17 14:14:13 2007
@@ -508,23 +508,23 @@
 			ASTOBJ_INIT(md_msg);
 
 			/* read the message desk number */
-			for (i = 0; i < SMDI_MESG_DESK_NUM_LEN; i++)
+			for (i = 0; i < sizeof(md_msg->mesg_desk_num) - 1; i++)
 				md_msg->mesg_desk_num[i] = fgetc(iface->file);
 
-			md_msg->mesg_desk_num[SMDI_MESG_DESK_NUM_LEN] = '\0';
+			md_msg->mesg_desk_num[sizeof(md_msg->mesg_desk_num) - 1] = '\0';
 
 			/* read the message desk terminal number */
-			for (i = 0; i < SMDI_MESG_DESK_TERM_LEN; i++)
+			for (i = 0; i < sizeof(md_msg->mesg_desk_term) - 1; i++)
 				md_msg->mesg_desk_term[i] = fgetc(iface->file);
 
-			md_msg->mesg_desk_term[SMDI_MESG_DESK_TERM_LEN] = '\0';
+			md_msg->mesg_desk_term[sizeof(md_msg->mesg_desk_term) - 1] = '\0';
 
 			/* read the message type */
 			md_msg->type = fgetc(iface->file);
 		   
 			/* read the forwarding station number (may be blank) */
 			cp = &md_msg->fwd_st[0];
-			for (i = 0; i < SMDI_MAX_STATION_NUM_LEN + 1; i++) {
+			for (i = 0; i < sizeof(md_msg->fwd_st) - 1; i++) {
 				if ((c = fgetc(iface->file)) == ' ') {
 					*cp = '\0';
 					break;
@@ -536,12 +536,12 @@
 			}
 
 			/* make sure the value is null terminated, even if this truncates it */
-			md_msg->fwd_st[SMDI_MAX_STATION_NUM_LEN] = '\0';
+			md_msg->fwd_st[sizeof(md_msg->fwd_st) - 1] = '\0';
 			cp = NULL;
 			
 			/* read the calling station number (may be blank) */
 			cp = &md_msg->calling_st[0];
-			for (i = 0; i < SMDI_MAX_STATION_NUM_LEN + 1; i++) {
+			for (i = 0; i < sizeof(md_msg->calling_st) - 1; i++) {
 				if (!isdigit((c = fgetc(iface->file)))) {
 					*cp = '\0';
 					break;
@@ -553,7 +553,7 @@
 			}
 
 			/* make sure the value is null terminated, even if this truncates it */
-			md_msg->calling_st[SMDI_MAX_STATION_NUM_LEN] = '\0';
+			md_msg->calling_st[sizeof(md_msg->calling_st) - 1] = '\0';
 			cp = NULL;
 
 			/* add the message to the message queue */
@@ -578,7 +578,7 @@
 			
 			/* read the forwarding station number (may be blank) */
 			cp = &mwi_msg->fwd_st[0];
-			for (i = 0; i < SMDI_MAX_STATION_NUM_LEN + 1; i++) {
+			for (i = 0; i < sizeof(mwi_msg->fwd_st) - 1; i++) {
 				if ((c = fgetc(iface->file)) == ' ') {
 					*cp = '\0';
 					break;
@@ -590,14 +590,14 @@
 			}
 
 			/* make sure the station number is null terminated, even if this will truncate it */
-			mwi_msg->fwd_st[SMDI_MAX_STATION_NUM_LEN] = '\0';
+			mwi_msg->fwd_st[sizeof(mwi_msg->fwd_st) - 1] = '\0';
 			cp = NULL;
 			
 			/* read the mwi failure cause */
-			for (i = 0; i < SMDI_MWI_FAIL_CAUSE_LEN; i++)
+			for (i = 0; i < sizeof(mwi_msg->cause) - 1; i++)
 				mwi_msg->cause[i] = fgetc(iface->file);
 
-			mwi_msg->cause[SMDI_MWI_FAIL_CAUSE_LEN] = '\0';
+			mwi_msg->cause[sizeof(mwi_msg->cause) - 1] = '\0';
 
 			/* add the message to the message queue */
 			mwi_msg->timestamp = ast_tvnow();




More information about the asterisk-commits mailing list