Merged revisions 59281 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 27 Mar 2007 23:34:57 +0000 (23:34 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 27 Mar 2007 23:34:57 +0000 (23:34 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r59281 | tilghman | 2007-03-27 18:32:46 -0500 (Tue, 27 Mar 2007) | 10 lines

Merged revisions 59280 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r59280 | tilghman | 2007-03-27 18:31:20 -0500 (Tue, 27 Mar 2007) | 2 lines

Fix a few remaining bad mmap(2) return values

........

................

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@59282 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index 9fcdb06..9787333 100644 (file)
@@ -991,7 +991,7 @@ static int retrieve_file(char *dir, int msgnum)
        int res;
        int fd=-1;
        size_t fdlen = 0;
-       void *fdm=NULL;
+       void *fdm = MAP_FAILED;
        SQLSMALLINT colcount=0;
        SQLHSTMT stmt;
        char sql[PATH_MAX];
@@ -1108,7 +1108,7 @@ static int retrieve_file(char *dir, int msgnum)
                                        }
                                        /* Read out in small chunks */
                                        for (offset = 0; offset < colsize2; offset += CHUNKSIZE) {
-                                               if ((fdm = mmap(NULL, CHUNKSIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)) == (void *)-1) {
+                                               if ((fdm = mmap(NULL, CHUNKSIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)) == MAP_FAILED) {
                                                        ast_log(LOG_WARNING, "Could not mmap the output file: %s (%d)\n", strerror(errno), errno);
                                                        SQLFreeHandle(SQL_HANDLE_STMT, stmt);
                                                        ast_odbc_release_obj(obj);
@@ -1386,7 +1386,7 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms
        int x = 0;
        int res;
        int fd = -1;
-       void *fdm=NULL;
+       void *fdm = MAP_FAILED;
        size_t fdlen = -1;
        SQLHSTMT stmt;
        SQLINTEGER len;
@@ -1442,7 +1442,7 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms
                lseek(fd, 0, SEEK_SET);
                printf("Length is %zd\n", fdlen);
                fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED,fd, 0);
-               if (!fdm) {
+               if (fdm != MAP_FAILED) {
                        ast_log(LOG_WARNING, "Memory map failed!\n");
                        ast_odbc_release_obj(obj);
                        goto yuck;
@@ -1491,7 +1491,7 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms
 yuck:  
        if (cfg)
                ast_config_destroy(cfg);
-       if (fdm)
+       if (fdm != MAP_FAILED)
                munmap(fdm, fdlen);
        if (fd > -1)
                close(fd);