[asterisk-commits] tilghman: trunk r276120 - /trunk/funcs/func_env.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 13 14:00:06 CDT 2010
Author: tilghman
Date: Tue Jul 13 14:00:02 2010
New Revision: 276120
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=276120
Log:
It really cannot fail in the places below, but the stupid compiler doesn't know that.
Modified:
trunk/funcs/func_env.c
Modified: trunk/funcs/func_env.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_env.c?view=diff&rev=276120&r1=276119&r2=276120
==============================================================================
--- trunk/funcs/func_env.c (original)
+++ trunk/funcs/func_env.c Tue Jul 13 14:00:02 2010
@@ -498,7 +498,10 @@
return 0;
}
- fseeko(ff, 0, SEEK_END);
+ if (fseeko(ff, 0, SEEK_END) < 0) {
+ ast_log(LOG_ERROR, "Cannot seek to end of '%s': %s\n", args.filename, strerror(errno));
+ return -1;
+ }
flength = ftello(ff);
if (offset < 0) {
@@ -573,6 +576,7 @@
fclose(ff);
return -1;
}
+
flength = ftello(ff);
if (length == LLONG_MAX) {
@@ -876,8 +880,12 @@
/* Write out the value, then write just up until where we last moved some data */
if (fwrite(value, 1, vlength, ff) < vlength) {
ast_log(LOG_ERROR, "Short write?!!\n");
- } else if (fwrite(fbuf, 1, (foplen = lastwritten - ftello(ff)), ff) < foplen) {
- ast_log(LOG_ERROR, "Short write?!!\n");
+ } else {
+ off_t curpos = ftello(ff);
+ foplen = lastwritten - curpos;
+ if (fwrite(fbuf, 1, foplen, ff) < foplen) {
+ ast_log(LOG_ERROR, "Short write?!!\n");
+ }
}
fclose(ff);
}
@@ -1153,8 +1161,12 @@
ast_log(LOG_ERROR, "Short write?!!\n");
fclose(ff);
return -1;
- } else if (fwrite(fbuf, 1, (foplen = lastwritten - ftello(ff)), ff) < foplen) {
- ast_log(LOG_ERROR, "Short write?!!\n");
+ } else {
+ off_t curpos = ftello(ff);
+ foplen = lastwritten - curpos;
+ if (fwrite(fbuf, 1, foplen, ff) < foplen) {
+ ast_log(LOG_ERROR, "Short write?!!\n");
+ }
}
fclose(ff);
}
More information about the asterisk-commits
mailing list