Avoid pointer arithmetic on void *

The pointer operand to the binary `+` operator must be to a complete
object type.

Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Michael Forney 2020-02-05 00:12:19 -08:00 committed by Takashi Iwai
parent f80a290153
commit 62a765087e
5 changed files with 10 additions and 9 deletions

View file

@ -442,7 +442,7 @@ static ssize_t xwrite(int fd, const void *buf, size_t count)
size_t offset = 0;
while (offset < count) {
written = write(fd, buf + offset, count - offset);
written = write(fd, (char *)buf + offset, count - offset);
if (written <= 0)
return written;
@ -1210,7 +1210,7 @@ static int test_au(int fd, void *buffer)
hwparams.channels = BE_INT(ap->channels);
if (hwparams.channels < 1 || hwparams.channels > 256)
return -1;
if ((size_t)safe_read(fd, buffer + sizeof(AuHeader), BE_INT(ap->hdr_size) - sizeof(AuHeader)) != BE_INT(ap->hdr_size) - sizeof(AuHeader)) {
if ((size_t)safe_read(fd, (char *)buffer + sizeof(AuHeader), BE_INT(ap->hdr_size) - sizeof(AuHeader)) != BE_INT(ap->hdr_size) - sizeof(AuHeader)) {
error(_("read error"));
prg_exit(EXIT_FAILURE);
}

View file

@ -146,9 +146,10 @@ static int irq_mmap_process_frames(struct libasound_state *state,
// TODO: Perhaps, the complex layout can be supported as a variation of
// vector type. However, there's no driver with this layout.
if (layout->vector == NULL) {
frame_buf = areas[0].addr;
frame_buf += snd_pcm_frames_to_bytes(state->handle,
frame_offset);
char *buf;
buf = areas[0].addr;
buf += snd_pcm_frames_to_bytes(state->handle, frame_offset);
frame_buf = buf;
} else {
int i;
for (i = 0; i < layout->samples_per_frame; ++i) {

View file

@ -100,8 +100,8 @@ static void *get_buffer(struct libasound_state *state,
if (layout->vector == NULL) {
char *buf;
buf = areas[0].addr + snd_pcm_frames_to_bytes(state->handle,
frame_offset);
buf = areas[0].addr;
buf += snd_pcm_frames_to_bytes(state->handle, frame_offset);
frame_buf = buf;
} else {
int i;

View file

@ -231,7 +231,7 @@ int generate_input_data(struct bat *bat, void *buffer, int bytes, int frames)
load = 0;
while (1) {
err = fread(buffer + load, 1, bytes - load, bat->fp);
err = fread((char *)buffer + load, 1, bytes - load, bat->fp);
if (0 == err) {
if (feof(bat->fp)) {
fprintf(bat->log,

View file

@ -633,7 +633,7 @@ static void handle_big_sysex(snd_seq_event_t *ev)
check_snd("sync output", err);
if (sleep(1))
fatal("aborted");
ev->data.ext.ptr += MIDI_BYTES_PER_SEC;
ev->data.ext.ptr = (char *)ev->data.ext.ptr + MIDI_BYTES_PER_SEC;
length -= MIDI_BYTES_PER_SEC;
}
ev->data.ext.len = length;