aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/directory.c2
-rw-r--r--src/state_file.c2
-rw-r--r--src/volume.c25
3 files changed, 14 insertions, 15 deletions
diff --git a/src/directory.c b/src/directory.c
index cb1995a93..5a5aaf3e5 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -967,7 +967,7 @@ int writeDirectoryDB(void)
DEBUG("writing DB\n");
- while (((fd = open(dbFile, O_WRONLY|O_TRUNC|O_CREAT)) < 0) &&
+ while (((fd = open(dbFile, O_WRONLY|O_TRUNC|O_CREAT, 0666)) < 0) &&
errno == EINTR);
if (fd < 0) {
ERROR("unable to write to db file \"%s\": %s\n",
diff --git a/src/state_file.c b/src/state_file.c
index b7f28e538..365baec0f 100644
--- a/src/state_file.c
+++ b/src/state_file.c
@@ -55,7 +55,7 @@ void write_state_file(void)
if (!sfpath)
return;
- while (((fd = open(sfpath, O_WRONLY|O_TRUNC|O_CREAT)) < 0) &&
+ while (((fd = open(sfpath, O_WRONLY|O_TRUNC|O_CREAT, 0666)) < 0) &&
errno == EINTR);
if (fd < 0) {
ERROR("problems opening state file \"%s\" for writing: %s\n",
diff --git a/src/volume.c b/src/volume.c
index bdb911916..be32f3a85 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -77,6 +77,8 @@ static int volume_alsaSet = -1;
#ifdef HAVE_OSS
+#include <alloca.h> /* only alloca user in mpd atm, may change ... */
+
static void closeOssMixer(void)
{
while (close(volume_ossFd) && errno == EINTR) ;
@@ -92,12 +94,9 @@ static int prepOssMixer(const char *device)
return -1;
}
- param = getConfigParam(CONF_MIXER_CONTROL);
-
- if (param) {
+ if ((param = getConfigParam(CONF_MIXER_CONTROL))) {
const char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
- char *duplicated;
- int i, j;
+ int i;
int devmask = 0;
if (ioctl(volume_ossFd, SOUND_MIXER_READ_DEVMASK, &devmask) < 0) {
@@ -107,16 +106,16 @@ static int prepOssMixer(const char *device)
}
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
- duplicated = xstrdup(labels[i]);
+ ssize_t len = strlen(labels[i]);
+ char *duplicated = alloca(len + 1);
+
/* eliminate spaces at the end */
- j = strlen(duplicated) - 1;
- while (j >= 0 && duplicated[j] == ' ')
- duplicated[j--] = '\0';
- if (strcasecmp(duplicated, param->value) == 0) {
- free(duplicated);
+ memcpy(duplicated, labels[i], len + 1);
+ len -= 2;
+ while (len >= 0 && duplicated[len] == ' ')
+ duplicated[len--] = '\0';
+ if (strcasecmp(duplicated, param->value) == 0)
break;
- }
- free(duplicated);
}
if (i >= SOUND_MIXER_NRDEVICES) {