aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-02 23:56:13 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-02 23:56:13 +0000
commitee246d0e0519c6aa7cb0aea17ea92c9a5c2dc16f (patch)
tree80dccc06626175232f48f4c2cde5b9f5ba602632 /res/res_musiconhold.c
parent11aedae560fa003f20ee8d7a02b7aa2fc17ae13a (diff)
import gcc 4.3.2 warning fixes from trunk, with a few changes specific to this branch
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@153710 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 9a34c293f..2e89cf8a0 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -512,7 +512,10 @@ static int spawn_mp3(struct mohclass *class)
ast_close_fds_above_n(STDERR_FILENO);
/* Child */
- chdir(class->dir);
+ if (chdir(class->dir) < 0) {
+ ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
+ _exit(1);
+ }
if (ast_test_flag(class, MOH_CUSTOM)) {
execv(argv[0], argv);
} else {
@@ -924,8 +927,14 @@ static int moh_scan_files(struct mohclass *class) {
class->total_files = 0;
dirnamelen = strlen(class->dir) + 2;
- getcwd(path, sizeof(path));
- chdir(class->dir);
+ if (!getcwd(path, sizeof(path))) {
+ ast_log(LOG_WARNING, "getcwd() failed: %s\n", strerror(errno));
+ return -1;
+ }
+ if (chdir(class->dir) < 0) {
+ ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
+ return -1;
+ }
while ((files_dirent = readdir(files_DIR))) {
/* The file name must be at least long enough to have the file type extension */
if ((strlen(files_dirent->d_name) < 4))
@@ -962,7 +971,10 @@ static int moh_scan_files(struct mohclass *class) {
}
closedir(files_DIR);
- chdir(path);
+ if (chdir(path) < 0) {
+ ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
+ return -1;
+ }
if (ast_test_flag(class, MOH_SORTALPHA))
qsort(&class->filearray[0], class->total_files, sizeof(char *), moh_sort_compare);
return class->total_files;