r4137 - developers/sean_chiang/gsm-pm
sean_chiang at sita.openmoko.org
sean_chiang at sita.openmoko.org
Fri Feb 29 10:14:52 CET 2008
Author: sean_chiang
Date: 2008-02-29 10:14:50 +0100 (Fri, 29 Feb 2008)
New Revision: 4137
Modified:
developers/sean_chiang/gsm-pm/gsm-pm.c
Log:
replace sprintf with snprintf
Modified: developers/sean_chiang/gsm-pm/gsm-pm.c
===================================================================
--- developers/sean_chiang/gsm-pm/gsm-pm.c 2008-02-29 08:41:52 UTC (rev 4136)
+++ developers/sean_chiang/gsm-pm/gsm-pm.c 2008-02-29 09:14:50 UTC (rev 4137)
@@ -118,25 +118,25 @@
p_DEV = getenv("GSM_DEV");
if ( p_DL ) {
- sprintf(buf, "echo \"1\" > %s", p_DL);
+ snprintf(buf, sizeof(buf), "echo \"1\" > %s", p_DL);
system(buf);
sleep(1);
}
if ( p_POW ) {
- sprintf(buf, "echo \"0\" > %s", p_POW);
+ snprintf(buf, sizeof(buf), "echo \"0\" > %s", p_POW);
system(buf);
sleep(1);
- sprintf(buf, "echo \"1\" > %s", p_POW);
+ snprintf(buf, sizeof(buf), "echo \"1\" > %s", p_POW);
system(buf);
sleep(1);
}
if ( p_RES ) {
- sprintf(buf, "echo \"1\" > %s", p_RES);
+ snprintf(buf, sizeof(buf), "echo \"1\" > %s", p_RES);
system(buf);
sleep(1);
- sprintf(buf, "echo \"0\" > %s", p_RES);
+ snprintf(buf, sizeof(buf), "echo \"0\" > %s", p_RES);
system(buf);
sleep(2);
}
@@ -145,7 +145,7 @@
if ( p_OPTS && p_DEV ) {
- sprintf(buf, "start-stop-daemon -S -x /usr/sbin/gsmd -- gsmd -p %s %s >/tmp/gsm.log 2>&1", p_DEV,p_OPTS);
+ snprintf(buf, sizeof(buf), "start-stop-daemon -S -x /usr/sbin/gsmd -- gsmd -p %s %s >/tmp/gsm.log 2>&1", p_DEV,p_OPTS);
system(buf);
}
@@ -166,6 +166,8 @@
}
drain(fd);
+
+ sleep(1);
if ( write(fd, "AT\r", 3) <= 0 ) {
printf("1 error\n");
@@ -184,7 +186,7 @@
sleep(1);
if ( p_POW ) {
- sprintf(buf, "echo \"0\" > %s", p_POW);
+ snprintf(buf, sizeof(buf), "echo \"0\" > %s", p_POW);
system(buf);
}
}
More information about the commitlog
mailing list