aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-04-20 12:27:57 +0200
committerTakashi Iwai <tiwai@suse.de>2011-04-20 12:27:57 +0200
commit800c36edf721fa05c450ac231ac9b02401b2243c (patch)
tree8b664662165ce34c71dfef5361552178ea50b436
parent7e10b24f842843a05b97d36f9bf8a37b23bc5994 (diff)
downloadsalsa-lib-800c36edf721fa05c450ac231ac9b02401b2243c.tar.gz
Add memzero_valgrind() macro
-rw-r--r--src/async.c5
-rw-r--r--src/control.c14
-rw-r--r--src/local.h6
-rw-r--r--src/pcm.c6
-rw-r--r--src/pcm_misc.c2
-rw-r--r--src/rawmidi.c2
-rw-r--r--src/timer.c2
7 files changed, 22 insertions, 15 deletions
diff --git a/src/async.c b/src/async.c
index 0dd8fb9..a1222fd 100644
--- a/src/async.c
+++ b/src/async.c
@@ -30,6 +30,7 @@
#include <sys/ioctl.h>
#include "recipe.h"
#include "global.h"
+#include "local.h"
static snd_async_handler_t *async_list;
@@ -90,7 +91,7 @@ int snd_async_add_handler(snd_async_handler_t **handler, int fd,
}
if (!async_list) {
struct sigaction act;
- memset(&act, 0, sizeof(act));
+ memzero_valgrind(&act, sizeof(act));
act.sa_flags = SA_RESTART | SA_SIGINFO;
act.sa_sigaction = snd_async_handler;
sigemptyset(&act.sa_mask);
@@ -126,7 +127,7 @@ int snd_async_del_handler(snd_async_handler_t *handler)
if (!async_list) {
struct sigaction act;
- memset(&act, 0, sizeof(act));
+ memzero_valgrind(&act, sizeof(act));
act.sa_flags = 0;
act.sa_handler = SIG_DFL;
sigaction(SIGIO, &act, NULL);
diff --git a/src/control.c b/src/control.c
index d0a68b2..f04892e 100644
--- a/src/control.c
+++ b/src/control.c
@@ -107,7 +107,7 @@ int snd_ctl_elem_add_integer(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
unsigned int i;
int err;
- memset(&info, 0, sizeof(info));
+ memzero_valgrind(&info, sizeof(info));
info.id = *id;
info.type = SND_CTL_ELEM_TYPE_INTEGER;
info.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
@@ -121,7 +121,7 @@ int snd_ctl_elem_add_integer(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
err = snd_ctl_elem_add(ctl, &info);
if (err < 0)
return err;
- memset(&val, 0, sizeof(val));
+ memzero_valgrind(&val, sizeof(val));
val.id = *id;
for (i = 0; i < count; i++)
val.value.integer.value[i] = min;
@@ -137,7 +137,7 @@ int snd_ctl_elem_add_integer64(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
unsigned int i;
int err;
- memset(&info, 0, sizeof(info));
+ memzero_valgrind(&info, sizeof(info));
info.id = *id;
info.type = SND_CTL_ELEM_TYPE_INTEGER64;
info.count = count;
@@ -147,7 +147,7 @@ int snd_ctl_elem_add_integer64(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
err = snd_ctl_elem_add(ctl, &info);
if (err < 0)
return err;
- memset(&val, 0, sizeof(val));
+ memzero_valgrind(&val, sizeof(val));
val.id = *id;
for (i = 0; i < count; i++)
val.value.integer64.value[i] = min;
@@ -159,7 +159,7 @@ int snd_ctl_elem_add_boolean(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
{
snd_ctl_elem_info_t info;
- memset(&info, 0, sizeof(info));
+ memzero_valgrind(&info, sizeof(info));
info.id = *id;
info.type = SND_CTL_ELEM_TYPE_BOOLEAN;
info.count = count;
@@ -172,7 +172,7 @@ int snd_ctl_elem_add_iec958(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id)
{
snd_ctl_elem_info_t info;
- memset(&info, 0, sizeof(info));
+ memzero_valgrind(&info, sizeof(info));
info.id = *id;
info.type = SND_CTL_ELEM_TYPE_IEC958;
info.count = 1;
@@ -222,7 +222,7 @@ static int snd_ctl_tlv_do(snd_ctl_t *ctl, int cmd,
if (!id->numid) {
int err;
snd_ctl_elem_info_t info;
- memset(&info, 0, sizeof(info));
+ memzero_valgrind(&info, sizeof(info));
info.id = *id;
id = &info.id;
err = snd_ctl_elem_info(ctl, &info);
diff --git a/src/local.h b/src/local.h
index abe37d3..1e09a9b 100644
--- a/src/local.h
+++ b/src/local.h
@@ -7,4 +7,10 @@ int _snd_ctl_hw_open(snd_ctl_t **ctlp, int card);
int _snd_pcm_mmap(snd_pcm_t *pcm);
int _snd_pcm_munmap(snd_pcm_t *pcm);
+#ifdef DELIGHT_VALGRIND
+#define memzero_valgrind(buf, size) memset(buf, 0, size)
+#else
+#define memzero_valgrind(buf, size)
+#endif
+
#endif /* __LOCAL_H_INC */
diff --git a/src/pcm.c b/src/pcm.c
index 3d19012..b5d3cbc 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -60,7 +60,7 @@ static int open_with_subdev(const char *filename, int fmode,
fd = open(filename, fmode);
if (fd < 0)
return -errno;
- memset(&info, 0, sizeof(info));
+ memzero_valgrind(&info, sizeof(info));
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, &info) >= 0 &&
info.subdevice == subdev) {
snd_ctl_close(ctl);
@@ -113,7 +113,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
}
if (subdev < 0) {
snd_pcm_info_t info;
- memset(&info, 0, sizeof(info));
+ memzero_valgrind(&info, sizeof(info));
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, &info) < 0) {
err = -errno;
goto error;
@@ -948,7 +948,7 @@ static snd_pcm_uframes_t snd_pcm_mmap_avail(snd_pcm_t *pcm)
return snd_pcm_mmap_capture_avail(pcm);
}
-snd_pcm_sframes_t snd_pcm_hw_forwardable(struct snd_pcm_t *pcm)
+snd_pcm_sframes_t snd_pcm_hw_forwardable(snd_pcm_t *pcm)
__attribute__ ((alias("snd_pcm_mmap_avail")));
snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm)
diff --git a/src/pcm_misc.c b/src/pcm_misc.c
index 7360732..5423949 100644
--- a/src/pcm_misc.c
+++ b/src/pcm_misc.c
@@ -283,7 +283,7 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
int i, p, w;
u_int64_t silence;
- if (format < 0 || format > SNDRV_PCM_FORMAT_LAST)
+ if ((int)format < 0 || (int)format > SNDRV_PCM_FORMAT_LAST)
return 0;
fmt = &pcm_formats[format];
if (!fmt->phys)
diff --git a/src/rawmidi.c b/src/rawmidi.c
index b3e67c3..2880b79 100644
--- a/src/rawmidi.c
+++ b/src/rawmidi.c
@@ -50,7 +50,7 @@ static int open_with_subdev(const char *filename, int fmode,
fd = open(filename, fmode);
if (fd < 0)
return -errno;
- memset(&info, 0, sizeof(info));
+ memzero_valgrind(&info, sizeof(info));
info.stream = ((fmode & O_ACCMODE) != O_RDONLY) ?
SNDRV_RAWMIDI_STREAM_OUTPUT : SNDRV_RAWMIDI_STREAM_INPUT;
if (ioctl(fd, SNDRV_RAWMIDI_IOCTL_INFO, &info) >= 0 &&
diff --git a/src/timer.c b/src/timer.c
index d9254b0..64c0ce0 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -65,7 +65,7 @@ int snd_timer_open(snd_timer_t **handle, const char *name, int mode)
return err;
}
}
- memset(&sel, 0, sizeof(sel));
+ memzero_valgrind(&sel, sizeof(sel));
sel.id.dev_class = dev_class;
sel.id.dev_sclass = dev_sclass;
sel.id.card = card;