aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_festival.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-01 18:22:39 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-01 18:22:39 +0000
commitea96823f2626e2a4178eec54f8a78a666d376ac1 (patch)
treed6fd63606de3355d2e0f7bb2ab751116095a1451 /apps/app_festival.c
parent1c4fdfd503883d806ba05da5d0e9156b54a4d51b (diff)
fix a bunch of potential problems found by gcc 4.3.x, primarily bare strings being passed to printf()-like functions and ignored results from read()/write() and friends
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@153337 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_festival.c')
-rw-r--r--apps/app_festival.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/apps/app_festival.c b/apps/app_festival.c
index 2aceceefd..ab05824f5 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -45,6 +45,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
+#include <errno.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
@@ -160,7 +161,9 @@ static int send_waveform_to_fd(char *waveform, int length, int fd) {
}
#endif
- write(fd,waveform,length);
+ if (write(fd,waveform,length) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
close(fd);
exit(0);
}
@@ -431,17 +434,25 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
writecache=1;
strln=strlen((char *)data);
ast_log(LOG_DEBUG,"line length : %d\n",strln);
- write(fdesc,&strln,sizeof(int));
- write(fdesc,data,strln);
+ if (write(fdesc,&strln,sizeof(int)) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
+ if (write(fdesc,data,strln) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
seekpos=lseek(fdesc,0,SEEK_CUR);
ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos);
}
} else {
- read(fdesc,&strln,sizeof(int));
+ if (read(fdesc,&strln,sizeof(int)) != sizeof(int)) {
+ ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
+ }
ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
if (strlen((char *)data)==strln) {
ast_log(LOG_DEBUG,"Size OK\n");
- read(fdesc,&bigstring,strln);
+ if (read(fdesc,&bigstring,strln) != strln) {
+ ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
+ }
bigstring[strln] = 0;
if (strcmp(bigstring,data)==0) {
readcache=1;
@@ -470,7 +481,9 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
if (writecache==1) {
ast_log(LOG_DEBUG,"Writing result to cache...\n");
while ((strln=read(fd,buffer,16384))!=0) {
- write(fdesc,buffer,strln);
+ if (write(fdesc,buffer,strln) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
}
close(fd);
close(fdesc);