All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Michael Forney <mforney@mforney.org>
Cc: alsa-devel@alsa-project.org
Subject: Re: [alsa-devel] [PATCH alsa-utils 2/4] Avoid pointer arithmetic on `void *`
Date: Wed, 5 Feb 2020 19:21:17 +0900	[thread overview]
Message-ID: <20200205102116.GB9810@workstation> (raw)
In-Reply-To: <20200205081221.18665-2-mforney@mforney.org>

On Wed, Feb 05, 2020 at 12:12:19AM -0800, Michael Forney wrote:
> The pointer operand to the binary `+` operator must be to a complete
> object type.
> 
> Signed-off-by: Michael Forney <mforney@mforney.org>
> ---
>  aplay/aplay.c                     | 4 ++--
>  axfer/xfer-libasound-irq-mmap.c   | 7 ++++---
>  axfer/xfer-libasound-timer-mmap.c | 4 ++--
>  bat/common.c                      | 2 +-
>  seq/aplaymidi/aplaymidi.c         | 2 +-
>  5 files changed, 10 insertions(+), 9 deletions(-)

These changes look good to me.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

> diff --git a/aplay/aplay.c b/aplay/aplay.c
> index 908093c..08395f6 100644
> --- a/aplay/aplay.c
> +++ b/aplay/aplay.c
> @@ -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);
>  	}
> diff --git a/axfer/xfer-libasound-irq-mmap.c b/axfer/xfer-libasound-irq-mmap.c
> index a13b3c3..386e741 100644
> --- a/axfer/xfer-libasound-irq-mmap.c
> +++ b/axfer/xfer-libasound-irq-mmap.c
> @@ -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) {
> diff --git a/axfer/xfer-libasound-timer-mmap.c b/axfer/xfer-libasound-timer-mmap.c
> index 1c642fe..ba26e29 100644
> --- a/axfer/xfer-libasound-timer-mmap.c
> +++ b/axfer/xfer-libasound-timer-mmap.c
> @@ -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;
> diff --git a/bat/common.c b/bat/common.c
> index d3d1f28..339e749 100644
> --- a/bat/common.c
> +++ b/bat/common.c
> @@ -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,
> diff --git a/seq/aplaymidi/aplaymidi.c b/seq/aplaymidi/aplaymidi.c
> index 12d6fac..b086e70 100644
> --- a/seq/aplaymidi/aplaymidi.c
> +++ b/seq/aplaymidi/aplaymidi.c
> @@ -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;
> -- 
> 2.25.0
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2020-02-05 10:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05  8:12 [alsa-devel] [PATCH alsa-utils 1/4] Use __func__ instead of __FUNCTION__ Michael Forney
2020-02-05  8:12 ` [alsa-devel] [PATCH alsa-utils 2/4] Avoid pointer arithmetic on `void *` Michael Forney
2020-02-05 10:21   ` Takashi Sakamoto [this message]
2020-02-05 15:50   ` Clemens Ladisch
2020-02-06  0:00     ` Michael Forney
2020-02-05  8:12 ` [alsa-devel] [PATCH alsa-utils 3/4] Use %lli for long long in printf Michael Forney
2020-02-05 10:24   ` Takashi Sakamoto
2020-02-05  8:12 ` [alsa-devel] [PATCH alsa-utils 4/4] Avoid empty initializer list Michael Forney
2020-02-05 10:25   ` Takashi Sakamoto
2020-02-06  0:02     ` Michael Forney
2020-02-06  1:53       ` Takashi Sakamoto
2020-02-05 10:19 ` [alsa-devel] [PATCH alsa-utils 1/4] Use __func__ instead of __FUNCTION__ Takashi Sakamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200205102116.GB9810@workstation \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=mforney@mforney.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.